aboutsummaryrefslogtreecommitdiffstats
path: root/src/settings_interface.h
diff options
context:
space:
mode:
authorConfuSomu2023-08-15 19:42:18 -0400
committerConfuSomu2023-08-15 19:42:18 -0400
commitade98b4cf6630635e2fdbf84ac29fe83a79cc371 (patch)
tree1297fa1f808baa949e14276c80b536f61fcd76cb /src/settings_interface.h
parent82dc68463c625fcf36155dbccfb264ac2171a386 (diff)
downloadActorViewer-ade98b4cf6630635e2fdbf84ac29fe83a79cc371.tar
ActorViewer-ade98b4cf6630635e2fdbf84ac29fe83a79cc371.tar.gz
ActorViewer-ade98b4cf6630635e2fdbf84ac29fe83a79cc371.zip
Implement settings dialog
Diffstat (limited to 'src/settings_interface.h')
-rw-r--r--src/settings_interface.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/settings_interface.h b/src/settings_interface.h
new file mode 100644
index 0000000..e3935d0
--- /dev/null
+++ b/src/settings_interface.h
@@ -0,0 +1,46 @@
+#pragma once
+
+#include <QString>
+#include <QVariant>
+#include <QSettings>
+
+/* struct AppSettings {
+ enum {LOCALTIME, UTC} ui_timezone = LOCALTIME;
+ bool can_access_internet = true;
+ bool can_download_emoji = true;
+ bool can_download_attachments = true;
+ struct {
+ enum {MASTODON} type = MASTODON;
+ QString address;
+ QString token;
+ } instance;
+}; */
+
+namespace AppSettingsTypes {
+ enum Timezone {LOCALTIME = 0, UTC};
+ enum InstanceType {MASTODON = 0};
+}
+// Declare metatypes for use with QVariant
+Q_DECLARE_METATYPE(AppSettingsTypes::Timezone);
+Q_DECLARE_METATYPE(AppSettingsTypes::InstanceType);
+
+class SettingsInterface {
+public:
+ ~SettingsInterface();
+ const QVariant read_setting(const QString &key);
+ void write_setting(const QString &key, const QVariant &value);
+ void clear_setting(const QString &key);
+ void clear_all();
+ bool commit();
+ bool is_default(const QString &key);
+ bool is_uncommited(const QString &key);
+
+private:
+ QSettings qt_settings;
+ QHash<QString, QVariant>* modified = nullptr;
+
+ // Optimization to commit a clear_all() faster
+ bool must_clear_all = false;
+ // List of keys to remove from the QSettings
+ QStringList must_clear;
+};