1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-20 06:41:33 +00:00

Launcher: Reload cells after a short delay (#8478)

This commit is contained in:
Alexei Kotov 2025-05-07 11:24:53 +03:00
parent 2342dbe0f5
commit e8b0ee874f
2 changed files with 16 additions and 1 deletions

View file

@ -10,6 +10,7 @@
#include <QPair> #include <QPair>
#include <QProgressDialog> #include <QProgressDialog>
#include <QPushButton> #include <QPushButton>
#include <QTimer>
#include <algorithm> #include <algorithm>
#include <mutex> #include <mutex>
@ -202,8 +203,14 @@ Launcher::DataFilesPage::DataFilesPage(const Files::ConfigurationManager& cfg, C
// the addons and don't want to get signals of the system doing it during startup. // the addons and don't want to get signals of the system doing it during startup.
connect(mSelector, &ContentSelectorView::ContentSelector::signalAddonDataChanged, this, connect(mSelector, &ContentSelectorView::ContentSelector::signalAddonDataChanged, this,
&DataFilesPage::slotAddonDataChanged); &DataFilesPage::slotAddonDataChanged);
mReloadCellsTimer = new QTimer(this);
mReloadCellsTimer->setSingleShot(true);
mReloadCellsTimer->setInterval(200);
connect(mReloadCellsTimer, &QTimer::timeout, this, &DataFilesPage::onReloadCellsTimerTimeout);
// Call manually to indicate all changes to addon data during startup. // Call manually to indicate all changes to addon data during startup.
slotAddonDataChanged(); onReloadCellsTimerTimeout();
} }
Launcher::DataFilesPage::~DataFilesPage() Launcher::DataFilesPage::~DataFilesPage()
@ -1000,6 +1007,11 @@ bool Launcher::DataFilesPage::showDeleteMessageBox(const QString& text)
} }
void Launcher::DataFilesPage::slotAddonDataChanged() void Launcher::DataFilesPage::slotAddonDataChanged()
{
mReloadCellsTimer->start();
}
void Launcher::DataFilesPage::onReloadCellsTimerTimeout()
{ {
const ContentSelectorModel::ContentFileList items = mSelector->selectedFiles(); const ContentSelectorModel::ContentFileList items = mSelector->selectedFiles();
QStringList selectedFiles; QStringList selectedFiles;

View file

@ -17,6 +17,7 @@
class QSortFilterProxyModel; class QSortFilterProxyModel;
class QAbstractItemModel; class QAbstractItemModel;
class QMenu; class QMenu;
class QTimer;
namespace Files namespace Files
{ {
@ -137,6 +138,7 @@ namespace Launcher
std::mutex mReloadCellsMutex; std::mutex mReloadCellsMutex;
std::condition_variable mStartReloadCells; std::condition_variable mStartReloadCells;
std::thread mReloadCellsThread; std::thread mReloadCellsThread;
QTimer* mReloadCellsTimer;
void addArchive(const QString& name, Qt::CheckState selected, int row = -1); void addArchive(const QString& name, Qt::CheckState selected, int row = -1);
void addArchivesFromDir(const QString& dir); void addArchivesFromDir(const QString& dir);
@ -151,6 +153,7 @@ namespace Launcher
void addProfile(const QString& profile, bool setAsCurrent); void addProfile(const QString& profile, bool setAsCurrent);
void checkForDefaultProfile(); void checkForDefaultProfile();
void populateFileViews(const QString& contentModelName); void populateFileViews(const QString& contentModelName);
void onReloadCellsTimerTimeout();
void reloadCells(); void reloadCells();
void refreshDataFilesView(); void refreshDataFilesView();
void updateNavMeshProgress(int minDataSize); void updateNavMeshProgress(int minDataSize);