summaryrefslogtreecommitdiffstats
path: root/depends/settings
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-03-09 08:43:08 +0100
committerJan Dalheimer <jan@dalheimer.de>2014-03-09 08:43:08 +0100
commitf1dc4568020d222803d54fdcece324a14c9266c7 (patch)
tree52b7e5d8342eba1d1c6d9751f2f8a5124833725a /depends/settings
parent44f21406e91c68b230d38441b950eb7c3d6a8ec5 (diff)
downloadMultiMC-f1dc4568020d222803d54fdcece324a14c9266c7.tar
MultiMC-f1dc4568020d222803d54fdcece324a14c9266c7.tar.gz
MultiMC-f1dc4568020d222803d54fdcece324a14c9266c7.tar.lz
MultiMC-f1dc4568020d222803d54fdcece324a14c9266c7.tar.xz
MultiMC-f1dc4568020d222803d54fdcece324a14c9266c7.zip
Also reload the instance cfg
While this should work, there don't seem to be any places where the signals are listened for, so changes probably will only be available when calling Setting::get TODO: Fix that ^
Diffstat (limited to 'depends/settings')
-rw-r--r--depends/settings/inisettingsobject.cpp5
-rw-r--r--depends/settings/inisettingsobject.h2
-rw-r--r--depends/settings/settingsobject.cpp9
-rw-r--r--depends/settings/settingsobject.h6
4 files changed, 22 insertions, 0 deletions
diff --git a/depends/settings/inisettingsobject.cpp b/depends/settings/inisettingsobject.cpp
index 5e52a56f..2cee8e3c 100644
--- a/depends/settings/inisettingsobject.cpp
+++ b/depends/settings/inisettingsobject.cpp
@@ -28,6 +28,11 @@ void INISettingsObject::setFilePath(const QString &filePath)
m_filePath = filePath;
}
+bool INISettingsObject::reload()
+{
+ return m_ini.loadFile(m_filePath) && SettingsObject::reload();
+}
+
void INISettingsObject::changeSetting(const Setting &setting, QVariant value)
{
if (contains(setting.id()))
diff --git a/depends/settings/inisettingsobject.h b/depends/settings/inisettingsobject.h
index 8badc0c6..12370896 100644
--- a/depends/settings/inisettingsobject.h
+++ b/depends/settings/inisettingsobject.h
@@ -47,6 +47,8 @@ public:
*/
virtual void setFilePath(const QString &filePath);
+ bool reload() override;
+
protected
slots:
virtual void changeSetting(const Setting &setting, QVariant value);
diff --git a/depends/settings/settingsobject.cpp b/depends/settings/settingsobject.cpp
index 43fc989a..0e3030df 100644
--- a/depends/settings/settingsobject.cpp
+++ b/depends/settings/settingsobject.cpp
@@ -126,6 +126,15 @@ bool SettingsObject::contains(const QString &id)
return m_settings.contains(id);
}
+bool SettingsObject::reload()
+{
+ for (auto setting : m_settings.values())
+ {
+ setting->set(setting->get());
+ }
+ return true;
+}
+
void SettingsObject::connectSignals(const Setting &setting)
{
connect(&setting, SIGNAL(settingChanged(const Setting &, QVariant)),
diff --git a/depends/settings/settingsobject.h b/depends/settings/settingsobject.h
index 27746f2d..b1b26b09 100644
--- a/depends/settings/settingsobject.h
+++ b/depends/settings/settingsobject.h
@@ -113,6 +113,12 @@ public:
*/
bool contains(const QString &id);
+ /*!
+ * \brief Reloads the settings and emit signals for changed settings
+ * \return True if reloading was successful
+ */
+ virtual bool reload();
+
signals:
/*!
* \brief Signal emitted when one of this SettingsObject object's settings changes.