From ca2a7da3f6534515160d5fbf92f72d6ff2bce3e8 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 2 Sep 2019 09:35:11 -0400 Subject: moved workarounds to settings --- src/settings.cpp | 43 +++++++++++++++++++++++++++++++++++++++ src/settings.h | 8 ++++++++ src/settingsdialogworkarounds.cpp | 22 +++++++++++--------- 3 files changed, 63 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/settings.cpp b/src/settings.cpp index 072318a2..f6be8ba0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -421,16 +421,31 @@ bool Settings::hideUncheckedPlugins() const return m_Settings.value("Settings/hide_unchecked_plugins", false).toBool(); } +void Settings::setHideUncheckedPlugins(bool b) +{ + m_Settings.setValue("Settings/hide_unchecked_plugins", b); +} + bool Settings::forceEnableCoreFiles() const { return m_Settings.value("Settings/force_enable_core_files", true).toBool(); } +void Settings::setForceEnableCoreFiles(bool b) +{ + m_Settings.setValue("Settings/force_enable_core_files", b); +} + bool Settings::lockGUI() const { return m_Settings.value("Settings/lock_gui", true).toBool(); } +void Settings::setLockGUI(bool b) +{ + m_Settings.setValue("Settings/lock_gui", b); +} + bool Settings::automaticLoginEnabled() const { return m_Settings.value("Settings/nexus_login", false).toBool(); @@ -441,6 +456,15 @@ QString Settings::getSteamAppID() const return m_Settings.value("Settings/app_id", m_GamePlugin->steamAPPId()).toString(); } +void Settings::setSteamAppID(const QString& id) +{ + if (id.isEmpty()) { + m_Settings.remove("Settings/app_id"); + } else { + m_Settings.setValue("Settings/app_id", id); + } +} + bool Settings::usePrereleases() const { return m_Settings.value("Settings/use_prereleases", false).toBool(); @@ -782,6 +806,11 @@ QString Settings::executablesBlacklist() const ).toString(); } +void Settings::setExecutablesBlacklist(const QString& s) +{ + m_Settings.setValue("Settings/executable_blacklist", s); +} + void Settings::setSteamLogin(QString username, QString password) { if (username == "") { @@ -815,6 +844,10 @@ LoadMechanism::EMechanism Settings::getLoadMechanism() const } } +void Settings::setLoadMechanism(LoadMechanism::EMechanism m) +{ + m_Settings.setValue("Settings/load_mechanism", static_cast(m)); +} void Settings::setupLoadMechanism() { @@ -869,6 +902,11 @@ bool Settings::displayForeign() const return m_Settings.value("Settings/display_foreign", true).toBool(); } +void Settings::setDisplayForeign(bool b) +{ + m_Settings.setValue("Settings/display_foreign", b); +} + void Settings::setMotDHash(uint hash) { m_Settings.setValue("motd_hash", hash); @@ -884,6 +922,11 @@ bool Settings::archiveParsing() const return m_Settings.value("Settings/archive_parsing_experimental", false).toBool(); } +void Settings::setArchiveParsing(bool b) +{ + m_Settings.setValue("Settings/archive_parsing_experimental", b); +} + QString Settings::language() { QString result = m_Settings.value("Settings/language", "").toString(); diff --git a/src/settings.h b/src/settings.h index fc33e0de..09141274 100644 --- a/src/settings.h +++ b/src/settings.h @@ -203,16 +203,19 @@ public: * the virtual dat adirectory **/ bool hideUncheckedPlugins() const; + void setHideUncheckedPlugins(bool b); /** * @return true if files of the core game are forced-enabled so the user can't accidentally disable them */ bool forceEnableCoreFiles() const; + void setForceEnableCoreFiles(bool b); /** * @return true if the GUI should be locked when running executables */ bool lockGUI() const; + void setLockGUI(bool b); /** * the steam appid is assigned by the steam platform to each product sold there. @@ -221,6 +224,7 @@ public: * @return the steam appid for the game **/ QString getSteamAppID() const; + void setSteamAppID(const QString& id); QString getBaseDirectory() const; QString getDownloadDirectory(bool resolve = true) const; @@ -380,6 +384,7 @@ public: void setCrashDumpsMax(int n); QString executablesBlacklist() const; + void setExecutablesBlacklist(const QString& s); /** * @brief set the steam login information @@ -393,6 +398,7 @@ public: * @return the load mechanism to be used **/ LoadMechanism::EMechanism getLoadMechanism() const; + void setLoadMechanism(LoadMechanism::EMechanism m); /** * @brief activate the load mechanism selected by the user @@ -425,6 +431,7 @@ public: * @return true if the user wants to see non-official plugins installed outside MO in his mod list */ bool displayForeign() const; + void setDisplayForeign(bool b); /** * @brief sets the new motd hash @@ -435,6 +442,7 @@ public: * @return true if the user wants to have archives being parsed to show conflicts and contents */ bool archiveParsing() const; + void setArchiveParsing(bool b); /** * @return hash of the last displayed message of the day diff --git a/src/settingsdialogworkarounds.cpp b/src/settingsdialogworkarounds.cpp index 443ba54e..b06bd77c 100644 --- a/src/settingsdialogworkarounds.cpp +++ b/src/settingsdialogworkarounds.cpp @@ -36,18 +36,20 @@ WorkaroundsSettingsTab::WorkaroundsSettingsTab(Settings& s, SettingsDialog& d) void WorkaroundsSettingsTab::update() { if (ui->appIDEdit->text() != settings().gamePlugin()->steamAPPId()) { - qsettings().setValue("Settings/app_id", ui->appIDEdit->text()); + settings().setSteamAppID(ui->appIDEdit->text()); } else { - qsettings().remove("Settings/app_id"); + settings().setSteamAppID(""); } - qsettings().setValue("Settings/load_mechanism", ui->mechanismBox->itemData(ui->mechanismBox->currentIndex()).toInt()); - qsettings().setValue("Settings/hide_unchecked_plugins", ui->hideUncheckedBox->isChecked()); - qsettings().setValue("Settings/force_enable_core_files", ui->forceEnableBox->isChecked()); - qsettings().setValue("Settings/display_foreign", ui->displayForeignBox->isChecked()); - qsettings().setValue("Settings/lock_gui", ui->lockGUIBox->isChecked()); - qsettings().setValue("Settings/archive_parsing_experimental", ui->enableArchiveParsingBox->isChecked()); - - qsettings().setValue("Settings/executable_blacklist", getExecutableBlacklist()); + + settings().setLoadMechanism(static_cast( + ui->mechanismBox->itemData(ui->mechanismBox->currentIndex()).toInt())); + + settings().setHideUncheckedPlugins(ui->hideUncheckedBox->isChecked()); + settings().setForceEnableCoreFiles(ui->forceEnableBox->isChecked()); + settings().setDisplayForeign(ui->displayForeignBox->isChecked()); + settings().setLockGUI(ui->lockGUIBox->isChecked()); + settings().setArchiveParsing(ui->enableArchiveParsingBox->isChecked()); + settings().setExecutablesBlacklist(getExecutableBlacklist()); } void WorkaroundsSettingsTab::on_execBlacklistBtn_clicked() -- cgit v1.3.1