mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Changing where we are loading cells to prevent Qt access issue
This commit is contained in:
parent
78234e9468
commit
26dfef7970
5 changed files with 21 additions and 16 deletions
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
#include <components/config/gamesettings.hpp>
|
#include <components/config/gamesettings.hpp>
|
||||||
#include <components/config/launchersettings.hpp>
|
#include <components/config/launchersettings.hpp>
|
||||||
#include <apps/launcher/utils/cellnameloader.hpp>
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <thread>
|
|
||||||
#include <components/contentselector/view/contentselector.hpp>
|
#include <components/contentselector/view/contentselector.hpp>
|
||||||
#include <components/contentselector/model/esmfile.hpp>
|
#include <components/contentselector/model/esmfile.hpp>
|
||||||
|
|
||||||
|
@ -23,13 +21,9 @@ Launcher::AdvancedPage::AdvancedPage(Files::ConfigurationManager &cfg,
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::AdvancedPage::loadCellsForAutocomplete(QStringList filePaths) {
|
void Launcher::AdvancedPage::loadCellsForAutocomplete(QStringList cellNames) {
|
||||||
CellNameLoader cellNameLoader;
|
|
||||||
QStringList cellNamesList = QStringList::fromSet(cellNameLoader.getCellNames(filePaths));
|
|
||||||
std::sort(cellNamesList.begin(), cellNamesList.end());
|
|
||||||
|
|
||||||
// Set up an auto-completer for the "Start default character at" field
|
// 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->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
completer->setCaseSensitivity(Qt::CaseSensitivity::CaseInsensitive);
|
completer->setCaseSensitivity(Qt::CaseSensitivity::CaseInsensitive);
|
||||||
startDefaultCharacterAtField->setCompleter(completer);
|
startDefaultCharacterAtField->setCompleter(completer);
|
||||||
|
@ -165,10 +159,7 @@ void Launcher::AdvancedPage::saveSettingBool(QCheckBox *checkbox, const std::str
|
||||||
mEngineSettings.setBool(setting, group, cValue);
|
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
|
loadCellsForAutocomplete(cellNames);
|
||||||
// barely perceptible UI lag. Splitting into its own thread to alleviate that.
|
|
||||||
std::thread loadCellsThread(&AdvancedPage::loadCellsForAutocomplete, this, selectedFiles);
|
|
||||||
loadCellsThread.join();
|
|
||||||
}
|
}
|
|
@ -30,7 +30,7 @@ namespace Launcher
|
||||||
void loadCellsForAutocomplete(QStringList filePaths);
|
void loadCellsForAutocomplete(QStringList filePaths);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotSelectedDataFilesChanged(QStringList selectedFiles);
|
void slotLoadedCellsChanged(QStringList cellNames);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_skipMenuCheckBox_stateChanged(int state);
|
void on_skipMenuCheckBox_stateChanged(int state);
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
#include <apps/launcher/utils/cellnameloader.hpp>
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
#include <components/contentselector/model/esmfile.hpp>
|
#include <components/contentselector/model/esmfile.hpp>
|
||||||
|
@ -330,6 +332,17 @@ void Launcher::DataFilesPage::slotAddonDataChanged()
|
||||||
QStringList selectedFiles = selectedFilePaths();
|
QStringList selectedFiles = selectedFilePaths();
|
||||||
if (previousSelectedFiles != selectedFiles) {
|
if (previousSelectedFiles != selectedFiles) {
|
||||||
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);
|
||||||
|
}
|
|
@ -96,6 +96,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 reloadCells(QStringList selectedFiles);
|
||||||
|
|
||||||
class PathIterator
|
class PathIterator
|
||||||
{
|
{
|
||||||
|
|
|
@ -142,7 +142,7 @@ void Launcher::MainDialog::createPages()
|
||||||
|
|
||||||
connect(mPlayPage, SIGNAL(signalProfileChanged(int)), mDataFilesPage, SLOT(slotProfileChanged(int)));
|
connect(mPlayPage, SIGNAL(signalProfileChanged(int)), mDataFilesPage, SLOT(slotProfileChanged(int)));
|
||||||
connect(mDataFilesPage, SIGNAL(signalProfileChanged(int)), mPlayPage, SLOT(setProfilesIndex(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)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue