summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MultiMC.cpp85
-rw-r--r--depends/settings/CMakeLists.txt43
-rw-r--r--depends/settings/include/basicsettingsobject.h42
-rw-r--r--depends/settings/include/keyring.h97
-rw-r--r--depends/settings/inifile.cpp (renamed from depends/settings/src/inifile.cpp)2
-rw-r--r--depends/settings/inifile.h (renamed from depends/settings/include/inifile.h)0
-rw-r--r--depends/settings/inisettingsobject.cpp (renamed from depends/settings/src/inisettingsobject.cpp)34
-rw-r--r--depends/settings/inisettingsobject.h (renamed from depends/settings/include/inisettingsobject.h)0
-rw-r--r--depends/settings/libsettings_config.h (renamed from depends/settings/include/libsettings_config.h)1
-rw-r--r--depends/settings/overridesetting.cpp (renamed from depends/settings/src/overridesetting.cpp)6
-rw-r--r--depends/settings/overridesetting.h (renamed from depends/settings/include/overridesetting.h)5
-rw-r--r--depends/settings/setting.cpp (renamed from depends/settings/src/setting.cpp)16
-rw-r--r--depends/settings/setting.h (renamed from depends/settings/include/setting.h)21
-rw-r--r--depends/settings/settingsobject.cpp (renamed from depends/settings/src/settingsobject.cpp)90
-rw-r--r--depends/settings/settingsobject.h (renamed from depends/settings/include/settingsobject.h)82
-rw-r--r--depends/settings/src/basicsettingsobject.cpp44
-rw-r--r--depends/settings/src/keyring.cpp63
-rw-r--r--depends/settings/src/stubkeyring.cpp105
-rw-r--r--depends/settings/src/stubkeyring.h47
-rw-r--r--logic/BaseInstance.cpp58
-rw-r--r--logic/InstanceFactory.cpp6
-rw-r--r--logic/LegacyInstance.cpp10
-rw-r--r--logic/OneSixInstance.cpp4
-rw-r--r--logic/icons/IconList.cpp6
24 files changed, 228 insertions, 639 deletions
diff --git a/MultiMC.cpp b/MultiMC.cpp
index fe83fbd1..07adc658 100644
--- a/MultiMC.cpp
+++ b/MultiMC.cpp
@@ -166,7 +166,7 @@ MultiMC::MultiMC(int &argc, char **argv, const QString &root)
m_instances.reset(new InstanceList(InstDirSetting->get().toString(), this));
QLOG_INFO() << "Loading Instances...";
m_instances->loadList();
- connect(InstDirSetting, SIGNAL(settingChanged(const Setting &, QVariant)),
+ connect(InstDirSetting.get(), SIGNAL(settingChanged(const Setting &, QVariant)),
m_instances.get(), SLOT(on_InstFolderChanged(const Setting &, QVariant)));
// and accounts
@@ -324,23 +324,22 @@ void MultiMC::initGlobalSettings()
{
m_settings.reset(new INISettingsObject("multimc.cfg", this));
// Updates
- m_settings->registerSetting(new Setting("UseDevBuilds", false));
- m_settings->registerSetting(new Setting("AutoUpdate", true));
+ m_settings->registerSetting("UseDevBuilds", false);
+ m_settings->registerSetting("AutoUpdate", true);
// FTB
- m_settings->registerSetting(new Setting("TrackFTBInstances", false));
- m_settings->registerSetting(new Setting(
- "FTBLauncherRoot",
+ m_settings->registerSetting("TrackFTBInstances", false);
#ifdef Q_OS_LINUX
- QDir::home().absoluteFilePath(".ftblauncher")
+ QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher");
#elif defined(Q_OS_WIN32)
- PathCombine(QDir::homePath(), "AppData/Roaming/ftblauncher")
+ QString ftbDefault = PathCombine(QDir::homePath(), "AppData/Roaming/ftblauncher");
#elif defined(Q_OS_MAC)
- PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher")
+ QString ftbDefault =
+ PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher");
#endif
- ));
+ m_settings->registerSetting("FTBLauncherRoot", ftbDefault);
- m_settings->registerSetting(new Setting("FTBRoot"));
+ m_settings->registerSetting("FTBRoot");
if (m_settings->get("FTBRoot").isNull())
{
QString ftbRoot;
@@ -379,54 +378,54 @@ void MultiMC::initGlobalSettings()
}
// Folders
- m_settings->registerSetting(new Setting("InstanceDir", "instances"));
- m_settings->registerSetting(new Setting("CentralModsDir", "mods"));
- m_settings->registerSetting(new Setting("LWJGLDir", "lwjgl"));
- m_settings->registerSetting(new Setting("IconsDir", "icons"));
+ m_settings->registerSetting("InstanceDir", "instances");
+ m_settings->registerSetting({"CentralModsDir", "ModsDir"}, "mods");
+ m_settings->registerSetting({"LWJGLDir", "LwjglDir"}, "lwjgl");
+ m_settings->registerSetting("IconsDir", "icons");
// Editors
- m_settings->registerSetting(new Setting("JsonEditor", QString()));
+ m_settings->registerSetting("JsonEditor", QString());
// Console
- m_settings->registerSetting(new Setting("ShowConsole", true));
- m_settings->registerSetting(new Setting("AutoCloseConsole", true));
+ m_settings->registerSetting("ShowConsole", true);
+ m_settings->registerSetting("AutoCloseConsole", true);
// Console Colors
- // m_settings->registerSetting(new Setting("SysMessageColor", QColor(Qt::blue)));
- // m_settings->registerSetting(new Setting("StdOutColor", QColor(Qt::black)));
- // m_settings->registerSetting(new Setting("StdErrColor", QColor(Qt::red)));
+ // m_settings->registerSetting("SysMessageColor", QColor(Qt::blue));
+ // m_settings->registerSetting("StdOutColor", QColor(Qt::black));
+ // m_settings->registerSetting("StdErrColor", QColor(Qt::red));
// Window Size
- m_settings->registerSetting(new Setting("LaunchMaximized", false));
- m_settings->registerSetting(new Setting("MinecraftWinWidth", 854));
- m_settings->registerSetting(new Setting("MinecraftWinHeight", 480));
+ m_settings->registerSetting({"LaunchMaximized", "MCWindowMaximize"}, false);
+ m_settings->registerSetting({"MinecraftWinWidth", "MCWindowWidth"}, 854);
+ m_settings->registerSetting({"MinecraftWinHeight", "MCWindowHeight"}, 480);
// Memory
- m_settings->registerSetting(new Setting("MinMemAlloc", 512));
- m_settings->registerSetting(new Setting("MaxMemAlloc", 1024));
- m_settings->registerSetting(new Setting("PermGen", 64));
+ m_settings->registerSetting({"MinMemAlloc", "MinMemoryAlloc"}, 512);
+ m_settings->registerSetting({"MaxMemAlloc", "MaxMemoryAlloc"}, 1024);
+ m_settings->registerSetting("PermGen", 64);
// Java Settings
- m_settings->registerSetting(new Setting("JavaPath", ""));
- m_settings->registerSetting(new Setting("LastHostname", ""));
- m_settings->registerSetting(new Setting("JvmArgs", ""));
+ m_settings->registerSetting("JavaPath", "");
+ m_settings->registerSetting("LastHostname", "");
+ m_settings->registerSetting("JvmArgs", "");
// Custom Commands
- m_settings->registerSetting(new Setting("PreLaunchCommand", ""));
- m_settings->registerSetting(new Setting("PostExitCommand", ""));
+ m_settings->registerSetting({"PreLaunchCommand", "PreLaunchCmd"}, "");
+ m_settings->registerSetting({"PostExitCommand", "PostLaunchCmd"}, "");
// The cat
- m_settings->registerSetting(new Setting("TheCat", false));
+ m_settings->registerSetting("TheCat", false);
- m_settings->registerSetting(new Setting("InstSortMode", "Name"));
- m_settings->registerSetting(new Setting("SelectedInstance", QString()));
+ m_settings->registerSetting("InstSortMode", "Name");
+ m_settings->registerSetting("SelectedInstance", QString());
// Window state and geometry
- m_settings->registerSetting(new Setting("MainWindowState", ""));
- m_settings->registerSetting(new Setting("MainWindowGeometry", ""));
+ m_settings->registerSetting("MainWindowState", "");
+ m_settings->registerSetting("MainWindowGeometry", "");
- m_settings->registerSetting(new Setting("ConsoleWindowState", ""));
- m_settings->registerSetting(new Setting("ConsoleWindowGeometry", ""));
+ m_settings->registerSetting("ConsoleWindowState", "");
+ m_settings->registerSetting("ConsoleWindowGeometry", "");
}
void MultiMC::initHttpMetaCache()
@@ -524,9 +523,9 @@ void MultiMC::installUpdates(const QString &updateFilesDir, bool restartOnFinish
args << "--finish-cmd" << finishCmd;
QLOG_INFO() << "Running updater with command" << updaterBinary << args.join(" ");
- QFile::setPermissions(updaterBinary, (QFileDevice::Permission) 0x7755);
+ QFile::setPermissions(updaterBinary, (QFileDevice::Permission)0x7755);
- if(!QProcess::startDetached(updaterBinary, args))
+ if (!QProcess::startDetached(updaterBinary, args))
{
QLOG_ERROR() << "Failed to start the updater process!";
return;
@@ -555,8 +554,8 @@ bool MultiMC::openJsonEditor(const QString &filename)
}
else
{
- return QProcess::startDetached(m_settings->get("JsonEditor").toString(),
- QStringList() << file);
+ return QProcess::startDetached(m_settings->get("JsonEditor").toString(), QStringList()
+ << file);
}
}
diff --git a/depends/settings/CMakeLists.txt b/depends/settings/CMakeLists.txt
index 154697f6..da853a73 100644
--- a/depends/settings/CMakeLists.txt
+++ b/depends/settings/CMakeLists.txt
@@ -5,44 +5,27 @@ find_package(Qt5Core REQUIRED)
# Include Qt headers.
include_directories(${Qt5Base_INCLUDE_DIRS})
-include_directories(${Qt5Network_INCLUDE_DIRS})
-SET(LIBSETTINGS_HEADERS
-include/libsettings_config.h
-
-include/inifile.h
-
-include/settingsobject.h
-include/setting.h
-include/overridesetting.h
-
-include/basicsettingsobject.h
-include/inisettingsobject.h
-
-include/keyring.h
-)
-
-SET(LIBSETTINGS_HEADERS_PRIVATE
-src/stubkeyring.h
-)
SET(LIBSETTINGS_SOURCES
-src/inifile.cpp
+libsettings_config.h
-src/settingsobject.cpp
-src/setting.cpp
-src/overridesetting.cpp
+inifile.h
+inifile.cpp
-src/basicsettingsobject.cpp
-src/inisettingsobject.cpp
+settingsobject.h
+settingsobject.cpp
+inisettingsobject.h
+inisettingsobject.cpp
-src/keyring.cpp
-src/stubkeyring.cpp
+setting.h
+setting.cpp
+overridesetting.h
+overridesetting.cpp
)
# Set the include dir path.
-SET(LIBSETTINGS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
-include_directories(${LIBSETTINGS_INCLUDE_DIR})
+SET(LIBSETTINGS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE)
# Static link!
ADD_DEFINITIONS(-DLIBSETTINGS_STATIC)
@@ -59,6 +42,6 @@ IF(MultiMC_CODE_COVERAGE)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0 --coverage")
ENDIF(MultiMC_CODE_COVERAGE)
-add_library(libSettings STATIC ${LIBSETTINGS_SOURCES} ${LIBSETTINGS_HEADERS} ${LIBSETTINGS_HEADERS_PRIVATE})
+add_library(libSettings STATIC ${LIBSETTINGS_SOURCES})
qt5_use_modules(libSettings Core)
target_link_libraries(libSettings)
diff --git a/depends/settings/include/basicsettingsobject.h b/depends/settings/include/basicsettingsobject.h
deleted file mode 100644
index 387a3646..00000000
--- a/depends/settings/include/basicsettingsobject.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <QObject>
-#include <QSettings>
-
-#include "settingsobject.h"
-
-#include "libsettings_config.h"
-
-/*!
- * \brief A settings object that stores its settings in a QSettings object.
- */
-class LIBSETTINGS_EXPORT BasicSettingsObject : public SettingsObject
-{
- Q_OBJECT
-public:
- explicit BasicSettingsObject(QObject *parent = 0);
-
-protected
-slots:
- virtual void changeSetting(const Setting &setting, QVariant value);
-
-protected:
- virtual QVariant retrieveValue(const Setting &setting);
-
- QSettings config;
-};
diff --git a/depends/settings/include/keyring.h b/depends/settings/include/keyring.h
deleted file mode 100644
index a4da23b1..00000000
--- a/depends/settings/include/keyring.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Authors: Orochimarufan <orochimarufan.x3@gmail.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <QString>
-
-#include "libsettings_config.h"
-
-/**
- * @file libsettings/include/keyring.h
- * Access to System Keyrings
- */
-
-/**
- * @brief The Keyring class
- * the System Keyring/Keychain/Wallet/Vault/etc
- */
-class LIBSETTINGS_EXPORT Keyring
-{
-public:
- /**
- * @brief virtual dtor
- */
- virtual ~Keyring() {};
-
- /**
- * @brief the System Keyring instance
- * @return the Keyring instance
- */
- static Keyring *instance();
-
- /**
- * @brief store a password in the Keyring
- * @param service the service name
- * @param username the account name
- * @param password the password to store
- * @return success
- */
- virtual bool storePassword(QString service, QString username, QString password) = 0;
-
- /**
- * @brief get a password from the Keyring
- * @param service the service name
- * @param username the account name
- * @return the password (success=!isNull())
- */
- virtual QString getPassword(QString service, QString username) = 0;
-
- /**
- * @brief lookup a password
- * @param service the service name
- * @param username the account name
- * @return wether the password is available
- */
- virtual bool hasPassword(QString service, QString username) = 0;
-
- /**
- * @brief get a list of all stored accounts.
- * @param service the service name
- * @return
- */
- virtual QStringList getStoredAccounts(QString service) = 0;
-
- /**
- * @brief Remove the specified account from storage
- * @param service the service name
- * @param username the account name
- * @return
- */
- virtual void removeStoredAccount(QString service, QString username) = 0;
-
-protected:
- /// fall back to StubKeyring if false
- virtual bool isValid()
- {
- return false;
- }
-
-private:
- static Keyring *m_instance;
- static void destroy();
-};
diff --git a/depends/settings/src/inifile.cpp b/depends/settings/inifile.cpp
index 83aec15e..1170f0b1 100644
--- a/depends/settings/src/inifile.cpp
+++ b/depends/settings/inifile.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-#include "include/inifile.h"
+#include "inifile.h"
#include <QFile>
#include <QTextStream>
diff --git a/depends/settings/include/inifile.h b/depends/settings/inifile.h
index 27da7bf0..27da7bf0 100644
--- a/depends/settings/include/inifile.h
+++ b/depends/settings/inifile.h
diff --git a/depends/settings/src/inisettingsobject.cpp b/depends/settings/inisettingsobject.cpp
index 4a7a7428..5e52a56f 100644
--- a/depends/settings/src/inisettingsobject.cpp
+++ b/depends/settings/inisettingsobject.cpp
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-#include "include/inisettingsobject.h"
-#include "include/setting.h"
+#include "inisettingsobject.h"
+#include "setting.h"
INISettingsObject::INISettingsObject(const QString &path, QObject *parent)
: SettingsObject(parent)
@@ -32,31 +32,45 @@ void INISettingsObject::changeSetting(const Setting &setting, QVariant value)
{
if (contains(setting.id()))
{
+ // valid value -> set the main config, remove all the sysnonyms
if (value.isValid())
- m_ini.set(setting.configKey(), value);
+ {
+ auto list = setting.configKeys();
+ m_ini.set(list.takeFirst(), value);
+ for(auto iter: list)
+ m_ini.remove(iter);
+ }
+ // invalid -> remove all (just like resetSetting)
else
- m_ini.remove(setting.configKey());
+ {
+ for(auto iter: setting.configKeys())
+ m_ini.remove(iter);
+ }
m_ini.saveFile(m_filePath);
}
}
void INISettingsObject::resetSetting(const Setting &setting)
{
+ // if we have the setting, remove all the synonyms. ALL OF THEM
if (contains(setting.id()))
{
- m_ini.remove(setting.configKey());
+ for(auto iter: setting.configKeys())
+ m_ini.remove(iter);
m_ini.saveFile(m_filePath);
}
}
QVariant INISettingsObject::retrieveValue(const Setting &setting)
{
+ // if we have the setting, return value of the first matching synonym
if (contains(setting.id()))
{
- return m_ini.get(setting.configKey(), QVariant());
- }
- else
- {
- return QVariant();
+ for(auto iter: setting.configKeys())
+ {
+ if(m_ini.contains(iter))
+ return m_ini[iter];
+ }
}
+ return QVariant();
}
diff --git a/depends/settings/include/inisettingsobject.h b/depends/settings/inisettingsobject.h
index 8badc0c6..8badc0c6 100644
--- a/depends/settings/include/inisettingsobject.h
+++ b/depends/settings/inisettingsobject.h
diff --git a/depends/settings/include/libsettings_config.h b/depends/settings/libsettings_config.h
index ba77f640..e5beed28 100644
--- a/depends/settings/include/libsettings_config.h
+++ b/depends/settings/libsettings_config.h
@@ -26,3 +26,4 @@
#define LIBSETTINGS_EXPORT Q_DECL_IMPORT
#endif
#endif
+
diff --git a/depends/settings/src/overridesetting.cpp b/depends/settings/overridesetting.cpp
index 5b10920d..7b5f5418 100644
--- a/depends/settings/src/overridesetting.cpp
+++ b/depends/settings/overridesetting.cpp
@@ -13,10 +13,10 @@
* limitations under the License.
*/
-#include "include/overridesetting.h"
+#include "overridesetting.h"
-OverrideSetting::OverrideSetting(const QString &name, Setting *other, QObject *parent)
- : Setting(name, QVariant(), parent)
+OverrideSetting::OverrideSetting(std::shared_ptr<Setting> other)
+ : Setting(other->configKeys(), QVariant())
{
m_other = other;
}
diff --git a/depends/settings/include/overridesetting.h b/depends/settings/overridesetting.h
index 3e60dc7c..5ef901d0 100644
--- a/depends/settings/include/overridesetting.h
+++ b/depends/settings/overridesetting.h
@@ -16,6 +16,7 @@
#pragma once
#include <QObject>
+#include <memory>
#include "setting.h"
@@ -31,10 +32,10 @@ class LIBSETTINGS_EXPORT OverrideSetting : public Setting
{
Q_OBJECT
public:
- explicit OverrideSetting(const QString &name, Setting *other, QObject *parent = 0);
+ explicit OverrideSetting(std::shared_ptr<Setting> other);
virtual QVariant defValue() const;
protected:
- Setting *m_other;
+ std::shared_ptr<Setting> m_other;
};
diff --git a/depends/settings/src/setting.cpp b/depends/settings/setting.cpp
index 899463dc..1a0c6b6a 100644
--- a/depends/settings/src/setting.cpp
+++ b/depends/settings/setting.cpp
@@ -13,17 +13,23 @@
* limitations under the License.
*/
-#include "include/setting.h"
-#include "include/settingsobject.h"
+#include "setting.h"
+#include "settingsobject.h"
-Setting::Setting(QString id, QVariant defVal, QObject *parent)
- : QObject(parent), m_id(id), m_defVal(defVal)
+Setting::Setting(QStringList synonyms, QVariant defVal)
+ : QObject(), m_synonyms(synonyms), m_defVal(defVal)
{
}
+Setting::Setting(QString id, QVariant defVal)
+ : QObject(), m_synonyms({id}), m_defVal(defVal)
+{
+}
+
+
QVariant Setting::get() const
{
- SettingsObject *sbase = qobject_cast<SettingsObject *>(parent());
+ SettingsObject *sbase = m_storage;
if (!sbase)
{
return defValue();
diff --git a/depends/settings/include/setting.h b/depends/settings/setting.h
index 39490207..179fa3bb 100644
--- a/depends/settings/include/setting.h
+++ b/depends/settings/setting.h
@@ -17,6 +17,8 @@
#include <QObject>
#include <QVariant>
+#include <QStringList>
+#include <memory>
#include "libsettings_config.h"
@@ -33,7 +35,13 @@ public:
* \brief Constructs a new Setting object with the given parent.
* \param parent The Setting's parent object.
*/
- explicit Setting(QString id, QVariant defVal = QVariant(), QObject *parent = 0);
+ explicit Setting(QStringList synonyms, QVariant defVal = QVariant());
+
+ /*!
+ * \brief Constructs a new Setting object with the given parent.
+ * \param parent The Setting's parent object.
+ */
+ explicit Setting(QString id, QVariant defVal = QVariant());
/*!
* \brief Gets this setting's ID.
@@ -44,7 +52,7 @@ public:
*/
virtual QString id() const
{
- return m_id;
+ return m_synonyms.first();
}
/*!
@@ -53,9 +61,9 @@ public:
* the same as the setting's ID, but it can be different.
* \return The setting's config file key.
*/
- virtual QString configKey() const
+ virtual QStringList configKeys() const
{
- return id();
+ return m_synonyms;
}
/*!
@@ -111,11 +119,12 @@ slots:
* \brief Reset the setting to default
* This is done by emitting the settingReset() signal which will then be
* handled by the SettingsObject object and cause the setting to change.
- * \param value The new value.
*/
virtual void reset();
protected:
- QString m_id;
+ friend class SettingsObject;
+ SettingsObject * m_storage;
+ QStringList m_synonyms;
QVariant m_defVal;
};
diff --git a/depends/settings/src/settingsobject.cpp b/depends/settings/settingsobject.cpp
index 32a63b8d..43fc989a 100644
--- a/depends/settings/src/settingsobject.cpp
+++ b/depends/settings/settingsobject.cpp
@@ -13,8 +13,9 @@
* limitations under the License.
*/
-#include "include/settingsobject.h"
-#include "include/setting.h"
+#include "settingsobject.h"
+#include "setting.h"
+#include "overridesetting.h"
#include <QVariant>
@@ -22,17 +23,49 @@ SettingsObject::SettingsObject(QObject *parent) : QObject(parent)
{
}
-bool SettingsObject::registerSetting(Setting *setting)
+SettingsObject::~SettingsObject()
{
- // Check if setting is null or we already have a setting with the same ID.
- if (!setting)
+ m_settings.clear();
+}
+
+std::shared_ptr<Setting> SettingsObject::registerOverride(std::shared_ptr<Setting> original)
+{
+ if (contains(original->id()))
{
- qDebug(QString("Failed to register setting. Setting is null.")
- .arg(setting->id())
+ qDebug(QString("Failed to register setting %1. ID already exists.")
+ .arg(original->id())
.toUtf8());
- return false; // Fail
+ return nullptr; // Fail
}
+ auto override = std::make_shared<OverrideSetting>(original);
+ override->m_storage = this;
+ connectSignals(*override);
+ m_settings.insert(override->id(), override);
+ return override;
+}
+
+std::shared_ptr<Setting> SettingsObject::registerSetting(QStringList synonyms, QVariant defVal)
+{
+ if (synonyms.empty())
+ return nullptr;
+ if (contains(synonyms.first()))
+ {
+ qDebug(QString("Failed to register setting %1. ID already exists.")
+ .arg(synonyms.first())
+ .toUtf8());
+ return nullptr; // Fail
+ }
+ auto setting = std::make_shared<Setting>(synonyms, defVal);
+ setting->m_storage = this;
+ connectSignals(*setting);
+ m_settings.insert(setting->id(), setting);
+ return setting;
+}
+
+/*
+bool SettingsObject::registerSetting(Setting *setting)
+{
if (contains(setting->id()))
{
qDebug(QString("Failed to register setting %1. ID already exists.")
@@ -50,21 +83,8 @@ bool SettingsObject::registerSetting(Setting *setting)
// qDebug(QString("Registered setting %1.").arg(setting->id()).toUtf8());
return true;
}
-
-void SettingsObject::unregisterSetting(Setting *setting)
-{
- if (!setting || !m_settings.contains(setting->id()))
- return; // We can't unregister something that's not registered.
-
- m_settings.remove(setting->id());
-
- // Disconnect signals.
- disconnectSignals(*setting);
-
- setting->setParent(NULL); // Drop ownership.
-}
-
-Setting *SettingsObject::getSetting(const QString &id) const
+*/
+std::shared_ptr<Setting> SettingsObject::getSetting(const QString &id) const
{
// Make sure there is a setting with the given ID.
if (!m_settings.contains(id))
@@ -75,13 +95,13 @@ Setting *SettingsObject::getSetting(const QString &id) const
QVariant SettingsObject::get(const QString &id) const
{
- Setting *setting = getSetting(id);
+ auto setting = getSetting(id);
return (setting ? setting->get() : QVariant());
}
bool SettingsObject::set(const QString &id, QVariant value)
{
- Setting *setting = getSetting(id);
+ auto setting = getSetting(id);
if (!setting)
{
qDebug(QString("Error changing setting %1. Setting doesn't exist.").arg(id).toUtf8());
@@ -96,16 +116,11 @@ bool SettingsObject::set(const QString &id, QVariant value)
void SettingsObject::reset(const QString &id) const
{
- Setting *setting = getSetting(id);
+ auto setting = getSetting(id);
if (setting)
setting->reset();
}
-QList<Setting *> SettingsObject::getSettings()
-{
- return m_settings.values();
-}
-
bool SettingsObject::contains(const QString &id)
{
return m_settings.contains(id);
@@ -121,16 +136,3 @@ void SettingsObject::connectSignals(const Setting &setting)
connect(&setting, SIGNAL(settingReset(Setting)), SLOT(resetSetting(const Setting &)));
connect(&setting, SIGNAL(settingReset(Setting)), SIGNAL(settingReset(const Setting &)));
}
-
-void SettingsObject::disconnectSignals(const Setting &setting)
-{
- setting.disconnect(SIGNAL(settingChanged(const Setting &, QVariant)), this,
- SLOT(changeSetting(const Setting &, QVariant)));
- setting.disconnect(SIGNAL(settingChanged(const Setting &, QVariant)), this,
- SIGNAL(settingChanged(const Setting &, QVariant)));
-
- setting.disconnect(SIGNAL(settingReset(const Setting &, QVariant)), this,
- SLOT(resetSetting(const Setting &, QVariant)));
- setting.disconnect(SIGNAL(settingReset(const Setting &, QVariant)), this,
- SIGNAL(settingReset(const Setting &, QVariant)));
-}
diff --git a/depends/settings/include/settingsobject.h b/depends/settings/settingsobject.h
index 7a6b3cb6..27746f2d 100644
--- a/depends/settings/include/settingsobject.h
+++ b/depends/settings/settingsobject.h
@@ -17,6 +17,9 @@
#include <QObject>
#include <QMap>
+#include <QStringList>
+#include <QVariant>
+#include <memory>
#include "libsettings_config.h"
@@ -39,32 +42,37 @@ class LIBSETTINGS_EXPORT SettingsObject : public QObject
Q_OBJECT
public:
explicit SettingsObject(QObject *parent = 0);
+ virtual ~SettingsObject();
+ /*!
+ * Registers an override setting for the given original setting in this settings object
+ *
+ * This will fail if there is already a setting with the same ID as
+ * the one that is being registered.
+ * \return A valid Setting shared pointer if successful.
+ */
+ std::shared_ptr<Setting> registerOverride(std::shared_ptr<Setting> original);
/*!
- * \brief Registers the given setting with this SettingsObject and connects the necessary
- * signals.
+ * Registers the given setting with this SettingsObject and connects the necessary signals.
+ *
* This will fail if there is already a setting with the same ID as
* the one that is being registered.
- * \note Registering a setting object causes the SettingsObject to take ownership
- * of the object. This means that setting's parent will be set to the object
- * it was registered with. Because the object it was registered with has taken
- * ownership, it becomes responsible for managing that setting object's memory.
- * \warning Do \b not delete the setting after registering it.
- * \param setting A pointer to the setting that will be registered.
- * \return True if successful. False if registry failed.
+ * \return A valid Setting shared pointer if successful.
*/
- virtual bool registerSetting(Setting *setting);
+ std::shared_ptr<Setting> registerSetting(QStringList synonyms,
+ QVariant defVal = QVariant());
/*!
- * \brief Unregisters the given setting from this SettingsObject and disconnects its
- * signals.
- * \note This does not delete the setting. Furthermore, when the setting is
- * unregistered, the SettingsObject drops ownership of the setting. This means
- * that if you unregister a setting, its parent is set to null and you become
- * responsible for freeing its memory.
- * \param setting The setting to unregister.
+ * Registers the given setting with this SettingsObject and connects the necessary signals.
+ *
+ * This will fail if there is already a setting with the same ID as
+ * the one that is being registered.
+ * \return A valid Setting shared pointer if successful.
*/
- virtual void unregisterSetting(Setting *setting);
+ std::shared_ptr<Setting> registerSetting(QString id, QVariant defVal = QVariant())
+ {
+ return registerSetting(QStringList(id), defVal);
+ }
/*!
* \brief Gets the setting with the given ID.
@@ -73,18 +81,7 @@ public:
* Returns null if there is no setting with the given ID.
* \sa operator []()
*/
- virtual Setting *getSetting(const QString &id) const;
-
- /*!
- * \brief Same as getSetting()
- * \param id The ID of the setting to get.
- * \return A pointer to the setting with the given ID.
- * \sa getSetting()
- */
- inline Setting *operator[](const QString &id)
- {
- return getSetting(id);
- }
+ std::shared_ptr<Setting> getSetting(const QString &id) const;
/*!
* \brief Gets the value of the setting with the given ID.
@@ -92,7 +89,7 @@ public:
* \return The setting's value as a QVariant.
* If no setting with the given ID exists, returns an invalid QVariant.
*/
- virtual QVariant get(const QString &id) const;
+ QVariant get(const QString &id) const;
/*!
* \brief Sets the value of the setting with the given ID.
@@ -101,27 +98,20 @@ public:
* \param value The new value of the setting.
* \return True if successful, false if it failed.
*/
- virtual bool set(const QString &id, QVariant value);
+ bool set(const QString &id, QVariant value);
/*!
* \brief Reverts the setting with the given ID to default.
* \param id The ID of the setting to reset.
*/
- virtual void reset(const QString &id) const;
-
- /*!
- * \brief Gets a QList with pointers to all of the registered settings.
- * The order of the entries in the list is undefined.
- * \return A QList with pointers to all registered settings.
- */
- virtual QList<Setting *> getSettings();
+ void reset(const QString &id) const;
/*!
* \brief Checks if this SettingsObject contains a setting with the given ID.
* \param id The ID to check for.
* \return True if the SettingsObject has a setting with the given ID.
*/
- virtual bool contains(const QString &id);
+ bool contains(const QString &id);
signals:
/*!
@@ -167,13 +157,7 @@ protected:
* \brief Connects the necessary signals to the given Setting.
* \param setting The setting to connect.
*/
- virtual void connectSignals(const Setting &setting);
-
- /*!
- * \brief Disconnects signals from the given Setting.
- * \param setting The setting to disconnect.
- */
- virtual void disconnectSignals(const Setting &setting);
+ void connectSignals(const Setting &setting);
/*!
* \brief Function used by Setting objects to get their values from the SettingsObject.
@@ -185,5 +169,5 @@ protected:
friend class Setting;
private:
- QMap<QString, Setting *> m_settings;
+ QMap<QString, std::shared_ptr<Setting>> m_settings;
};
diff --git a/depends/settings/src/basicsettingsobject.cpp b/depends/settings/src/basicsettingsobject.cpp
deleted file mode 100644
index 96b38851..00000000
--- a/depends/settings/src/basicsettingsobject.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "include/basicsettingsobject.h"
-#include "include/setting.h"
-
-BasicSettingsObject::BasicSettingsObject(QObject *parent) : SettingsObject(parent)
-{
-}
-
-void BasicSettingsObject::changeSetting(const Setting &setting, QVariant value)
-{
- if (contains(setting.id()))
- {
- if (value.isValid())
- config.setValue(setting.configKey(), value);
- else
- config.remove(setting.configKey());
- }
-}
-
-QVariant BasicSettingsObject::retrieveValue(const Setting &setting)
-{
- if (contains(setting.id()))
- {
- return config.value(setting.configKey());
- }
- else
- {
- return QVariant();
- }
-}
diff --git a/depends/settings/src/keyring.cpp b/depends/settings/src/keyring.cpp
deleted file mode 100644
index 9eaba684..00000000
--- a/depends/settings/src/keyring.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Authors: Orochimarufan <orochimarufan.x3@gmail.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "include/keyring.h"
-
-#include "osutils.h"
-
-#include "stubkeyring.h"
-
-// system specific keyrings
-/*#if defined(OSX)
-class OSXKeychain;
-#define KEYRING OSXKeychain
-#elif defined(LINUX)
-class XDGKeyring;
-#define KEYRING XDGKeyring
-#elif defined(WINDOWS)
-class Win32Keystore;
-#define KEYRING Win32Keystore
-#else
-#pragma message Keyrings are not supported on your os. Falling back to the insecure StubKeyring
-#endif*/
-
-Keyring *Keyring::instance()
-{
- if (m_instance == nullptr)
- {
-#ifdef KEYRING
- m_instance = new KEYRING();
- if (!m_instance->isValid())
- {
- qWarning("Could not create SystemKeyring! falling back to StubKeyring.");
- m_instance = new StubKeyring();
- }
-#else
- qWarning("Keyrings are not supported on your OS. Fallback StubKeyring is insecure!");
- m_instance = new StubKeyring();
-#endif
- atexit(Keyring::destroy);
- }
- return m_instance;
-}
-
-void Keyring::destroy()
-{
- delete m_instance;
-}
-
-Keyring *Keyring::m_instance;
diff --git a/depends/settings/src/stubkeyring.cpp b/depends/settings/src/stubkeyring.cpp
deleted file mode 100644
index 53fca025..00000000
--- a/depends/settings/src/stubkeyring.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Authors: Orochimarufan <orochimarufan.x3@gmail.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "stubkeyring.h"
-
-#include <QStringList>
-
-// Scrambling
-// this is NOT SAFE, but it's not plain either.
-int scrambler = 0x9586309;
-
-QString scramble(QString in_)
-{
- QByteArray in = in_.toUtf8();
- QByteArray out;
- for (int i = 0; i < in.length(); i++)
- out.append(in.at(i) ^ scrambler);
- return QString::fromUtf8(out);
-}
-
-inline QString base64(QString in)
-{
- return QString(in.toUtf8().toBase64());
-}
-inline QString unbase64(QString in)
-{
- return QString::fromUtf8(QByteArray::fromBase64(in.toLatin1()));
-}
-
-inline QString scramble64(QString in)
-{
- return base64(scramble(in));
-}
-inline QString unscramble64(QString in)
-{
- return scramble(unbase64(in));
-}
-
-// StubKeyring implementation
-inline QString generateKey(QString service, QString username)
-{
- return QString("%1/%2").arg(base64(service)).arg(scramble64(username));
-}
-
-bool StubKeyring::storePassword(QString service, QString username, QString password)
-{
- m_settings.setValue(generateKey(service, username), scramble64(password));
- return true;
-}
-
-QString StubKeyring::getPassword(QString service, QString username)
-{
- QString key = generateKey(service, username);
- if (!m_settings.contains(key))
- return QString();
- return unscramble64(m_settings.value(key).toString());
-}
-
-bool StubKeyring::hasPassword(QString service, QString username)
-{
- return m_settings.contains(generateKey(service, username));
-}
-
-QStringList StubKeyring::getStoredAccounts(QString service)
-{
- service = base64(service).append('/');
- QStringList out;
- QStringList in(m_settings.allKeys());
- QStringListIterator it(in);
- while (it.hasNext())
- {
- QString c = it.next();
- if (c.startsWith(service))
- out << unscramble64(c.mid(service.length()));
- }
- return out;
-}
-
-void StubKeyring::removeStoredAccount(QString service, QString username)
-{
- QString key = generateKey(service, username);
- m_settings.remove(key);
-}
-
-// FIXME: this needs tweaking/changes for user account level storage
-StubKeyring::StubKeyring()
- :
- // m_settings(QSettings::UserScope, "Orochimarufan", "Keyring")
- m_settings("keyring.cfg", QSettings::IniFormat)
-{
-}
diff --git a/depends/settings/src/stubkeyring.h b/depends/settings/src/stubkeyring.h
deleted file mode 100644
index 1f4b1be0..00000000
--- a/depends/settings/src/stubkeyring.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Authors: Orochimarufan <orochimarufan.x3@gmail.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include "include/keyring.h"
-
-#include <QSettings>
-
-class StubKeyring : public Keyring
-{
-public:
- /**
- * @brief virtual dtor
- */
- virtual ~StubKeyring() {};
-
- virtual bool storePassword(QString service, QString username, QString password);
- virtual QString getPassword(QString service, QString username);
- virtual bool hasPassword(QString service, QString username);
- virtual QStringList getStoredAccounts(QString service);
- virtual void removeStoredAccount(QString service, QString username);
-
-private:
- friend class Keyring;
- explicit StubKeyring();
- virtual bool isValid()
- {
- return true;
- }
-
- QSettings m_settings;
-};
diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp
index b39db03b..ac66a8d5 100644
--- a/logic/BaseInstance.cpp
+++ b/logic/BaseInstance.cpp
@@ -37,11 +37,11 @@ BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir,
d->m_settings = settings_obj;
d->m_rootDir = rootDir;
- settings().registerSetting(new Setting("name", "Unnamed Instance"));
- settings().registerSetting(new Setting("iconKey", "default"));
+ settings().registerSetting("name", "Unnamed Instance");
+ settings().registerSetting("iconKey", "default");
connect(MMC->icons().get(), SIGNAL(iconUpdated(QString)), SLOT(iconUpdated(QString)));
- settings().registerSetting(new Setting("notes", ""));
- settings().registerSetting(new Setting("lastLaunchTime", 0));
+ settings().registerSetting("notes", "");
+ settings().registerSetting("lastLaunchTime", 0);
/*
* custom base jar has no default. it is determined in code... see the accessor methods for
@@ -50,49 +50,37 @@ BaseInstance::BaseInstance(BaseInstancePrivate *d_in, const QString &rootDir,
* for instances that DO NOT have the CustomBaseJar setting (legacy instances),
* [.]minecraft/bin/mcbackup.jar is the default base jar
*/
- settings().registerSetting(new Setting("UseCustomBaseJar", true));
- settings().registerSetting(new Setting("CustomBaseJar", ""));
+ settings().registerSetting("UseCustomBaseJar", true);
+ settings().registerSetting("CustomBaseJar", "");
auto globalSettings = MMC->settings();
// Java Settings
- settings().registerSetting(new Setting("OverrideJava", false));
- settings().registerSetting(
- new OverrideSetting("JavaPath", globalSettings->getSetting("JavaPath")));
- settings().registerSetting(
- new OverrideSetting("JvmArgs", globalSettings->getSetting("JvmArgs")));
+ settings().registerSetting("OverrideJava", false);
+ settings().registerOverride(globalSettings->getSetting("JavaPath"));
+ settings().registerOverride(globalSettings->getSetting("JvmArgs"));
// Custom Commands
- settings().registerSetting(new Setting("OverrideCommands", false));
- settings().registerSetting(new OverrideSetting(
- "PreLaunchCommand", globalSettings->getSetting("PreLaunchCommand")));
- settings().registerSetting(
- new OverrideSetting("PostExitCommand", globalSettings->getSetting("PostExitCommand")));
+ settings().registerSetting({"OverrideCommands","OverrideLaunchCmd"}, false);
+ settings().registerOverride(globalSettings->getSetting("PreLaunchCommand"));
+ settings().registerOverride(globalSettings->getSetting("PostExitCommand"));
// Window Size
- settings().registerSetting(new Setting("OverrideWindow", false));
- settings().registerSetting(
- new OverrideSetting("LaunchMaximized", globalSettings->getSetting("LaunchMaximized")));
- settings().registerSetting(new OverrideSetting(
- "MinecraftWinWidth", globalSettings->getSetting("MinecraftWinWidth")));
- settings().registerSetting(new OverrideSetting(
- "MinecraftWinHeight", globalSettings->getSetting("MinecraftWinHeight")));
+ settings().registerSetting("OverrideWindow", false);
+ settings().registerOverride(globalSettings->getSetting("LaunchMaximized"));
+ settings().registerOverride(globalSettings->getSetting("MinecraftWinWidth"));
+ settings().registerOverride(globalSettings->getSetting("MinecraftWinHeight"));
// Memory
- settings().registerSetting(new Setting("OverrideMemory", false));
- settings().registerSetting(
- new OverrideSetting("MinMemAlloc", globalSettings->getSetting("MinMemAlloc")));
- settings().registerSetting(
- new OverrideSetting("MaxMemAlloc", globalSettings->getSetting("MaxMemAlloc")));
- settings().registerSetting(
- new OverrideSetting("PermGen", globalSettings->getSetting("PermGen")));
+ settings().registerSetting("OverrideMemory", false);
+ settings().registerOverride(globalSettings->getSetting("MinMemAlloc"));
+ settings().registerOverride(globalSettings->getSetting("MaxMemAlloc"));
+ settings().registerOverride(globalSettings->getSetting("PermGen"));
// Console
- settings().registerSetting(new Setting("OverrideConsole", false));
- settings().registerSetting(
- new OverrideSetting("ShowConsole", globalSettings->getSetting("ShowConsole")));
- settings().registerSetting(new OverrideSetting(
- "AutoCloseConsole", globalSettings->getSetting("AutoCloseConsole")));
+ settings().registerSetting("OverrideConsole", false);
+ settings().registerOverride(globalSettings->getSetting("ShowConsole"));
+ settings().registerOverride(globalSettings->getSetting("AutoCloseConsole"));
}
void BaseInstance::iconUpdated(QString key)
diff --git a/logic/InstanceFactory.cpp b/logic/InstanceFactory.cpp
index 7c778035..1f1a5879 100644
--- a/logic/InstanceFactory.cpp
+++ b/logic/InstanceFactory.cpp
@@ -45,7 +45,7 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
{
auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
- m_settings->registerSetting(new Setting("InstanceType", "Legacy"));
+ m_settings->registerSetting("InstanceType", "Legacy");
QString inst_type = m_settings->get("InstanceType").toString();
@@ -94,7 +94,7 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
return InstanceFactory::NoSuchVersion;
auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
- m_settings->registerSetting(new Setting("InstanceType", "Legacy"));
+ m_settings->registerSetting("InstanceType", "Legacy");
if (type == NormalInst)
{
@@ -171,7 +171,7 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
return InstanceFactory::CantCreateDir;
}
auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
- m_settings->registerSetting(new Setting("InstanceType", "Legacy"));
+ m_settings->registerSetting("InstanceType", "Legacy");
QString inst_type = m_settings->get("InstanceType").toString();
if(inst_type == "OneSixFTB")
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index 08d7c147..0bc0961e 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -37,11 +37,11 @@ LegacyInstance::LegacyInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent)
: BaseInstance(new LegacyInstancePrivate(), rootDir, settings, parent)
{
- settings->registerSetting(new Setting("NeedsRebuild", true));
- settings->registerSetting(new Setting("ShouldUpdate", false));
- settings->registerSetting(new Setting("JarVersion", "Unknown"));
- settings->registerSetting(new Setting("LwjglVersion", "2.9.0"));
- settings->registerSetting(new Setting("IntendedJarVersion", ""));
+ settings->registerSetting("NeedsRebuild", true);
+ settings->registerSetting("ShouldUpdate", false);
+ settings->registerSetting("JarVersion", "Unknown");
+ settings->registerSetting("LwjglVersion", "2.9.0");
+ settings->registerSetting("IntendedJarVersion", "");
}
std::shared_ptr<Task> LegacyInstance::doUpdate(bool only_prepare)
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index fd41b9e5..2392c683 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -33,8 +33,8 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *setting_o
: BaseInstance(new OneSixInstancePrivate(), rootDir, setting_obj, parent)
{
I_D(OneSixInstance);
- d->m_settings->registerSetting(new Setting("IntendedVersion", ""));
- d->m_settings->registerSetting(new Setting("ShouldUpdate", false));
+ d->m_settings->registerSetting("IntendedVersion", "");
+ d->m_settings->registerSetting("ShouldUpdate", false);
reloadFullVersion();
}
diff --git a/logic/icons/IconList.cpp b/logic/icons/IconList.cpp
index 1e692d1d..3a745662 100644
--- a/logic/icons/IconList.cpp
+++ b/logic/icons/IconList.cpp
@@ -42,10 +42,10 @@ IconList::IconList(QObject *parent) : QAbstractListModel(parent)
connect(m_watcher.get(), SIGNAL(directoryChanged(QString)),
SLOT(directoryChanged(QString)));
connect(m_watcher.get(), SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString)));
-
+
auto setting = MMC->settings()->getSetting("IconsDir");
QString path = setting->get().toString();
- connect(setting, SIGNAL(settingChanged(const Setting &, QVariant)),
+ connect(setting.get(), SIGNAL(settingChanged(const Setting &, QVariant)),
SLOT(settingChanged(const Setting &, QVariant)));
directoryChanged(path);
}
@@ -145,7 +145,7 @@ void IconList::fileChanged(const QString &path)
void IconList::settingChanged(const Setting &setting, QVariant value)
{
- if(setting.configKey() != "IconsDir")
+ if(setting.id() != "IconsDir")
return;
directoryChanged(value.toString());