From 9d9cabf40d1b6fd73c90db416de8c4b9bf980b87 Mon Sep 17 00:00:00 2001 From: dteviot Date: Fri, 6 Feb 2015 12:24:06 +1300 Subject: [PATCH 1/2] Fix: Importer creates a single Content List (Fixes #2345) --- apps/launcher/datafilespage.cpp | 9 ++++++--- apps/launcher/datafilespage.hpp | 4 ++++ apps/launcher/settingspage.cpp | 22 +++++++++++++++++----- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index ff1364b08..7861894b0 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -20,6 +20,9 @@ #include "utils/textinputdialog.hpp" #include "utils/profilescombobox.hpp" + +const char *Launcher::DataFilesPage::mDefaultContentListName = "Default"; + Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config::GameSettings &gameSettings, Config::LauncherSettings &launcherSettings, QWidget *parent) : mCfgMgr(cfg) , mGameSettings(gameSettings) @@ -48,9 +51,9 @@ void Launcher::DataFilesPage::buildView() ui.deleteProfileButton->setToolTip ("Delete an existing Content List"); //combo box - ui.profilesComboBox->addItem ("Default"); + ui.profilesComboBox->addItem(mDefaultContentListName); ui.profilesComboBox->setPlaceholderText (QString("Select a Content List...")); - ui.profilesComboBox->setCurrentIndex(ui.profilesComboBox->findText(QLatin1String("Default"))); + ui.profilesComboBox->setCurrentIndex(ui.profilesComboBox->findText(QLatin1String(mDefaultContentListName))); // Add the actions to the toolbuttons ui.newProfileButton->setDefaultAction (ui.newProfileAction); @@ -284,7 +287,7 @@ void Launcher::DataFilesPage::updateOkButton(const QString &text) void Launcher::DataFilesPage::checkForDefaultProfile() { //don't allow deleting "Default" profile - bool success = (ui.profilesComboBox->currentText() != "Default"); + bool success = (ui.profilesComboBox->currentText() != mDefaultContentListName); ui.deleteProfileAction->setEnabled (success); ui.profilesComboBox->setEditEnabled (success); diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 73b840c5c..1e0fc8e7a 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -58,6 +58,10 @@ namespace Launcher void on_newProfileAction_triggered(); void on_deleteProfileAction_triggered(); + public: + /// Content List that is aways present + const static char *mDefaultContentListName; + private: TextInputDialog *mProfileDialog; diff --git a/apps/launcher/settingspage.cpp b/apps/launcher/settingspage.cpp index ace8f4310..88c60766b 100644 --- a/apps/launcher/settingspage.cpp +++ b/apps/launcher/settingspage.cpp @@ -11,6 +11,7 @@ #include #include "utils/textinputdialog.hpp" +#include "datafilespage.hpp" using namespace Process; @@ -198,22 +199,33 @@ void Launcher::SettingsPage::importerFinished(int exitCode, QProcess::ExitStatus if (exitCode != 0 || exitStatus == QProcess::CrashExit) return; - // Re-read the settings in their current state + // Importer may have changed settings, so refresh mMain->reloadSettings(); // Import selected data files from openmw.cfg if (addonsCheckBox->isChecked()) { + // Because we've reloaded settings, the current content list matches content in OpenMW.cfg + QString oldContentListName = mLauncherSettings.getCurrentContentListName(); if (mProfileDialog->exec() == QDialog::Accepted) { - const QString profile(mProfileDialog->lineEdit()->text()); + // remove the current content list to prevent duplication + //... except, not allowed to delete the Default content list + if (oldContentListName.compare(DataFilesPage::mDefaultContentListName) != 0) + { + mLauncherSettings.removeContentList(oldContentListName); + } + + const QString newContentListName(mProfileDialog->lineEdit()->text()); const QStringList files(mGameSettings.getContentList()); - mLauncherSettings.setCurrentContentListName(profile); - mLauncherSettings.setContentList(profile, files); + mLauncherSettings.setCurrentContentListName(newContentListName); + mLauncherSettings.setContentList(newContentListName, files); + + // Make DataFiles Page load the new content list. + mMain->reloadSettings(); } } - mMain->reloadSettings(); importerButton->setEnabled(true); } From cac250a90d213d33e0560b0b49da1b17c790bba0 Mon Sep 17 00:00:00 2001 From: dteviot Date: Fri, 6 Feb 2015 12:45:15 +1300 Subject: [PATCH 2/2] Fixed typo in comment. --- apps/launcher/datafilespage.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 1e0fc8e7a..d25d20fc9 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -59,7 +59,7 @@ namespace Launcher void on_deleteProfileAction_triggered(); public: - /// Content List that is aways present + /// Content List that is always present const static char *mDefaultContentListName; private: