diff --git a/apps/launcher/advancedpage.cpp b/apps/launcher/advancedpage.cpp index bc0378314..3fe7c1f89 100644 --- a/apps/launcher/advancedpage.cpp +++ b/apps/launcher/advancedpage.cpp @@ -2,10 +2,8 @@ #include #include -#include #include #include -#include #include #include @@ -23,13 +21,9 @@ Launcher::AdvancedPage::AdvancedPage(Files::ConfigurationManager &cfg, loadSettings(); } -void Launcher::AdvancedPage::loadCellsForAutocomplete(QStringList filePaths) { - CellNameLoader cellNameLoader; - QStringList cellNamesList = QStringList::fromSet(cellNameLoader.getCellNames(filePaths)); - std::sort(cellNamesList.begin(), cellNamesList.end()); - +void Launcher::AdvancedPage::loadCellsForAutocomplete(QStringList cellNames) { // Set up an auto-completer for the "Start default character at" field - auto *completer = new QCompleter(cellNamesList); + auto *completer = new QCompleter(cellNames); completer->setCompletionMode(QCompleter::PopupCompletion); completer->setCaseSensitivity(Qt::CaseSensitivity::CaseInsensitive); startDefaultCharacterAtField->setCompleter(completer); @@ -165,10 +159,7 @@ void Launcher::AdvancedPage::saveSettingBool(QCheckBox *checkbox, const std::str mEngineSettings.setBool(setting, group, cValue); } -void Launcher::AdvancedPage::slotSelectedDataFilesChanged(QStringList selectedFiles) +void Launcher::AdvancedPage::slotLoadedCellsChanged(QStringList cellNames) { - // Loading cells for core Morrowind + Expansions takes about 0.2 seconds, which is enough to cause a - // barely perceptible UI lag. Splitting into its own thread to alleviate that. - std::thread loadCellsThread(&AdvancedPage::loadCellsForAutocomplete, this, selectedFiles); - loadCellsThread.join(); + loadCellsForAutocomplete(cellNames); } \ No newline at end of file diff --git a/apps/launcher/advancedpage.hpp b/apps/launcher/advancedpage.hpp index c40ae2da1..82b9c3b65 100644 --- a/apps/launcher/advancedpage.hpp +++ b/apps/launcher/advancedpage.hpp @@ -30,7 +30,7 @@ namespace Launcher void loadCellsForAutocomplete(QStringList filePaths); public slots: - void slotSelectedDataFilesChanged(QStringList selectedFiles); + void slotLoadedCellsChanged(QStringList cellNames); private slots: void on_skipMenuCheckBox_stateChanged(int state); diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 25a09ab1b..1f46c7156 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -7,7 +7,9 @@ #include #include #include +#include +#include #include #include @@ -330,6 +332,17 @@ void Launcher::DataFilesPage::slotAddonDataChanged() QStringList selectedFiles = selectedFilePaths(); if (previousSelectedFiles != selectedFiles) { previousSelectedFiles = selectedFiles; - emit signalSelectedFilesChanged(selectedFiles); + // Loading cells for core Morrowind + Expansions takes about 0.2 seconds, which is enough to cause a + // barely perceptible UI lag. Splitting into its own thread to alleviate that. + std::thread loadCellsThread(&DataFilesPage::reloadCells, this, selectedFiles); + loadCellsThread.join(); } +} + +void Launcher::DataFilesPage::reloadCells(QStringList selectedFiles) +{ + CellNameLoader cellNameLoader; + QStringList cellNamesList = QStringList::fromSet(cellNameLoader.getCellNames(selectedFiles)); + std::sort(cellNamesList.begin(), cellNamesList.end()); + emit signalSelectedFilesChanged(cellNamesList); } \ No newline at end of file diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 8893412be..d871eeee0 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -96,6 +96,7 @@ namespace Launcher void addProfile (const QString &profile, bool setAsCurrent); void checkForDefaultProfile(); void populateFileViews(const QString& contentModelName); + void reloadCells(QStringList selectedFiles); class PathIterator { diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index f3afb2732..79f3e5c67 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -142,7 +142,7 @@ void Launcher::MainDialog::createPages() connect(mPlayPage, SIGNAL(signalProfileChanged(int)), mDataFilesPage, SLOT(slotProfileChanged(int))); connect(mDataFilesPage, SIGNAL(signalProfileChanged(int)), mPlayPage, SLOT(setProfilesIndex(int))); - connect(mDataFilesPage, SIGNAL(signalSelectedFilesChanged(QStringList)), mAdvancedPage, SLOT(slotSelectedDataFilesChanged(QStringList))); + connect(mDataFilesPage, SIGNAL(signalSelectedFilesChanged(QStringList)), mAdvancedPage, SLOT(slotLoadedCellsChanged(QStringList))); }