summaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2015-06-30 19:57:59 +0200
committerTannin <devnull@localhost>2015-06-30 19:57:59 +0200
commit7853ba5f9a246b56e4dd0abfcb55a7e81e99ad9f (patch)
tree1d608f66f47ac8220d57e325f863d9df09cf300a /src/settings.cpp
parent90dcc8171549d62007a1f5eb910688de61553ab9 (diff)
parentca591dbd230bf49abad63bb13a30d04cc4725ff8 (diff)
Merge
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp487
1 files changed, 266 insertions, 221 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 88d97006..4c2a34c8 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -36,6 +36,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QMessageBox>
#include <QDesktopServices>
+#include <memory>
+
using namespace MOBase;
using namespace MOShared;
@@ -140,7 +142,7 @@ void Settings::registerPlugin(IPlugin *plugin)
}
}
-QString Settings::obfuscate(const QString &password) const
+QString Settings::obfuscate(const QString &password)
{
QByteArray temp = password.toUtf8();
@@ -151,7 +153,7 @@ QString Settings::obfuscate(const QString &password) const
return buffer.toBase64();
}
-QString Settings::deObfuscate(const QString &password) const
+QString Settings::deObfuscate(const QString &password)
{
QByteArray temp(QByteArray::fromBase64(password.toUtf8()));
@@ -328,12 +330,12 @@ void Settings::setupLoadMechanism()
}
-bool Settings::useProxy()
+bool Settings::useProxy() const
{
return m_Settings.value("Settings/use_proxy", false).toBool();
}
-bool Settings::displayForeign()
+bool Settings::displayForeign() const
{
return m_Settings.value("Settings/display_foreign", true).toBool();
}
@@ -539,141 +541,158 @@ void Settings::query(QWidget *parent)
connect(&dialog, SIGNAL(resetDialogs()), this, SLOT(resetDialogs()));
- // General Page
- QComboBox *languageBox = dialog.findChild<QComboBox*>("languageBox");
- QComboBox *styleBox = dialog.findChild<QComboBox*>("styleBox");
- QComboBox *logLevelBox = dialog.findChild<QComboBox*>("logLevelBox");
- QCheckBox *compactBox = dialog.findChild<QCheckBox*>("compactBox");
- QCheckBox *showMetaBox = dialog.findChild<QCheckBox*>("showMetaBox");
+ std::vector<std::unique_ptr<SettingsTab>> tabs;
- QLineEdit *downloadDirEdit = dialog.findChild<QLineEdit*>("downloadDirEdit");
- QLineEdit *modDirEdit = dialog.findChild<QLineEdit*>("modDirEdit");
- QLineEdit *cacheDirEdit = dialog.findChild<QLineEdit*>("cacheDirEdit");
+ tabs.push_back(std::unique_ptr<SettingsTab>(new GeneralTab(this, dialog)));
+ tabs.push_back(std::unique_ptr<SettingsTab>(new NexusTab(this, dialog)));
+ tabs.push_back(std::unique_ptr<SettingsTab>(new SteamTab(this, dialog)));
+ tabs.push_back(std::unique_ptr<SettingsTab>(new PluginsTab(this, dialog)));
+ tabs.push_back(std::unique_ptr<SettingsTab>(new WorkaroundsTab(this, dialog)));
- // nexus page
- QCheckBox *loginCheckBox = dialog.findChild<QCheckBox*>("loginCheckBox");
- QLineEdit *usernameEdit = dialog.findChild<QLineEdit*>("usernameEdit");
- QLineEdit *passwordEdit = dialog.findChild<QLineEdit*>("passwordEdit");
- QCheckBox *offlineBox = dialog.findChild<QCheckBox*>("offlineBox");
- QCheckBox *proxyBox = dialog.findChild<QCheckBox*>("proxyBox");
+ if (dialog.exec() == QDialog::Accepted) {
+ // transfer modified settings to configuration file
+ for (std::unique_ptr<SettingsTab> const &tab: tabs) {
+ tab->update();
+ }
+ }
+}
- QListWidget *knownServersList = dialog.findChild<QListWidget*>("knownServersList");
- QListWidget *preferredServersList = dialog.findChild<QListWidget*>("preferredServersList");
+Settings::SettingsTab::SettingsTab(Settings *m_parent, SettingsDialog &m_dialog) :
+ m_parent(m_parent),
+ m_Settings(m_parent->m_Settings),
+ m_dialog(m_dialog)
+{}
- // plugis page
- QListWidget *pluginsList = dialog.findChild<QListWidget*>("pluginsList");
- QListWidget *pluginBlacklistList = dialog.findChild<QListWidget*>("pluginBlacklist");
+Settings::SettingsTab::~SettingsTab()
+{}
- // workarounds page
- QCheckBox *forceEnableBox = dialog.findChild<QCheckBox*>("forceEnableBox");
- QComboBox *mechanismBox = dialog.findChild<QComboBox*>("mechanismBox");
- QLineEdit *appIDEdit = dialog.findChild<QLineEdit*>("appIDEdit");
- QLineEdit *nmmVersionEdit = dialog.findChild<QLineEdit*>("nmmVersionEdit");
- QCheckBox *hideUncheckedBox = dialog.findChild<QCheckBox*>("hideUncheckedBox");
- QCheckBox *displayForeignBox = dialog.findChild<QCheckBox*>("displayForeignBox");
+Settings::GeneralTab::GeneralTab(Settings *m_parent, SettingsDialog &m_dialog) :
+ Settings::SettingsTab(m_parent, m_dialog),
+ m_languageBox(m_dialog.findChild<QComboBox*>("languageBox")),
+ m_styleBox(m_dialog.findChild<QComboBox*>("styleBox")),
+ m_logLevelBox(m_dialog.findChild<QComboBox*>("logLevelBox")),
+ m_downloadDirEdit(m_dialog.findChild<QLineEdit*>("downloadDirEdit")),
+ m_modDirEdit(m_dialog.findChild<QLineEdit*>("modDirEdit")),
+ m_cacheDirEdit(m_dialog.findChild<QLineEdit*>("cacheDirEdit")),
+ m_compactBox(m_dialog.findChild<QCheckBox*>("compactBox")),
+ m_showMetaBox(m_dialog.findChild<QCheckBox*>("showMetaBox"))
+ {
+ //FIXME I think 'addLanguages' lives in here not in parent
+ m_parent->addLanguages(m_languageBox);
+ {
+ QString languageCode = m_parent->language();
+ int currentID = m_languageBox->findData(languageCode);
+ // I made a mess. :( Most languages are stored with only the iso country code (2 characters like "de") but chinese
+ // with the exact language variant (zh_TW) so I have to search for both variants
+ if (currentID == -1) {
+ currentID = m_languageBox->findData(languageCode.mid(0, 2));
+ }
+ if (currentID != -1) {
+ m_languageBox->setCurrentIndex(currentID);
+ }
+ }
- // steam login page
- QLineEdit *steamUserEdit = dialog.findChild<QLineEdit*>("steamUserEdit");
- QLineEdit *steamPassEdit = dialog.findChild<QLineEdit*>("steamPassEdit");
+ //FIXME I think addStyles lives in here not in parent
+ m_parent->addStyles(m_styleBox);
+ {
+ int currentID = m_styleBox->findData(m_Settings.value("Settings/style", "").toString());
+ if (currentID != -1) {
+ m_styleBox->setCurrentIndex(currentID);
+ }
+ }
- //
- // set up current settings
- //
- LoadMechanism::EMechanism mechanismID = getLoadMechanism();
- int index = 0;
+ m_logLevelBox->setCurrentIndex(m_parent->logLevel());
+ m_downloadDirEdit->setText(m_parent->getDownloadDirectory());
+ m_modDirEdit->setText(m_parent->getModDirectory());
+ m_cacheDirEdit->setText(m_parent->getCacheDirectory());
+ m_compactBox->setChecked(m_parent->compactDownloads());
+ m_showMetaBox->setChecked(m_parent->metaDownloads());
+}
- if (m_LoadMechanism.isDirectLoadingSupported()) {
- mechanismBox->addItem(QObject::tr("Mod Organizer"), LoadMechanism::LOAD_MODORGANIZER);
- if (mechanismID == LoadMechanism::LOAD_MODORGANIZER) {
- index = mechanismBox->count() - 1;
- }
+void Settings::GeneralTab::update()
+{
+ QString oldLanguage = m_Settings.value("Settings/language", "en_US").toString();
+ QString newLanguage = m_languageBox->itemData(m_languageBox->currentIndex()).toString();
+ if (newLanguage != oldLanguage) {
+ m_Settings.setValue("Settings/language", newLanguage);
+ emit m_parent->languageChanged(newLanguage);
}
- if (m_LoadMechanism.isScriptExtenderSupported()) {
- mechanismBox->addItem(QObject::tr("Script Extender"), LoadMechanism::LOAD_SCRIPTEXTENDER);
- if (mechanismID == LoadMechanism::LOAD_SCRIPTEXTENDER) {
- index = mechanismBox->count() - 1;
- }
+ QString oldStyle = m_Settings.value("Settings/style", "").toString();
+ QString newStyle = m_styleBox->itemData(m_styleBox->currentIndex()).toString();
+ if (oldStyle != newStyle) {
+ m_Settings.setValue("Settings/style", newStyle);
+ emit m_parent->styleChanged(newStyle);
}
- if (m_LoadMechanism.isProxyDLLSupported()) {
- mechanismBox->addItem(QObject::tr("Proxy DLL"), LoadMechanism::LOAD_PROXYDLL);
- if (mechanismID == LoadMechanism::LOAD_PROXYDLL) {
- index = mechanismBox->count() - 1;
- }
- }
+ m_Settings.setValue("Settings/log_level", m_logLevelBox->currentIndex());
- mechanismBox->setCurrentIndex(index);
+ { // advanced settings
+ if ((QDir::fromNativeSeparators(m_modDirEdit->text()) != QDir::fromNativeSeparators(m_parent->getModDirectory())) &&
+ (QMessageBox::question(nullptr, tr("Confirm"), tr("Changing the mod directory affects all your profiles! "
+ "Mods not present (or named differently) in the new location will be disabled in all profiles. "
+ "There is no way to undo this unless you backed up your profiles manually. Proceed?"),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)) {
+ m_modDirEdit->setText(m_parent->getModDirectory());
+ }
- {
- addLanguages(languageBox);
- QString languageCode = language();
- int currentID = languageBox->findData(languageCode);
- // I made a mess. :( Most languages are stored with only the iso country code (2 characters like "de") but chinese
- // with the exact language variant (zh_TW) so I have to search for both variants
- if (currentID == -1) {
- currentID = languageBox->findData(languageCode.mid(0, 2));
+ if (!QDir(m_downloadDirEdit->text()).exists()) {
+ QDir().mkpath(m_downloadDirEdit->text());
}
- if (currentID != -1) {
- languageBox->setCurrentIndex(currentID);
+ if (QFileInfo(m_downloadDirEdit->text()) !=
+ QFileInfo(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::downloadPath()))) {
+ m_Settings.setValue("Settings/download_directory", QDir::toNativeSeparators(m_downloadDirEdit->text()));
+ } else {
+ m_Settings.remove("Settings/download_directory");
}
- }
- {
- addStyles(styleBox);
- int currentID = styleBox->findData(m_Settings.value("Settings/style", "").toString());
- if (currentID != -1) {
- styleBox->setCurrentIndex(currentID);
+ if (!QDir(m_modDirEdit->text()).exists()) {
+ QDir().mkpath(m_modDirEdit->text());
+ }
+ if (QFileInfo(m_modDirEdit->text()) !=
+ QFileInfo(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::modsPath()))) {
+ m_Settings.setValue("Settings/mod_directory", QDir::toNativeSeparators(m_modDirEdit->text()));
+ } else {
+ m_Settings.remove("Settings/mod_directory");
}
- }
-
- compactBox->setChecked(compactDownloads());
- showMetaBox->setChecked(metaDownloads());
-
- hideUncheckedBox->setChecked(hideUncheckedPlugins());
- displayForeignBox->setChecked(displayForeign());
- forceEnableBox->setChecked(forceEnableCoreFiles());
-
- appIDEdit->setText(getSteamAppID());
-
- if (automaticLoginEnabled()) {
- loginCheckBox->setChecked(true);
- usernameEdit->setText(m_Settings.value("Settings/nexus_username", "").toString());
- passwordEdit->setText(deObfuscate(m_Settings.value("Settings/nexus_password", "").toString()));
- }
- if (m_Settings.contains("Settings/steam_username")) {
- steamUserEdit->setText(m_Settings.value("Settings/steam_username", "").toString());
- if (m_Settings.contains("Settings/steam_password")) {
- steamPassEdit->setText(deObfuscate(m_Settings.value("Settings/steam_password", "").toString()));
+ if (!QDir(m_cacheDirEdit->text()).exists()) {
+ QDir().mkpath(m_cacheDirEdit->text());
+ }
+ if (QFileInfo(m_cacheDirEdit->text()) !=
+ QFileInfo(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::cachePath()))) {
+ m_Settings.setValue("Settings/cache_directory", QDir::toNativeSeparators(m_cacheDirEdit->text()));
+ } else {
+ m_Settings.remove("Settings/cache_directory");
}
}
- downloadDirEdit->setText(getDownloadDirectory());
- modDirEdit->setText(getModDirectory());
- cacheDirEdit->setText(getCacheDirectory());
- offlineBox->setChecked(offlineMode());
- proxyBox->setChecked(useProxy());
- nmmVersionEdit->setText(getNMMVersion());
- logLevelBox->setCurrentIndex(logLevel());
+ m_Settings.setValue("Settings/compact_downloads", m_compactBox->isChecked());
+ m_Settings.setValue("Settings/meta_downloads", m_showMetaBox->isChecked());
+}
- // display plugin settings
- foreach (IPlugin *plugin, m_Plugins) {
- QListWidgetItem *listItem = new QListWidgetItem(plugin->name(), pluginsList);
- listItem->setData(Qt::UserRole, QVariant::fromValue((void*)plugin));
- listItem->setData(Qt::UserRole + 1, m_PluginSettings[plugin->name()]);
- listItem->setData(Qt::UserRole + 2, m_PluginDescriptions[plugin->name()]);
- pluginsList->addItem(listItem);
+Settings::NexusTab::NexusTab(Settings *m_parent, SettingsDialog &m_dialog) :
+ Settings::SettingsTab(m_parent, m_dialog),
+ m_loginCheckBox(m_dialog.findChild<QCheckBox*>("loginCheckBox")),
+ m_usernameEdit(m_dialog.findChild<QLineEdit*>("usernameEdit")),
+ m_passwordEdit(m_dialog.findChild<QLineEdit*>("passwordEdit")),
+ m_offlineBox(m_dialog.findChild<QCheckBox*>("offlineBox")),
+ m_proxyBox(m_dialog.findChild<QCheckBox*>("proxyBox")),
+ m_knownServersList(m_dialog.findChild<QListWidget*>("knownServersList")),
+ m_preferredServersList(m_dialog.findChild<QListWidget*>("preferredServersList"))
+{
+ if (m_parent->automaticLoginEnabled()) {
+ m_loginCheckBox->setChecked(true);
+ m_usernameEdit->setText(m_Settings.value("Settings/nexus_username", "").toString());
+ m_passwordEdit->setText(deObfuscate(m_Settings.value("Settings/nexus_password", "").toString()));
}
- // display plugin blacklist
- foreach (const QString &pluginName, m_PluginBlacklist) {
- pluginBlacklistList->addItem(pluginName);
- }
+ m_offlineBox->setChecked(m_parent->offlineMode());
+ m_proxyBox->setChecked(m_parent->useProxy());
// display server preferences
m_Settings.beginGroup("Servers");
- foreach (const QString &key, m_Settings.childKeys()) {
+ for (const QString &key : m_Settings.childKeys()) {
QVariantMap val = m_Settings.value(key).toMap();
QString type = val["premium"].toBool() ? "(premium)" : "(free)";
@@ -688,137 +707,163 @@ void Settings::query(QWidget *parent)
newItem->setData(Qt::UserRole, key);
newItem->setData(Qt::UserRole + 1, val["preferred"].toInt());
if (val["preferred"].toInt() > 0) {
- preferredServersList->addItem(newItem);
+ m_preferredServersList->addItem(newItem);
} else {
- knownServersList->addItem(newItem);
+ m_knownServersList->addItem(newItem);
}
- preferredServersList->sortItems(Qt::DescendingOrder);
+ m_preferredServersList->sortItems(Qt::DescendingOrder);
}
m_Settings.endGroup();
+}
- if (dialog.exec() == QDialog::Accepted) {
- //
- // transfer modified settings to configuration file
- //
-
- m_Settings.setValue("Settings/hide_unchecked_plugins", hideUncheckedBox->checkState() ? true : false);
- m_Settings.setValue("Settings/force_enable_core_files", forceEnableBox->checkState() ? true : false);
- m_Settings.setValue("Settings/compact_downloads", compactBox->isChecked());
- m_Settings.setValue("Settings/meta_downloads", showMetaBox->isChecked());
- m_Settings.setValue("Settings/load_mechanism", mechanismBox->itemData(mechanismBox->currentIndex()).toInt());
-
+void Settings::NexusTab::update()
+{
+ if (m_loginCheckBox->isChecked()) {
+ m_Settings.setValue("Settings/nexus_login", true);
+ m_Settings.setValue("Settings/nexus_username", m_usernameEdit->text());
+ m_Settings.setValue("Settings/nexus_password", obfuscate(m_passwordEdit->text()));
+ } else {
+ m_Settings.setValue("Settings/nexus_login", false);
+ m_Settings.remove("Settings/nexus_username");
+ m_Settings.remove("Settings/nexus_password");
+ }
+ m_Settings.setValue("Settings/offline_mode", m_offlineBox->isChecked());
+ m_Settings.setValue("Settings/use_proxy", m_proxyBox->isChecked());
- { // advanced settings
- if ((QDir::fromNativeSeparators(modDirEdit->text()) != QDir::fromNativeSeparators(getModDirectory())) &&
- (QMessageBox::question(nullptr, tr("Confirm"), tr("Changing the mod directory affects all your profiles! "
- "Mods not present (or named differently) in the new location will be disabled in all profiles. "
- "There is no way to undo this unless you backed up your profiles manually. Proceed?"),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)) {
- modDirEdit->setText(getModDirectory());
- }
+ // store server preference
+ m_Settings.beginGroup("Servers");
+ for (int i = 0; i < m_knownServersList->count(); ++i) {
+ QString key = m_knownServersList->item(i)->data(Qt::UserRole).toString();
+ QVariantMap val = m_Settings.value(key).toMap();
+ val["preferred"] = 0;
+ m_Settings.setValue(key, val);
+ }
+ int count = m_preferredServersList->count();
+ for (int i = 0; i < count; ++i) {
+ QString key = m_preferredServersList->item(i)->data(Qt::UserRole).toString();
+ QVariantMap val = m_Settings.value(key).toMap();
+ val["preferred"] = count - i;
+ m_Settings.setValue(key, val);
+ }
+ m_Settings.endGroup();
+}
- if (!QDir(downloadDirEdit->text()).exists()) {
- QDir().mkpath(downloadDirEdit->text());
- }
- if (!QDir(cacheDirEdit->text()).exists()) {
- QDir().mkpath(cacheDirEdit->text());
- }
- if (!QDir(modDirEdit->text()).exists()) {
- QDir().mkpath(modDirEdit->text());
- }
- if (QFileInfo(downloadDirEdit->text()) !=
- QFileInfo(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::downloadPath()))) {
- m_Settings.setValue("Settings/download_directory", QDir::toNativeSeparators(downloadDirEdit->text()));
- } else {
- m_Settings.remove("Settings/download_directory");
- }
- if (QFileInfo(cacheDirEdit->text()) !=
- QFileInfo(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::cachePath()))) {
- m_Settings.setValue("Settings/cache_directory", QDir::toNativeSeparators(cacheDirEdit->text()));
- } else {
- m_Settings.remove("Settings/cache_directory");
- }
- if (QFileInfo(modDirEdit->text()) !=
- QFileInfo(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::modsPath()))) {
- m_Settings.setValue("Settings/mod_directory", QDir::toNativeSeparators(modDirEdit->text()));
- } else {
- m_Settings.remove("Settings/mod_directory");
- }
+Settings::SteamTab::SteamTab(Settings *m_parent, SettingsDialog &m_dialog) :
+ Settings::SettingsTab(m_parent, m_dialog),
+ m_steamUserEdit(m_dialog.findChild<QLineEdit*>("steamUserEdit")),
+ m_steamPassEdit(m_dialog.findChild<QLineEdit*>("steamPassEdit"))
+{
+ if (m_Settings.contains("Settings/steam_username")) {
+ m_steamUserEdit->setText(m_Settings.value("Settings/steam_username", "").toString());
+ if (m_Settings.contains("Settings/steam_password")) {
+ m_steamPassEdit->setText(deObfuscate(m_Settings.value("Settings/steam_password", "").toString()));
}
+ }
+}
+void Settings::SteamTab::update()
+{
+ //FIXME this should be inlined here?
+ m_parent->setSteamLogin(m_steamUserEdit->text(), m_steamPassEdit->text());
+}
- QString oldLanguage = m_Settings.value("Settings/language", "en_US").toString();
- QString newLanguage = languageBox->itemData(languageBox->currentIndex()).toString();
- if (newLanguage != oldLanguage) {
- m_Settings.setValue("Settings/language", newLanguage);
- emit languageChanged(newLanguage);
- }
+Settings::PluginsTab::PluginsTab(Settings *m_parent, SettingsDialog &m_dialog) :
+ Settings::SettingsTab(m_parent, m_dialog),
+ m_pluginsList(m_dialog.findChild<QListWidget*>("pluginsList")),
+ m_pluginBlacklistList(m_dialog.findChild<QListWidget*>("pluginBlacklist"))
+{
+ // display plugin settings
+ for (IPlugin *plugin : m_parent->m_Plugins) {
+ QListWidgetItem *listItem = new QListWidgetItem(plugin->name(), m_pluginsList);
+ listItem->setData(Qt::UserRole, QVariant::fromValue((void*)plugin));
+ listItem->setData(Qt::UserRole + 1, m_parent->m_PluginSettings[plugin->name()]);
+ listItem->setData(Qt::UserRole + 2, m_parent->m_PluginDescriptions[plugin->name()]);
+ m_pluginsList->addItem(listItem);
+ }
+
+ // display plugin blacklist
+ for (const QString &pluginName : m_parent->m_PluginBlacklist) {
+ m_pluginBlacklistList->addItem(pluginName);
+ }
+}
- QString oldStyle = m_Settings.value("Settings/style", "").toString();
- QString newStyle = styleBox->itemData(styleBox->currentIndex()).toString();
- if (oldStyle != newStyle) {
- m_Settings.setValue("Settings/style", newStyle);
- emit styleChanged(newStyle);
+void Settings::PluginsTab::update()
+{
+ // transfer plugin settings to in-memory structure
+ for (int i = 0; i < m_pluginsList->count(); ++i) {
+ QListWidgetItem *item = m_pluginsList->item(i);
+ m_parent->m_PluginSettings[item->text()] = item->data(Qt::UserRole + 1).toMap();
+ }
+ // store plugin settings on disc
+ for (auto iterPlugins = m_parent->m_PluginSettings.begin(); iterPlugins != m_parent->m_PluginSettings.end(); ++iterPlugins) {
+ for (auto iterSettings = iterPlugins->begin(); iterSettings != iterPlugins->end(); ++iterSettings) {
+ m_Settings.setValue("Plugins/" + iterPlugins.key() + "/" + iterSettings.key(), iterSettings.value());
}
+ }
- m_Settings.setValue("Settings/log_level", logLevelBox->currentIndex());
+ // store plugin blacklist
+ m_parent->m_PluginBlacklist.clear();
+ foreach (QListWidgetItem *item, m_pluginBlacklistList->findItems("*", Qt::MatchWildcard)) {
+ m_parent->m_PluginBlacklist.insert(item->text());
+ }
+ m_parent->writePluginBlacklist();
+}
- if (appIDEdit->text() != m_GamePlugin->steamAPPId()) {
- m_Settings.setValue("Settings/app_id", appIDEdit->text());
- } else {
- m_Settings.remove("Settings/app_id");
- }
- if (loginCheckBox->isChecked()) {
- m_Settings.setValue("Settings/nexus_login", true);
- m_Settings.setValue("Settings/nexus_username", usernameEdit->text());
- m_Settings.setValue("Settings/nexus_password", obfuscate(passwordEdit->text()));
- } else {
- m_Settings.setValue("Settings/nexus_login", false);
- m_Settings.remove("Settings/nexus_username");
- m_Settings.remove("Settings/nexus_password");
- }
- setSteamLogin(steamUserEdit->text(), steamPassEdit->text());
- m_Settings.setValue("Settings/offline_mode", offlineBox->isChecked());
- m_Settings.setValue("Settings/use_proxy", proxyBox->isChecked());
- m_Settings.setValue("Settings/display_foreign", displayForeignBox->isChecked());
+Settings::WorkaroundsTab::WorkaroundsTab(Settings *m_parent, SettingsDialog &m_dialog) :
+ Settings::SettingsTab(m_parent, m_dialog),
+ m_appIDEdit(m_dialog.findChild<QLineEdit*>("appIDEdit")),
+ m_mechanismBox(m_dialog.findChild<QComboBox*>("mechanismBox")),
+ m_nmmVersionEdit(m_dialog.findChild<QLineEdit*>("nmmVersionEdit")),
+ m_hideUncheckedBox(m_dialog.findChild<QCheckBox*>("hideUncheckedBox")),
+ m_forceEnableBox(m_dialog.findChild<QCheckBox*>("forceEnableBox")),
+ m_displayForeignBox(m_dialog.findChild<QCheckBox*>("displayForeignBox"))
+{
+ m_appIDEdit->setText(m_parent->getSteamAppID());
- m_Settings.setValue("Settings/nmm_version", nmmVersionEdit->text());
+ LoadMechanism::EMechanism mechanismID = m_parent->getLoadMechanism();
+ int index = 0;
- // transfer plugin settings to in-memory structure
- for (int i = 0; i < pluginsList->count(); ++i) {
- QListWidgetItem *item = pluginsList->item(i);
- m_PluginSettings[item->text()] = item->data(Qt::UserRole + 1).toMap();
- }
- // store plugin settings on disc
- for (auto iterPlugins = m_PluginSettings.begin(); iterPlugins != m_PluginSettings.end(); ++iterPlugins) {
- for (auto iterSettings = iterPlugins->begin(); iterSettings != iterPlugins->end(); ++iterSettings) {
- m_Settings.setValue("Plugins/" + iterPlugins.key() + "/" + iterSettings.key(), iterSettings.value());
- }
+ if (m_parent->m_LoadMechanism.isDirectLoadingSupported()) {
+ m_mechanismBox->addItem(QObject::tr("Mod Organizer"), LoadMechanism::LOAD_MODORGANIZER);
+ if (mechanismID == LoadMechanism::LOAD_MODORGANIZER) {
+ index = m_mechanismBox->count() - 1;
}
+ }
- // store plugin blacklist
- m_PluginBlacklist.clear();
- foreach (QListWidgetItem *item, pluginBlacklistList->findItems("*", Qt::MatchWildcard)) {
- m_PluginBlacklist.insert(item->text());
+ if (m_parent->m_LoadMechanism.isScriptExtenderSupported()) {
+ m_mechanismBox->addItem(QObject::tr("Script Extender"), LoadMechanism::LOAD_SCRIPTEXTENDER);
+ if (mechanismID == LoadMechanism::LOAD_SCRIPTEXTENDER) {
+ index = m_mechanismBox->count() - 1;
}
- writePluginBlacklist();
+ }
- // store server preference
- m_Settings.beginGroup("Servers");
- for (int i = 0; i < knownServersList->count(); ++i) {
- QString key = knownServersList->item(i)->data(Qt::UserRole).toString();
- QVariantMap val = m_Settings.value(key).toMap();
- val["preferred"] = 0;
- m_Settings.setValue(key, val);
- }
- int count = preferredServersList->count();
- for (int i = 0; i < count; ++i) {
- QString key = preferredServersList->item(i)->data(Qt::UserRole).toString();
- QVariantMap val = m_Settings.value(key).toMap();
- val["preferred"] = count - i;
- m_Settings.setValue(key, val);
+ if (m_parent->m_LoadMechanism.isProxyDLLSupported()) {
+ m_mechanismBox->addItem(QObject::tr("Proxy DLL"), LoadMechanism::LOAD_PROXYDLL);
+ if (mechanismID == LoadMechanism::LOAD_PROXYDLL) {
+ index = m_mechanismBox->count() - 1;
}
- m_Settings.endGroup();
}
+
+ m_mechanismBox->setCurrentIndex(index);
+
+ m_nmmVersionEdit->setText(m_parent->getNMMVersion());
+ m_hideUncheckedBox->setChecked(m_parent->hideUncheckedPlugins());
+ m_forceEnableBox->setChecked(m_parent->forceEnableCoreFiles());
+ m_displayForeignBox->setChecked(m_parent->displayForeign());
+
+}
+
+void Settings::WorkaroundsTab::update()
+{
+ if (m_appIDEdit->text() != m_parent->m_GamePlugin->steamAPPId()) {
+ m_Settings.setValue("Settings/app_id", m_appIDEdit->text());
+ } else {
+ m_Settings.remove("Settings/app_id");
+ }
+ m_Settings.setValue("Settings/load_mechanism", m_mechanismBox->itemData(m_mechanismBox->currentIndex()).toInt());
+ m_Settings.setValue("Settings/nmm_version", m_nmmVersionEdit->text());
+ m_Settings.setValue("Settings/hide_unchecked_plugins", m_hideUncheckedBox->isChecked());
+ m_Settings.setValue("Settings/force_enable_core_files", m_forceEnableBox->isChecked());
+ m_Settings.setValue("Settings/display_foreign", m_displayForeignBox->isChecked());
}