summaryrefslogtreecommitdiffstats
path: root/core/settings/qPrefProxy.h
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-07-27 10:25:43 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-30 07:43:22 -0700
commitf4f798f8dd43a4da884845af102e0b97dd8409dd (patch)
tree88582f21c1b01b249d31fc9405379db41953c3d6 /core/settings/qPrefProxy.h
parentc696c7941df1b083e41fbf72376a0f8f82b9652b (diff)
downloadsubsurface-f4f798f8dd43a4da884845af102e0b97dd8409dd.tar.gz
core: create qPrefProxy from SettingsObjectWrapper
Update set/get functions to follow common name scheme: - get function have same name as in struct prefs - 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/qPrefProxy.h')
-rw-r--r--core/settings/qPrefProxy.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/core/settings/qPrefProxy.h b/core/settings/qPrefProxy.h
new file mode 100644
index 000000000..e7cd209fa
--- /dev/null
+++ b/core/settings/qPrefProxy.h
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef QPREFPROXY_H
+#define QPREFPROXY_H
+#include "core/pref.h"
+
+#include <QObject>
+
+
+class qPrefProxy : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool proxy_auth READ proxy_auth WRITE set_proxy_auth NOTIFY proxy_auth_changed);
+ Q_PROPERTY(QString proxy_host READ proxy_host WRITE set_proxy_host NOTIFY proxy_host_changed);
+ Q_PROPERTY(QString proxy_pass READ proxy_pass WRITE set_proxy_pass NOTIFY proxy_pass_changed);
+ Q_PROPERTY(int proxy_port READ proxy_port WRITE set_proxy_port NOTIFY proxy_port_changed);
+ Q_PROPERTY(int proxy_type READ proxy_type WRITE set_proxy_type NOTIFY proxy_type_changed);
+ Q_PROPERTY(QString proxy_user READ proxy_user WRITE set_proxy_user NOTIFY proxy_user_changed);
+
+public:
+ qPrefProxy(QObject *parent = NULL);
+ static qPrefProxy *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 bool proxy_auth() { return prefs.proxy_auth; }
+ static inline QString proxy_host() { return prefs.proxy_host; }
+ static inline QString proxy_pass() { return prefs.proxy_pass; }
+ static inline int proxy_port() { return prefs.proxy_port; }
+ static inline int proxy_type() { return prefs.proxy_type; }
+ static inline QString proxy_user() { return prefs.proxy_user; }
+
+public slots:
+ void set_proxy_auth(bool value);
+ void set_proxy_host(const QString &value);
+ void set_proxy_pass(const QString &value);
+ void set_proxy_port(int value);
+ void set_proxy_type(int value);
+ void set_proxy_user(const QString &value);
+
+signals:
+ void proxy_auth_changed(bool value);
+ void proxy_host_changed(const QString &value);
+ void proxy_pass_changed(const QString &value);
+ void proxy_port_changed(int value);
+ void proxy_type_changed(int value);
+ void proxy_user_changed(const QString &value);
+
+private:
+ void disk_proxy_auth(bool doSync);
+ void disk_proxy_host(bool doSync);
+ void disk_proxy_pass(bool doSync);
+ void disk_proxy_port(bool doSync);
+ void disk_proxy_type(bool doSync);
+ void disk_proxy_user(bool doSync);
+};
+
+#endif