summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-07-27 21:55:49 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-30 07:43:22 -0700
commit181d2cf364f22c5e673916d884ca5f0742e137ce (patch)
tree3fbf7f47b17e193d29d703daaba2af6d1a11a6ac
parentf4f798f8dd43a4da884845af102e0b97dd8409dd (diff)
downloadsubsurface-181d2cf364f22c5e673916d884ca5f0742e137ce.tar.gz
core: activate qPrefProxy
remove Proxy from SettingsObjectWrapper and reference qPrefProxy update files using SettingsObjectWrapper/Proxy to use qPrefProxy this activated qPrefProxy and removed the similar class from SettingsObjectWrapper. Signed-off-by: Jan Iversen <jani@apache.org>
-rw-r--r--core/settings/qPref.cpp2
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.cpp122
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.h41
-rw-r--r--desktop-widgets/preferences/preferences_network.cpp16
-rw-r--r--subsurface-helper.cpp1
-rw-r--r--tests/testpreferences.cpp56
6 files changed, 44 insertions, 194 deletions
diff --git a/core/settings/qPref.cpp b/core/settings/qPref.cpp
index 49851c29a..aae226d30 100644
--- a/core/settings/qPref.cpp
+++ b/core/settings/qPref.cpp
@@ -18,6 +18,8 @@ void qPref::loadSync(bool doSync)
qPrefCloudStorage::instance()->loadSync(doSync);
qPrefDisplay::instance()->loadSync(doSync);
qPrefDiveComputer::instance()->loadSync(doSync);
+ // qPrefFaceook does not use disk.
+ qPrefProxy::instance()->loadSync(doSync);
}
const QString qPref::canonical_version() const
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp
index da2a86a68..296414be3 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.cpp
+++ b/core/subsurface-qt/SettingsObjectWrapper.cpp
@@ -4,7 +4,6 @@
#include <QApplication>
#include <QFont>
#include <QDate>
-#include <QNetworkProxy>
#include "core/qthelper.h"
#include "core/prefs-macros.h"
@@ -716,111 +715,6 @@ void GeocodingPreferences::setThirdTaxonomyCategory(taxonomy_category value)
emit thirdTaxonomyCategoryChanged(value);
}
-ProxySettings::ProxySettings(QObject *parent) :
- QObject(parent)
-{
-}
-
-int ProxySettings::type() const
-{
- return prefs.proxy_type;
-}
-
-QString ProxySettings::host() const
-{
- return prefs.proxy_host;
-}
-
-int ProxySettings::port() const
-{
- return prefs.proxy_port;
-}
-
-bool ProxySettings::auth() const
-{
- return prefs.proxy_auth;
-}
-
-QString ProxySettings::user() const
-{
- return prefs.proxy_user;
-}
-
-QString ProxySettings::pass() const
-{
- return prefs.proxy_pass;
-}
-
-void ProxySettings::setType(int value)
-{
- if (value == prefs.proxy_type)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("proxy_type", value);
- prefs.proxy_type = value;
- emit typeChanged(value);
-}
-
-void ProxySettings::setHost(const QString& value)
-{
- if (value == prefs.proxy_host)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("proxy_host", value);
- free((void *)prefs.proxy_host);
- prefs.proxy_host = copy_qstring(value);
- emit hostChanged(value);
-}
-
-void ProxySettings::setPort(int value)
-{
- if (value == prefs.proxy_port)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("proxy_port", value);
- prefs.proxy_port = value;
- emit portChanged(value);
-}
-
-void ProxySettings::setAuth(bool value)
-{
- if (value == prefs.proxy_auth)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("proxy_auth", value);
- prefs.proxy_auth = value;
- emit authChanged(value);
-}
-
-void ProxySettings::setUser(const QString& value)
-{
- if (value == prefs.proxy_user)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("proxy_user", value);
- free((void *)prefs.proxy_user);
- prefs.proxy_user = copy_qstring(value);
- emit userChanged(value);
-}
-
-void ProxySettings::setPass(const QString& value)
-{
- if (value == prefs.proxy_pass)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("proxy_pass", value);
- free((void *)prefs.proxy_pass);
- prefs.proxy_pass = copy_qstring(value);
- emit passChanged(value);
-}
-
-
DivePlannerSettings::DivePlannerSettings(QObject *parent) :
QObject(parent)
{
@@ -1817,7 +1711,7 @@ QObject(parent),
pp_gas(new PartialPressureGasSettings(this)),
facebook(new qPrefFacebook(this)),
geocoding(new GeocodingPreferences(this)),
- proxy(new ProxySettings(this)),
+ proxy(new qPrefProxy(this)),
cloud_storage(new qPrefCloudStorage(this)),
planner_settings(new DivePlannerSettings(this)),
unit_settings(new UnitsSettings(this)),
@@ -1915,20 +1809,10 @@ void SettingsObjectWrapper::load()
GET_BOOL("auto_recalculate_thumbnails", auto_recalculate_thumbnails);
s.endGroup();
- qPrefDisplay::instance()->load();
-
qPrefAnimations::instance()->load();
-
- s.beginGroup("Network");
- GET_INT_DEF("proxy_type", proxy_type, QNetworkProxy::DefaultProxy);
- GET_TXT("proxy_host", proxy_host);
- GET_INT("proxy_port", proxy_port);
- GET_BOOL("proxy_auth", proxy_auth);
- GET_TXT("proxy_user", proxy_user);
- GET_TXT("proxy_pass", proxy_pass);
- s.endGroup();
-
qPrefCloudStorage::instance()->load();
+ qPrefDisplay::instance()->load();
+ qPrefProxy::instance()->load();
// GeoManagement
s.beginGroup("geocoding");
diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h
index a7957f9f1..5afcfccc4 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.h
+++ b/core/subsurface-qt/SettingsObjectWrapper.h
@@ -229,43 +229,6 @@ private:
const QString group = QStringLiteral("geocoding");
};
-class ProxySettings : public QObject {
- Q_OBJECT
- Q_PROPERTY(int type READ type WRITE setType NOTIFY typeChanged)
- Q_PROPERTY(QString host READ host WRITE setHost NOTIFY hostChanged)
- Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged)
- Q_PROPERTY(bool auth READ auth WRITE setAuth NOTIFY authChanged)
- Q_PROPERTY(QString user READ user WRITE setUser NOTIFY userChanged)
- Q_PROPERTY(QString pass READ pass WRITE setPass NOTIFY passChanged)
-
-public:
- ProxySettings(QObject *parent);
- int type() const;
- QString host() const;
- int port() const;
- bool auth() const;
- QString user() const;
- QString pass() const;
-
-public slots:
- void setType(int value);
- void setHost(const QString& value);
- void setPort(int value);
- void setAuth(bool value);
- void setUser(const QString& value);
- void setPass(const QString& value);
-
-signals:
- void typeChanged(int value);
- void hostChanged(const QString& value);
- void portChanged(int value);
- void authChanged(bool value);
- void userChanged(const QString& value);
- void passChanged(const QString& value);
-private:
- const QString group = QStringLiteral("Network");
-};
-
class DivePlannerSettings : public QObject {
Q_OBJECT
Q_PROPERTY(bool last_stop READ lastStop WRITE setLastStop NOTIFY lastStopChanged)
@@ -560,7 +523,7 @@ class SettingsObjectWrapper : public QObject {
Q_PROPERTY(PartialPressureGasSettings* pp_gas MEMBER pp_gas CONSTANT)
Q_PROPERTY(qPrefFacebook* facebook MEMBER facebook CONSTANT)
Q_PROPERTY(GeocodingPreferences* geocoding MEMBER geocoding CONSTANT)
- Q_PROPERTY(ProxySettings* proxy MEMBER proxy CONSTANT)
+ Q_PROPERTY(qPrefProxy* proxy MEMBER proxy CONSTANT)
Q_PROPERTY(qPrefCloudStorage* cloud_storage MEMBER cloud_storage CONSTANT)
Q_PROPERTY(DivePlannerSettings* planner MEMBER planner_settings CONSTANT)
Q_PROPERTY(UnitsSettings* units MEMBER unit_settings CONSTANT)
@@ -580,7 +543,7 @@ public:
PartialPressureGasSettings *pp_gas;
qPrefFacebook *facebook;
GeocodingPreferences *geocoding;
- ProxySettings *proxy;
+ qPrefProxy *proxy;
qPrefCloudStorage *cloud_storage;
DivePlannerSettings *planner_settings;
UnitsSettings *unit_settings;
diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp
index ba08cea63..bb72bef19 100644
--- a/desktop-widgets/preferences/preferences_network.cpp
+++ b/desktop-widgets/preferences/preferences_network.cpp
@@ -45,18 +45,18 @@ void PreferencesNetwork::refreshSettings()
void PreferencesNetwork::syncSettings()
{
- auto cloud = SettingsObjectWrapper::instance()->cloud_storage;
- auto proxy = SettingsObjectWrapper::instance()->proxy;
+ auto cloud = qPrefCloudStorage::instance();
+ auto proxy = qPrefProxy::instance();
cloud->set_userid(ui->default_uid->text().toUpper());
cloud->set_save_userid_local(ui->save_uid_local->checkState());
- proxy->setType(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
- proxy->setHost(ui->proxyHost->text());
- proxy->setPort(ui->proxyPort->value());
- proxy->setAuth(ui->proxyAuthRequired->isChecked());
- proxy->setUser(ui->proxyUsername->text());
- proxy->setPass(ui->proxyPassword->text());
+ proxy->set_proxy_type(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
+ proxy->set_proxy_host(ui->proxyHost->text());
+ proxy->set_proxy_port(ui->proxyPort->value());
+ proxy->set_proxy_auth(ui->proxyAuthRequired->isChecked());
+ proxy->set_proxy_user(ui->proxyUsername->text());
+ proxy->set_proxy_pass(ui->proxyPassword->text());
QString email = ui->cloud_storage_email->text();
QString password = ui->cloud_storage_password->text();
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp
index ea4aaa8b1..20dd47ec7 100644
--- a/subsurface-helper.cpp
+++ b/subsurface-helper.cpp
@@ -161,6 +161,7 @@ void register_qml_types()
REGISTER_TYPE(qPrefDisplay, "SsrfDisplayPrefs");
REGISTER_TYPE(qPrefDiveComputer, "SsrfDiveComputerPrefs");
REGISTER_TYPE(qPrefFacebook, "SsrfFacebookPrefs");
+ REGISTER_TYPE(qPrefProxy, "SsrfProxyPrefs");
#ifndef SUBSURFACE_TEST_DATA
#ifdef SUBSURFACE_MOBILE
diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp
index c9cef1e37..c82159652 100644
--- a/tests/testpreferences.cpp
+++ b/tests/testpreferences.cpp
@@ -177,34 +177,34 @@ void TestPreferences::testPreferences()
TEST(geo->secondTaxonomyCategory(), TC_COUNTRY);
TEST(geo->thirdTaxonomyCategory(), TC_NONE);
- auto proxy = pref->proxy;
- proxy->setType(2);
- proxy->setPort(80);
- proxy->setAuth(true);
- proxy->setHost("localhost");
- proxy->setUser("unknown");
- proxy->setPass("secret");
-
- TEST(proxy->type(), 2);
- TEST(proxy->port(), 80);
- TEST(proxy->auth(), true);
- TEST(proxy->host(), QStringLiteral("localhost"));
- TEST(proxy->user(), QStringLiteral("unknown"));
- TEST(proxy->pass(), QStringLiteral("secret"));
-
- proxy->setType(3);
- proxy->setPort(8080);
- proxy->setAuth(false);
- proxy->setHost("127.0.0.1");
- proxy->setUser("unknown_1");
- proxy->setPass("secret_1");
-
- TEST(proxy->type(), 3);
- TEST(proxy->port(), 8080);
- TEST(proxy->auth(), false);
- TEST(proxy->host(), QStringLiteral("127.0.0.1"));
- TEST(proxy->user(), QStringLiteral("unknown_1"));
- TEST(proxy->pass(), QStringLiteral("secret_1"));
+ auto proxy = qPrefProxy::instance();
+ proxy->set_proxy_type(2);
+ proxy->set_proxy_port(80);
+ proxy->set_proxy_auth(true);
+ proxy->set_proxy_host("localhost");
+ proxy->set_proxy_user("unknown");
+ proxy->set_proxy_pass("secret");
+
+ TEST(proxy->proxy_type(), 2);
+ TEST(proxy->proxy_port(), 80);
+ TEST(proxy->proxy_auth(), true);
+ TEST(proxy->proxy_host(), QStringLiteral("localhost"));
+ TEST(proxy->proxy_user(), QStringLiteral("unknown"));
+ TEST(proxy->proxy_pass(), QStringLiteral("secret"));
+
+ proxy->set_proxy_type(3);
+ proxy->set_proxy_port(8080);
+ proxy->set_proxy_auth(false);
+ proxy->set_proxy_host("127.0.0.1");
+ proxy->set_proxy_user("unknown_1");
+ proxy->set_proxy_pass("secret_1");
+
+ TEST(proxy->proxy_type(), 3);
+ TEST(proxy->proxy_port(), 8080);
+ TEST(proxy->proxy_auth(), false);
+ TEST(proxy->proxy_host(), QStringLiteral("127.0.0.1"));
+ TEST(proxy->proxy_user(), QStringLiteral("unknown_1"));
+ TEST(proxy->proxy_pass(), QStringLiteral("secret_1"));
auto planner = pref->planner_settings;
planner->setLastStop(true);