mirror of https://github.com/PCSX2/pcsx2.git
Qt: Elide redundant scan progress updates
Fixes UI locking up for ages when switching theme.
This commit is contained in:
parent
a77f78f08f
commit
f0f23a2c61
|
@ -204,6 +204,8 @@ void MainWindow::setupAdditionalUi()
|
||||||
m_status_progress_widget = new QProgressBar(m_ui.statusBar);
|
m_status_progress_widget = new QProgressBar(m_ui.statusBar);
|
||||||
m_status_progress_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
m_status_progress_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||||
m_status_progress_widget->setFixedSize(140, 16);
|
m_status_progress_widget->setFixedSize(140, 16);
|
||||||
|
m_status_progress_widget->setMinimum(0);
|
||||||
|
m_status_progress_widget->setMaximum(100);
|
||||||
m_status_progress_widget->hide();
|
m_status_progress_widget->hide();
|
||||||
|
|
||||||
m_status_verbose_widget = new QLabel(m_ui.statusBar);
|
m_status_verbose_widget = new QLabel(m_ui.statusBar);
|
||||||
|
@ -820,8 +822,9 @@ void MainWindow::updateWindowState(bool force_visible)
|
||||||
|
|
||||||
void MainWindow::setProgressBar(int current, int total)
|
void MainWindow::setProgressBar(int current, int total)
|
||||||
{
|
{
|
||||||
m_status_progress_widget->setValue(current);
|
const int value = (current * 100) / total;
|
||||||
m_status_progress_widget->setMaximum(total);
|
if (m_status_progress_widget->value() != value)
|
||||||
|
m_status_progress_widget->setValue(value);
|
||||||
|
|
||||||
if (m_status_progress_widget->isVisible())
|
if (m_status_progress_widget->isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -547,11 +547,14 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
|
||||||
(FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES),
|
(FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES),
|
||||||
&files);
|
&files);
|
||||||
|
|
||||||
|
u32 files_scanned = 0;
|
||||||
progress->SetProgressRange(static_cast<u32>(files.size()));
|
progress->SetProgressRange(static_cast<u32>(files.size()));
|
||||||
progress->SetProgressValue(0);
|
progress->SetProgressValue(0);
|
||||||
|
|
||||||
for (FILESYSTEM_FIND_DATA& ffd : files)
|
for (FILESYSTEM_FIND_DATA& ffd : files)
|
||||||
{
|
{
|
||||||
|
files_scanned++;
|
||||||
|
|
||||||
if (progress->IsCancelled() || !GameList::IsScannableFilename(ffd.FileName) ||
|
if (progress->IsCancelled() || !GameList::IsScannableFilename(ffd.FileName) ||
|
||||||
IsPathExcluded(excluded_paths, ffd.FileName))
|
IsPathExcluded(excluded_paths, ffd.FileName))
|
||||||
{
|
{
|
||||||
|
@ -564,7 +567,6 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
|
||||||
AddFileFromCache(ffd.FileName, ffd.ModificationTime) ||
|
AddFileFromCache(ffd.FileName, ffd.ModificationTime) ||
|
||||||
only_cache)
|
only_cache)
|
||||||
{
|
{
|
||||||
progress->IncrementProgressValue();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,10 +574,10 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
|
||||||
// ownership of fp is transferred
|
// ownership of fp is transferred
|
||||||
progress->SetFormattedStatusText("Scanning '%s'...", FileSystem::GetDisplayNameFromPath(ffd.FileName).c_str());
|
progress->SetFormattedStatusText("Scanning '%s'...", FileSystem::GetDisplayNameFromPath(ffd.FileName).c_str());
|
||||||
ScanFile(std::move(ffd.FileName), ffd.ModificationTime);
|
ScanFile(std::move(ffd.FileName), ffd.ModificationTime);
|
||||||
progress->IncrementProgressValue();
|
progress->SetProgressValue(files_scanned);
|
||||||
}
|
}
|
||||||
|
|
||||||
progress->SetProgressValue(static_cast<u32>(files.size()));
|
progress->SetProgressValue(files_scanned);
|
||||||
progress->PopState();
|
progress->PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue