diff options
-rw-r--r-- | core/CMakeLists.txt | 1 | ||||
-rw-r--r-- | core/settings/qPref.h | 1 | ||||
-rw-r--r-- | core/settings/qPrefPrivate.h | 1 | ||||
-rw-r--r-- | core/settings/qPrefProxy.cpp | 38 | ||||
-rw-r--r-- | core/settings/qPrefProxy.h | 60 | ||||
-rw-r--r-- | packaging/ios/Subsurface-mobile.pro | 2 |
6 files changed, 103 insertions, 0 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 416c1ea5b..29b6a4446 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -109,6 +109,7 @@ set(SUBSURFACE_CORE_LIB_SRCS settings/qPrefDiveComputer.cpp settings/qPrefFacebook.cpp settings/qPrefPrivate.cpp + settings/qPrefProxy.cpp #Subsurface Qt have the Subsurface structs QObjectified for easy access via QML. subsurface-qt/DiveObjectHelper.cpp diff --git a/core/settings/qPref.h b/core/settings/qPref.h index d3cba3be9..8cd7a2862 100644 --- a/core/settings/qPref.h +++ b/core/settings/qPref.h @@ -10,6 +10,7 @@ #include "qPrefDisplay.h" #include "qPrefDiveComputer.h" #include "qPrefFacebook.h" +#include "qPrefProxy.h" class qPref : public QObject { Q_OBJECT diff --git a/core/settings/qPrefPrivate.h b/core/settings/qPrefPrivate.h index e68c5cbd8..881c53fc6 100644 --- a/core/settings/qPrefPrivate.h +++ b/core/settings/qPrefPrivate.h @@ -19,6 +19,7 @@ public: friend class qPrefDisplay; friend class qPrefDiveComputer; friend class qPrefFacebook; + friend class qPrefProxy; private: static qPrefPrivate *instance(); diff --git a/core/settings/qPrefProxy.cpp b/core/settings/qPrefProxy.cpp new file mode 100644 index 000000000..540d64dde --- /dev/null +++ b/core/settings/qPrefProxy.cpp @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "qPref.h" +#include "qPrefPrivate.h" + +#include <QNetworkProxy> + +static const QString group = QStringLiteral("Network"); + +qPrefProxy::qPrefProxy(QObject *parent) : QObject(parent) +{ +} +qPrefProxy *qPrefProxy::instance() +{ + static qPrefProxy *self = new qPrefProxy; + return self; +} + +void qPrefProxy::loadSync(bool doSync) +{ + disk_proxy_auth(doSync); + disk_proxy_host(doSync); + disk_proxy_pass(doSync); + disk_proxy_port(doSync); + disk_proxy_type(doSync); + disk_proxy_user(doSync); +} + +HANDLE_PREFERENCE_BOOL(Proxy, "/proxy_auth", proxy_auth); + +HANDLE_PREFERENCE_TXT(Proxy, "/proxy_host", proxy_host); + +HANDLE_PREFERENCE_TXT(Proxy, "/proxy_pass", proxy_pass); + +HANDLE_PREFERENCE_INT(Proxy, "/proxy_port", proxy_port); + +HANDLE_PREFERENCE_INT_DEF(Proxy, "/proxy_type", proxy_type, QNetworkProxy::DefaultProxy); + +HANDLE_PREFERENCE_TXT(Proxy, "/proxy_user", proxy_user); 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 diff --git a/packaging/ios/Subsurface-mobile.pro b/packaging/ios/Subsurface-mobile.pro index 9a98470d8..c286c34e7 100644 --- a/packaging/ios/Subsurface-mobile.pro +++ b/packaging/ios/Subsurface-mobile.pro @@ -84,6 +84,7 @@ SOURCES += ../../subsurface-mobile-main.cpp \ ../../core/settings/qPrefDiveComputer.cpp \ ../../core/settings/qPrefFacebook.cpp \ ../../core/settings/qPrefPrivate.cpp \ + ../../core/settings/qPrefProxy.cpp \ ../../core/subsurface-qt/CylinderObjectHelper.cpp \ ../../core/subsurface-qt/DiveObjectHelper.cpp \ ../../core/subsurface-qt/SettingsObjectWrapper.cpp \ @@ -197,6 +198,7 @@ HEADERS += \ ../../core/settings/qPrefDiveComputer.h \ ../../core/settings/qPrefFacebook.h \ ../../core/settings/qPrefPrivate.h \ + ../../core/settings/qPrefProxy.h \ ../../core/subsurface-qt/CylinderObjectHelper.h \ ../../core/subsurface-qt/DiveObjectHelper.h \ ../../core/subsurface-qt/SettingsObjectWrapper.h \ |