diff options
| author | Tannin <devnull@localhost> | 2013-06-20 21:55:37 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-06-20 21:55:37 +0200 |
| commit | f8c683f700a3fff30540ff343df2bfba15080e86 (patch) | |
| tree | 248b6dcea1f45449675c05d4e64ed4b76e976919 /src/settings.cpp | |
| parent | 49cbe0349184419530d22782cc670946b61c9f01 (diff) | |
- some fixes for qt5 compatibility
- hook.dll no longer creates a dump and uninstalls it if an exception is reported that doesn't originate from it
- NCC used read-only transactions again because otherwise solid archives become unusably slow.
- removed the integrated nexus browser
- the mod description and motd are now rendered in QTextBrowser. This (and the above) eliminates the dependency on qtwebkit
- removed the direct file download for mod files
- reduced CPU usage during downloads by invalidating only one column of the download list. This widget still needs to be replaced
- added the complete filename as an option for the modname
- applications that require elevation can now be started by invoking an elevated secondary ModOrganizer instance
- MO will now register nexus file servers and provides a settings dialog to pick preferred servers. (This preference is not used yet)
- worked around 1-2 bugs in QSortFilterProxy
- handling of nxm links is now done by an external application. This allows the registration of different applications depending on the game
- integrated fomod installer now displays the screenshot in a scalable view
- bugfix: integrated fomod installer didn't name output files correctly if the name differs from the source name
- bugfix: a successful login to nexus was (sometimes?) not correctly detected as a success
- bugfix: top-level entries in QtGroupingProxy were sometimes incorrectly displayed as groups
- bugfix: GetPrivateProfile... optimization could cause null-pointer indirection
- bugfix: GetCurrentWorkingDirectory caused buffer overflow in case of pre-flighting (buffer size 0)
- bugfix: configurator plugin now also uses qt5 (it's currently broken though)
Diffstat (limited to 'src/settings.cpp')
| -rw-r--r-- | src/settings.cpp | 107 |
1 files changed, 84 insertions, 23 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 27dea0dc..991f1f59 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -38,6 +38,20 @@ using namespace MOBase; using namespace MOShared; +template <typename T> +class QListWidgetItemEx : public QListWidgetItem { +public: + QListWidgetItemEx(const QString &text, int sortRole = Qt::DisplayRole, QListWidget *parent = 0, int type = Type) + : QListWidgetItem(text, parent, type), m_SortRole(sortRole) {} + + virtual bool operator< ( const QListWidgetItem & other ) const { + return this->data(m_SortRole).value<T>() < other.data(m_SortRole).value<T>(); + } +private: + int m_SortRole; +}; + + static const unsigned char Key2[20] = { 0x99, 0xb8, 0x76, 0x42, 0x3e, 0xc1, 0x60, 0xa4, 0x5b, 0x01, 0xdb, 0xf8, 0x43, 0x3a, 0xb7, 0xb6, 0x98, 0xd4, 0x7d, 0xa2 }; @@ -201,24 +215,12 @@ void Settings::setupLoadMechanism() } -bool Settings::preferIntegratedInstallers() -{ - return m_Settings.value("Settings/prefer_integrated_installer").toBool(); -} - - bool Settings::enableQuickInstaller() { return m_Settings.value("Settings/enable_quick_installer").toBool(); } -bool Settings::preferExternalBrowser() -{ - return m_Settings.value("Settings/prefer_external_browser").toBool(); -} - - void Settings::setMotDHash(uint hash) { m_Settings.setValue("motd_hash", hash); @@ -259,6 +261,32 @@ QString Settings::language() return result; } +void Settings::updateServers(const QList<ServerInfo> &servers) +{ + m_Settings.beginGroup("Servers"); + QStringList oldServerKeys = m_Settings.childKeys(); + + foreach (const ServerInfo &server, servers) { + if (!oldServerKeys.contains(server.name)) { + // not yet known server + QVariantMap newVal; + newVal["premium"] = server.premium; + newVal["preferred"] = server.preferred; + newVal["lastSeen"] = server.lastSeen; + m_Settings.setValue(server.name, newVal); + } else { + QVariantMap data = m_Settings.value(server.name).toMap(); + data["lastSeen"] = server.lastSeen; + data["premium"] = server.premium; + + m_Settings.setValue(server.name, data); + } + } + + m_Settings.endGroup(); + m_Settings.sync(); +} + void Settings::addLanguages(QComboBox *languageBox) { @@ -299,7 +327,7 @@ void Settings::addStyles(QComboBox *styleBox) bool Settings::isNXMHandler(bool *modifyable) { - QSettings handlerReg("HKEY_CLASSES_ROOT\\nxm\\shell\\open\\command", + QSettings handlerReg("HKEY_CURRENT_USER\\Software\\Classes\\nxm\\shell\\open\\command", QSettings::NativeFormat); QString currentExe = handlerReg.value("Default", "").toString().toUtf8().constData(); @@ -317,8 +345,8 @@ bool Settings::isNXMHandler(bool *modifyable) void Settings::setNXMHandlerActive(bool active, bool writable) { - QSettings handlerReg("HKEY_CLASSES_ROOT\\nxm\\", - QSettings::NativeFormat); +// QSettings handlerReg("HKEY_CLASSES_ROOT\\nxm\\", QSettings::NativeFormat); + QSettings handlerReg("HKEY_CURRENT_USER\\Software\\Classes\\nxm\\", QSettings::NativeFormat); if (writable) { QString myExe = QString("\"%1\" ").arg(QDir::toNativeSeparators(QCoreApplication::applicationFilePath())).append("\"%1\""); @@ -363,18 +391,20 @@ void Settings::query(QWidget *parent) QComboBox *languageBox = dialog.findChild<QComboBox*>("languageBox"); QComboBox *styleBox = dialog.findChild<QComboBox*>("styleBox"); QComboBox *logLevelBox = dialog.findChild<QComboBox*>("logLevelBox"); - QCheckBox *handleNXMBox = dialog.findChild<QCheckBox*>("handleNXMBox"); +// QCheckBox *handleNXMBox = dialog.findChild<QCheckBox*>("handleNXMBox"); QLineEdit *downloadDirEdit = dialog.findChild<QLineEdit*>("downloadDirEdit"); QLineEdit *modDirEdit = dialog.findChild<QLineEdit*>("modDirEdit"); QLineEdit *cacheDirEdit = dialog.findChild<QLineEdit*>("cacheDirEdit"); - QCheckBox *preferExternalBox = dialog.findChild<QCheckBox*>("preferExternalBox"); QCheckBox *offlineBox = dialog.findChild<QCheckBox*>("offlineBox"); QLineEdit *nmmVersionEdit = dialog.findChild<QLineEdit*>("nmmVersionEdit"); QListWidget *pluginsList = dialog.findChild<QListWidget*>("pluginsList"); + QListWidget *knownServersList = dialog.findChild<QListWidget*>("knownServersList"); + QListWidget *preferredServersList = dialog.findChild<QListWidget*>("preferredServersList"); + // // set up current settings // @@ -437,18 +467,17 @@ void Settings::query(QWidget *parent) passwordEdit->setText(deObfuscate(m_Settings.value("Settings/nexus_password", "").toString())); } - bool registryWritable = false; +/* bool registryWritable = false; bool nxmHandler = isNXMHandler(®istryWritable); handleNXMBox->setChecked(nxmHandler); if (!registryWritable) { handleNXMBox->setIcon(QIcon(":/MO/gui/locked")); handleNXMBox->setToolTip(tr("Administrative rights required to change this.")); - } + }*/ downloadDirEdit->setText(getDownloadDirectory()); modDirEdit->setText(getModDirectory()); cacheDirEdit->setText(getCacheDirectory()); - preferExternalBox->setChecked(m_Settings.value("Settings/prefer_external_browser", false).toBool()); offlineBox->setChecked(m_Settings.value("Settings/offline_mode", false).toBool()); nmmVersionEdit->setText(m_Settings.value("Settings/nmm_version", "0.33.1").toString()); logLevelBox->setCurrentIndex(logLevel()); @@ -460,6 +489,22 @@ void Settings::query(QWidget *parent) pluginsList->addItem(listItem); } + m_Settings.beginGroup("Servers"); + foreach (const QString &key, m_Settings.childKeys()) { + QVariantMap val = m_Settings.value(key).toMap(); + QString type = val["premium"].toBool() ? "(premium)" : "(free)"; + QListWidgetItem *newItem = new QListWidgetItemEx<int>(key + " " + type, Qt::UserRole + 1); + newItem->setData(Qt::UserRole, key); + newItem->setData(Qt::UserRole + 1, val["preferred"].toInt()); + if (val["preferred"].toInt() > 0) { + preferredServersList->addItem(newItem); + } else { + knownServersList->addItem(newItem); + } + preferredServersList->sortItems(Qt::DescendingOrder); + } + m_Settings.endGroup(); + if (dialog.exec() == QDialog::Accepted) { // // transfer modified settings to configuration file @@ -514,10 +559,9 @@ void Settings::query(QWidget *parent) m_Settings.remove("Settings/nexus_username"); m_Settings.remove("Settings/nexus_password"); } - if (nxmHandler != handleNXMBox->isChecked()) { +/* if (nxmHandler != handleNXMBox->isChecked()) { setNXMHandlerActive(handleNXMBox->isChecked(), registryWritable); - } - m_Settings.setValue("Settings/prefer_external_browser", preferExternalBox->isChecked()); + }*/ m_Settings.setValue("Settings/offline_mode", offlineBox->isChecked()); m_Settings.setValue("Settings/nmm_version", nmmVersionEdit->text()); @@ -533,5 +577,22 @@ void Settings::query(QWidget *parent) m_Settings.setValue("Plugins/" + iterPlugins.key() + "/" + iterSettings.key(), iterSettings.value()); } } + + // 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); + } + m_Settings.endGroup(); } } |
