From b6b01a52db1877b16531137289641fb9be9833aa Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Fri, 2 Aug 2019 23:24:27 -0400
Subject: removed mentions of QSettings from main.cpp added necessary member
functions in Settings
---
src/settings.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 74 insertions(+), 3 deletions(-)
(limited to 'src/settings.cpp')
diff --git a/src/settings.cpp b/src/settings.cpp
index 77db6918..5d103267 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -28,8 +28,8 @@ using namespace MOBase;
Settings *Settings::s_Instance = nullptr;
-Settings::Settings(const QSettings &settingsSource)
- : m_Settings(settingsSource.fileName(), settingsSource.format())
+Settings::Settings(const QString& path)
+ : m_Settings(path, QSettings::IniFormat)
{
if (s_Instance != nullptr) {
throw std::runtime_error("second instance of \"Settings\" created");
@@ -280,7 +280,57 @@ QString Settings::getModDirectory(bool resolve) const
QString Settings::getManagedGameDirectory() const
{
- return m_Settings.value("gamePath", "").toString();
+ return QString::fromUtf8(m_Settings.value("gamePath", "").toByteArray());
+}
+
+void Settings::setManagedGameDirectory(const QString& path)
+{
+ m_Settings.setValue("gamePath", QDir::toNativeSeparators(path).toUtf8());
+}
+
+QString Settings::getManagedGameName() const
+{
+ return m_Settings.value("gameName", "").toString();
+}
+
+void Settings::setManagedGameName(const QString& name)
+{
+ m_Settings.setValue("gameName", name);
+}
+
+QString Settings::getManagedGameEdition() const
+{
+ return m_Settings.value("game_edition", "").toString();
+}
+
+void Settings::setManagedGameEdition(const QString& name)
+{
+ m_Settings.setValue("game_edition", name);
+}
+
+QString Settings::getSelectedProfileName() const
+{
+ return QString::fromUtf8(m_Settings.value("selected_profile", "").toByteArray());
+}
+
+int Settings::getMainWindowMonitor() const
+{
+ return m_Settings.value("window_monitor", -1).toInt();
+}
+
+QString Settings::getStyleName() const
+{
+ return m_Settings.value("Settings/style", "").toString();
+}
+
+void Settings::setStyleName(const QString& name)
+{
+ m_Settings.setValue("Settings/style", name);
+}
+
+bool Settings::isCategoryListVisible() const
+{
+ return m_Settings.value("categorylist_visible", true).toBool();
}
QString Settings::getProfileDirectory(bool resolve) const
@@ -608,3 +658,24 @@ void Settings::writePluginBlacklist()
m_Settings.endArray();
}
+
+void Settings::dump() const
+{
+ static const QStringList ignore({
+ "username", "password", "nexus_api_key"
+ });
+
+ log::debug("settings:");
+
+ m_Settings.beginGroup("Settings");
+
+ for (auto k : m_Settings.allKeys()) {
+ if (ignore.contains(k, Qt::CaseInsensitive)) {
+ continue;
+ }
+
+ log::debug(" . {}={}", k, m_Settings.value(k).toString());
+ }
+
+ m_Settings.endGroup();
+}
--
cgit v1.3.1
From 07f1ac7a96dcf4c91a24bb1d30af92851ecda78f Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Sat, 3 Aug 2019 01:55:21 -0400
Subject: split into GeometrySettings removed most of storeSettings() from
OrganizerCore: QSettings handles saving by itself, no need for that removed
topLevelSplitter from ui, unused since the log widget is in a dock removed
QSettings from MainWindow::readSettings() replaced return values for some of
the new getters in Settings to std::optional
---
src/executableslist.cpp | 9 ++-
src/executableslist.h | 5 +-
src/filedialogmemory.cpp | 8 ++-
src/filedialogmemory.h | 5 +-
src/iuserinterface.h | 4 +-
src/main.cpp | 96 +++++++++++++++----------
src/mainwindow.cpp | 116 ++++++++++++++----------------
src/mainwindow.h | 4 +-
src/mainwindow.ui | 5 --
src/organizercore.cpp | 90 +++++-------------------
src/organizercore.h | 4 --
src/settings.cpp | 180 +++++++++++++++++++++++++++++++++++++++++++----
src/settings.h | 55 ++++++++++++---
13 files changed, 359 insertions(+), 222 deletions(-)
(limited to 'src/settings.cpp')
diff --git a/src/executableslist.cpp b/src/executableslist.cpp
index 3f76bb6f..2b3219df 100644
--- a/src/executableslist.cpp
+++ b/src/executableslist.cpp
@@ -21,6 +21,7 @@ along with Mod Organizer. If not, see .
#include "iplugingame.h"
#include "utility.h"
+#include "settings.h"
#include
#include
@@ -64,7 +65,7 @@ bool ExecutablesList::empty() const
return m_Executables.empty();
}
-void ExecutablesList::load(const MOBase::IPluginGame* game, QSettings& settings)
+void ExecutablesList::load(const MOBase::IPluginGame* game, const Settings& s)
{
log::debug("loading executables");
@@ -74,6 +75,8 @@ void ExecutablesList::load(const MOBase::IPluginGame* game, QSettings& settings)
// executables from 2.2.0, see upgradeFromCustom()
bool needsUpgrade = false;
+ auto& settings = const_cast(s.directInterface());
+
int numCustomExecutables = settings.beginReadArray("customExecutables");
for (int i = 0; i < numCustomExecutables; ++i) {
settings.setArrayIndex(i);
@@ -108,8 +111,10 @@ void ExecutablesList::load(const MOBase::IPluginGame* game, QSettings& settings)
dump();
}
-void ExecutablesList::store(QSettings& settings)
+void ExecutablesList::store(Settings& s)
{
+ auto& settings = s.directInterface();
+
settings.remove("customExecutables");
settings.beginWriteArray("customExecutables");
diff --git a/src/executableslist.h b/src/executableslist.h
index eda2034e..23cf3cfe 100644
--- a/src/executableslist.h
+++ b/src/executableslist.h
@@ -29,6 +29,7 @@ along with Mod Organizer. If not, see .
#include
namespace MOBase { class IPluginGame; class ExecutableInfo; }
+class Settings;
/*!
* @brief Information about an executable
@@ -103,7 +104,7 @@ public:
/**
* @brief initializes the list from the settings and the given plugin
**/
- void load(const MOBase::IPluginGame* game, QSettings& settings);
+ void load(const MOBase::IPluginGame* game, const Settings& settings);
/**
* @brief re-adds all the executables from the plugin and renames existing
@@ -114,7 +115,7 @@ public:
/**
* @brief writes the current list to the settings
*/
- void store(QSettings& settings);
+ void store(Settings& settings);
/**
* @brief get an executable by name
diff --git a/src/filedialogmemory.cpp b/src/filedialogmemory.cpp
index 308a175e..48828563 100644
--- a/src/filedialogmemory.cpp
+++ b/src/filedialogmemory.cpp
@@ -27,8 +27,10 @@ FileDialogMemory::FileDialogMemory()
}
-void FileDialogMemory::save(QSettings &settings)
+void FileDialogMemory::save(Settings& s)
{
+ auto& settings = s.directInterface();
+
settings.remove("recentDirectories");
settings.beginWriteArray("recentDirectories");
int index = 0;
@@ -42,8 +44,10 @@ void FileDialogMemory::save(QSettings &settings)
}
-void FileDialogMemory::restore(QSettings &settings)
+void FileDialogMemory::restore(const Settings& s)
{
+ auto& settings = const_cast(s.directInterface());
+
int size = settings.beginReadArray("recentDirectories");
for (int i = 0; i < size; ++i) {
settings.setArrayIndex(i);
diff --git a/src/filedialogmemory.h b/src/filedialogmemory.h
index 1a72b289..d214a8e6 100644
--- a/src/filedialogmemory.h
+++ b/src/filedialogmemory.h
@@ -23,7 +23,6 @@ along with Mod Organizer. If not, see .
#include