mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 09:35:40 +00:00
Qt: Delay showing game list refresh progress
Otherwise we spend more time updating the visuals than actually scanning.
This commit is contained in:
parent
a84bf0d8cf
commit
ddcc29c8a6
|
@ -339,7 +339,7 @@ void QtHostInterface::refreshGameList(bool invalidate_cache /* = false */, bool
|
||||||
std::lock_guard<std::recursive_mutex> lock(m_settings_mutex);
|
std::lock_guard<std::recursive_mutex> lock(m_settings_mutex);
|
||||||
m_game_list->SetSearchDirectoriesFromSettings(*m_settings_interface.get());
|
m_game_list->SetSearchDirectoriesFromSettings(*m_settings_interface.get());
|
||||||
|
|
||||||
QtProgressCallback progress(m_main_window);
|
QtProgressCallback progress(m_main_window, invalidate_cache ? 0.0f : 1.0f);
|
||||||
m_game_list->Refresh(invalidate_cache, invalidate_database, &progress);
|
m_game_list->Refresh(invalidate_cache, invalidate_database, &progress);
|
||||||
emit gameListRefreshed();
|
emit gameListRefreshed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
#include <QtWidgets/QMessageBox>
|
#include <QtWidgets/QMessageBox>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
QtProgressCallback::QtProgressCallback(QWidget* parent_widget)
|
QtProgressCallback::QtProgressCallback(QWidget* parent_widget, float show_delay)
|
||||||
: QObject(parent_widget), m_dialog(QString(), QString(), 0, 1, parent_widget)
|
: QObject(parent_widget), m_dialog(QString(), QString(), 0, 1, parent_widget), m_show_delay(show_delay)
|
||||||
{
|
{
|
||||||
m_dialog.setWindowTitle(tr("DuckStation"));
|
m_dialog.setWindowTitle(tr("DuckStation"));
|
||||||
m_dialog.setMinimumSize(QSize(500, 0));
|
m_dialog.setMinimumSize(QSize(500, 0));
|
||||||
m_dialog.setModal(parent_widget != nullptr);
|
m_dialog.setModal(parent_widget != nullptr);
|
||||||
m_dialog.show();
|
checkForDelayedShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtProgressCallback::~QtProgressCallback() = default;
|
QtProgressCallback::~QtProgressCallback() = default;
|
||||||
|
@ -37,20 +37,27 @@ void QtProgressCallback::SetTitle(const char* title)
|
||||||
void QtProgressCallback::SetStatusText(const char* text)
|
void QtProgressCallback::SetStatusText(const char* text)
|
||||||
{
|
{
|
||||||
BaseProgressCallback::SetStatusText(text);
|
BaseProgressCallback::SetStatusText(text);
|
||||||
|
checkForDelayedShow();
|
||||||
|
|
||||||
|
if (m_dialog.isVisible())
|
||||||
m_dialog.setLabelText(QString::fromUtf8(text));
|
m_dialog.setLabelText(QString::fromUtf8(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtProgressCallback::SetProgressRange(u32 range)
|
void QtProgressCallback::SetProgressRange(u32 range)
|
||||||
{
|
{
|
||||||
BaseProgressCallback::SetProgressRange(range);
|
BaseProgressCallback::SetProgressRange(range);
|
||||||
|
checkForDelayedShow();
|
||||||
|
|
||||||
|
if (m_dialog.isVisible())
|
||||||
m_dialog.setRange(0, m_progress_range);
|
m_dialog.setRange(0, m_progress_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtProgressCallback::SetProgressValue(u32 value)
|
void QtProgressCallback::SetProgressValue(u32 value)
|
||||||
{
|
{
|
||||||
BaseProgressCallback::SetProgressValue(value);
|
BaseProgressCallback::SetProgressValue(value);
|
||||||
|
checkForDelayedShow();
|
||||||
|
|
||||||
if (static_cast<u32>(m_dialog.value()) == m_progress_range)
|
if (!m_dialog.isVisible() || static_cast<u32>(m_dialog.value()) == m_progress_range)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_dialog.setValue(m_progress_value);
|
m_dialog.setValue(m_progress_value);
|
||||||
|
@ -92,3 +99,16 @@ void QtProgressCallback::ModalInformation(const char* message)
|
||||||
{
|
{
|
||||||
QMessageBox::information(&m_dialog, tr("Information"), QString::fromUtf8(message));
|
QMessageBox::information(&m_dialog, tr("Information"), QString::fromUtf8(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtProgressCallback::checkForDelayedShow()
|
||||||
|
{
|
||||||
|
if (m_dialog.isVisible())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_show_timer.GetTimeSeconds() >= m_show_delay)
|
||||||
|
{
|
||||||
|
m_dialog.setRange(0, m_progress_range);
|
||||||
|
m_dialog.setValue(m_progress_value);
|
||||||
|
m_dialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "common/progress_callback.h"
|
#include "common/progress_callback.h"
|
||||||
|
#include "common/timer.h"
|
||||||
#include <QtWidgets/QProgressDialog>
|
#include <QtWidgets/QProgressDialog>
|
||||||
|
|
||||||
class QtProgressCallback final : public QObject, public BaseProgressCallback
|
class QtProgressCallback final : public QObject, public BaseProgressCallback
|
||||||
|
@ -7,7 +8,7 @@ class QtProgressCallback final : public QObject, public BaseProgressCallback
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtProgressCallback(QWidget* parent_widget);
|
QtProgressCallback(QWidget* parent_widget, float show_delay = 0.0f);
|
||||||
~QtProgressCallback();
|
~QtProgressCallback();
|
||||||
|
|
||||||
bool IsCancelled() const override;
|
bool IsCancelled() const override;
|
||||||
|
@ -28,5 +29,9 @@ public:
|
||||||
void ModalInformation(const char* message) override;
|
void ModalInformation(const char* message) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void checkForDelayedShow();
|
||||||
|
|
||||||
QProgressDialog m_dialog;
|
QProgressDialog m_dialog;
|
||||||
|
Common::Timer m_show_timer;
|
||||||
|
float m_show_delay;
|
||||||
};
|
};
|
Loading…
Reference in a new issue