aboutsummaryrefslogtreecommitdiffstats
path: root/core/settings/qPrefFacebook.h
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-07-23 15:10:40 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-27 12:36:20 -0700
commite0f1817fdc3b0024c5e97cfa0db048384aae6d78 (patch)
tree358c902fef4bd151cf57bf44ca97662ff9c82cdd /core/settings/qPrefFacebook.h
parent75661186d37ac48201cce4e89973658b440aeb72 (diff)
downloadsubsurface-e0f1817fdc3b0024c5e97cfa0db048384aae6d78.tar.gz
core: create qPrefFacebook from SettingsObjectWrapper
Update set/get functions to follow common name scheme: - get function have same name as in struct diveComputer - set function have set_<name> - signal function have <name>_changed one class one .h/.cpp is the C++ idiom. Having load/sync of each variable in 1 functions (in contrast to the distributed way SettingsObjectWrapper handles it) secures the same storage name is used. Having the set/get/load/sync functions grouped together makes it easier to get an overview. REMARK: this commit only defines the class, it is not active in production Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'core/settings/qPrefFacebook.h')
-rw-r--r--core/settings/qPrefFacebook.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/core/settings/qPrefFacebook.h b/core/settings/qPrefFacebook.h
new file mode 100644
index 000000000..dc6efcbdb
--- /dev/null
+++ b/core/settings/qPrefFacebook.h
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef QPREFSFACEBOOK_H
+#define QPREFSFACEBOOK_H
+#include "core/pref.h"
+
+#include <QObject>
+
+
+class qPrefFacebook : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString access_token READ access_token WRITE set_access_token NOTIFY access_token_changed);
+ Q_PROPERTY(QString album_id READ album_id WRITE set_album_id NOTIFY album_id_changed);
+ Q_PROPERTY(QString user_id READ user_id WRITE set_user_id NOTIFY user_id_changed);
+
+public:
+ qPrefFacebook(QObject *parent = NULL);
+ static qPrefFacebook *instance();
+
+ // Load/Sync local settings (disk) and struct preference
+ void loadSync(bool doSync);
+ void inline load() {loadSync(false); }
+ void inline sync() {loadSync(true); }
+
+public:
+ static inline QString access_token() { return prefs.facebook.access_token; }
+ static inline QString album_id() { return prefs.facebook.album_id; }
+ static inline QString user_id() { return prefs.facebook.user_id; }
+
+public slots:
+ void set_access_token(const QString& value);
+ void set_album_id(const QString& value);
+ void set_user_id(const QString& value);
+
+signals:
+ void access_token_changed(const QString& value);
+ void album_id_changed(const QString& value);
+ void user_id_changed(const QString& value);
+
+private:
+ void disk_access_token(bool doSync);
+ void disk_album_id(bool doSync);
+ void disk_user_id(bool doSync);
+};
+
+#endif