aboutsummaryrefslogtreecommitdiff
path: root/launcher/settings/SettingsObject.h
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/settings/SettingsObject.h')
-rw-r--r--launcher/settings/SettingsObject.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/launcher/settings/SettingsObject.h b/launcher/settings/SettingsObject.h
index 6200bc3a..ff430172 100644
--- a/launcher/settings/SettingsObject.h
+++ b/launcher/settings/SettingsObject.h
@@ -19,6 +19,8 @@
#include <QMap>
#include <QStringList>
#include <QVariant>
+#include <QJsonDocument>
+#include <QJsonArray>
#include <memory>
class Setting;
@@ -143,6 +145,45 @@ public:
bool contains(const QString &id);
/*!
+ * \brief Sets the value of the setting with the given ID with a json list.
+ * If no setting with the given ID exists, returns false
+ * \param id The ID of the setting to change.
+ * \param value The new value of the setting.
+ */
+ bool setList(const QString &id, QVariantList value);
+ template <typename T> bool setList(const QString &id, QList<T> val)
+ {
+ QVariantList variantList;
+ variantList.reserve(val.size());
+ for (const T& v : val)
+ {
+ variantList.append(v);
+ }
+
+ return setList(id, variantList);
+ }
+
+ /**
+ * \brief Gets the value of the setting with the given ID as if it were a json list.
+ * \param id The ID of the setting to change.
+ * \return The setting's value as a QVariantList.
+ * If no setting with the given ID exists, returns an empty QVariantList.
+ */
+ QVariantList getList(const QString &id);
+ template <typename T> QList<T> getList(const QString &id)
+ {
+ QVariantList variantList = this->getList(id);
+
+ QList<T>TList;
+ TList.reserve(variantList.size());
+ for (const QVariant& v : variantList)
+ {
+ TList.append(v.value<T>());
+ }
+ return TList;
+ }
+
+ /*!
* \brief Reloads the settings and emit signals for changed settings
* \return True if reloading was successful
*/