mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
f4f798f8dd
commit
181d2cf364
6 changed files with 41 additions and 191 deletions
|
@ -18,6 +18,8 @@ void qPref::loadSync(bool doSync)
|
||||||
qPrefCloudStorage::instance()->loadSync(doSync);
|
qPrefCloudStorage::instance()->loadSync(doSync);
|
||||||
qPrefDisplay::instance()->loadSync(doSync);
|
qPrefDisplay::instance()->loadSync(doSync);
|
||||||
qPrefDiveComputer::instance()->loadSync(doSync);
|
qPrefDiveComputer::instance()->loadSync(doSync);
|
||||||
|
// qPrefFaceook does not use disk.
|
||||||
|
qPrefProxy::instance()->loadSync(doSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString qPref::canonical_version() const
|
const QString qPref::canonical_version() const
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QNetworkProxy>
|
|
||||||
|
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/prefs-macros.h"
|
#include "core/prefs-macros.h"
|
||||||
|
@ -716,111 +715,6 @@ void GeocodingPreferences::setThirdTaxonomyCategory(taxonomy_category value)
|
||||||
emit thirdTaxonomyCategoryChanged(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) :
|
DivePlannerSettings::DivePlannerSettings(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
|
@ -1817,7 +1711,7 @@ QObject(parent),
|
||||||
pp_gas(new PartialPressureGasSettings(this)),
|
pp_gas(new PartialPressureGasSettings(this)),
|
||||||
facebook(new qPrefFacebook(this)),
|
facebook(new qPrefFacebook(this)),
|
||||||
geocoding(new GeocodingPreferences(this)),
|
geocoding(new GeocodingPreferences(this)),
|
||||||
proxy(new ProxySettings(this)),
|
proxy(new qPrefProxy(this)),
|
||||||
cloud_storage(new qPrefCloudStorage(this)),
|
cloud_storage(new qPrefCloudStorage(this)),
|
||||||
planner_settings(new DivePlannerSettings(this)),
|
planner_settings(new DivePlannerSettings(this)),
|
||||||
unit_settings(new UnitsSettings(this)),
|
unit_settings(new UnitsSettings(this)),
|
||||||
|
@ -1915,20 +1809,10 @@ void SettingsObjectWrapper::load()
|
||||||
GET_BOOL("auto_recalculate_thumbnails", auto_recalculate_thumbnails);
|
GET_BOOL("auto_recalculate_thumbnails", auto_recalculate_thumbnails);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
qPrefDisplay::instance()->load();
|
|
||||||
|
|
||||||
qPrefAnimations::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();
|
qPrefCloudStorage::instance()->load();
|
||||||
|
qPrefDisplay::instance()->load();
|
||||||
|
qPrefProxy::instance()->load();
|
||||||
|
|
||||||
// GeoManagement
|
// GeoManagement
|
||||||
s.beginGroup("geocoding");
|
s.beginGroup("geocoding");
|
||||||
|
|
|
@ -229,43 +229,6 @@ private:
|
||||||
const QString group = QStringLiteral("geocoding");
|
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 {
|
class DivePlannerSettings : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool last_stop READ lastStop WRITE setLastStop NOTIFY lastStopChanged)
|
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(PartialPressureGasSettings* pp_gas MEMBER pp_gas CONSTANT)
|
||||||
Q_PROPERTY(qPrefFacebook* facebook MEMBER facebook CONSTANT)
|
Q_PROPERTY(qPrefFacebook* facebook MEMBER facebook CONSTANT)
|
||||||
Q_PROPERTY(GeocodingPreferences* geocoding MEMBER geocoding 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(qPrefCloudStorage* cloud_storage MEMBER cloud_storage CONSTANT)
|
||||||
Q_PROPERTY(DivePlannerSettings* planner MEMBER planner_settings CONSTANT)
|
Q_PROPERTY(DivePlannerSettings* planner MEMBER planner_settings CONSTANT)
|
||||||
Q_PROPERTY(UnitsSettings* units MEMBER unit_settings CONSTANT)
|
Q_PROPERTY(UnitsSettings* units MEMBER unit_settings CONSTANT)
|
||||||
|
@ -580,7 +543,7 @@ public:
|
||||||
PartialPressureGasSettings *pp_gas;
|
PartialPressureGasSettings *pp_gas;
|
||||||
qPrefFacebook *facebook;
|
qPrefFacebook *facebook;
|
||||||
GeocodingPreferences *geocoding;
|
GeocodingPreferences *geocoding;
|
||||||
ProxySettings *proxy;
|
qPrefProxy *proxy;
|
||||||
qPrefCloudStorage *cloud_storage;
|
qPrefCloudStorage *cloud_storage;
|
||||||
DivePlannerSettings *planner_settings;
|
DivePlannerSettings *planner_settings;
|
||||||
UnitsSettings *unit_settings;
|
UnitsSettings *unit_settings;
|
||||||
|
|
|
@ -45,18 +45,18 @@ void PreferencesNetwork::refreshSettings()
|
||||||
|
|
||||||
void PreferencesNetwork::syncSettings()
|
void PreferencesNetwork::syncSettings()
|
||||||
{
|
{
|
||||||
auto cloud = SettingsObjectWrapper::instance()->cloud_storage;
|
auto cloud = qPrefCloudStorage::instance();
|
||||||
auto proxy = SettingsObjectWrapper::instance()->proxy;
|
auto proxy = qPrefProxy::instance();
|
||||||
|
|
||||||
cloud->set_userid(ui->default_uid->text().toUpper());
|
cloud->set_userid(ui->default_uid->text().toUpper());
|
||||||
cloud->set_save_userid_local(ui->save_uid_local->checkState());
|
cloud->set_save_userid_local(ui->save_uid_local->checkState());
|
||||||
|
|
||||||
proxy->setType(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
|
proxy->set_proxy_type(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
|
||||||
proxy->setHost(ui->proxyHost->text());
|
proxy->set_proxy_host(ui->proxyHost->text());
|
||||||
proxy->setPort(ui->proxyPort->value());
|
proxy->set_proxy_port(ui->proxyPort->value());
|
||||||
proxy->setAuth(ui->proxyAuthRequired->isChecked());
|
proxy->set_proxy_auth(ui->proxyAuthRequired->isChecked());
|
||||||
proxy->setUser(ui->proxyUsername->text());
|
proxy->set_proxy_user(ui->proxyUsername->text());
|
||||||
proxy->setPass(ui->proxyPassword->text());
|
proxy->set_proxy_pass(ui->proxyPassword->text());
|
||||||
|
|
||||||
QString email = ui->cloud_storage_email->text();
|
QString email = ui->cloud_storage_email->text();
|
||||||
QString password = ui->cloud_storage_password->text();
|
QString password = ui->cloud_storage_password->text();
|
||||||
|
|
|
@ -161,6 +161,7 @@ void register_qml_types()
|
||||||
REGISTER_TYPE(qPrefDisplay, "SsrfDisplayPrefs");
|
REGISTER_TYPE(qPrefDisplay, "SsrfDisplayPrefs");
|
||||||
REGISTER_TYPE(qPrefDiveComputer, "SsrfDiveComputerPrefs");
|
REGISTER_TYPE(qPrefDiveComputer, "SsrfDiveComputerPrefs");
|
||||||
REGISTER_TYPE(qPrefFacebook, "SsrfFacebookPrefs");
|
REGISTER_TYPE(qPrefFacebook, "SsrfFacebookPrefs");
|
||||||
|
REGISTER_TYPE(qPrefProxy, "SsrfProxyPrefs");
|
||||||
|
|
||||||
#ifndef SUBSURFACE_TEST_DATA
|
#ifndef SUBSURFACE_TEST_DATA
|
||||||
#ifdef SUBSURFACE_MOBILE
|
#ifdef SUBSURFACE_MOBILE
|
||||||
|
|
|
@ -177,34 +177,34 @@ void TestPreferences::testPreferences()
|
||||||
TEST(geo->secondTaxonomyCategory(), TC_COUNTRY);
|
TEST(geo->secondTaxonomyCategory(), TC_COUNTRY);
|
||||||
TEST(geo->thirdTaxonomyCategory(), TC_NONE);
|
TEST(geo->thirdTaxonomyCategory(), TC_NONE);
|
||||||
|
|
||||||
auto proxy = pref->proxy;
|
auto proxy = qPrefProxy::instance();
|
||||||
proxy->setType(2);
|
proxy->set_proxy_type(2);
|
||||||
proxy->setPort(80);
|
proxy->set_proxy_port(80);
|
||||||
proxy->setAuth(true);
|
proxy->set_proxy_auth(true);
|
||||||
proxy->setHost("localhost");
|
proxy->set_proxy_host("localhost");
|
||||||
proxy->setUser("unknown");
|
proxy->set_proxy_user("unknown");
|
||||||
proxy->setPass("secret");
|
proxy->set_proxy_pass("secret");
|
||||||
|
|
||||||
TEST(proxy->type(), 2);
|
TEST(proxy->proxy_type(), 2);
|
||||||
TEST(proxy->port(), 80);
|
TEST(proxy->proxy_port(), 80);
|
||||||
TEST(proxy->auth(), true);
|
TEST(proxy->proxy_auth(), true);
|
||||||
TEST(proxy->host(), QStringLiteral("localhost"));
|
TEST(proxy->proxy_host(), QStringLiteral("localhost"));
|
||||||
TEST(proxy->user(), QStringLiteral("unknown"));
|
TEST(proxy->proxy_user(), QStringLiteral("unknown"));
|
||||||
TEST(proxy->pass(), QStringLiteral("secret"));
|
TEST(proxy->proxy_pass(), QStringLiteral("secret"));
|
||||||
|
|
||||||
proxy->setType(3);
|
proxy->set_proxy_type(3);
|
||||||
proxy->setPort(8080);
|
proxy->set_proxy_port(8080);
|
||||||
proxy->setAuth(false);
|
proxy->set_proxy_auth(false);
|
||||||
proxy->setHost("127.0.0.1");
|
proxy->set_proxy_host("127.0.0.1");
|
||||||
proxy->setUser("unknown_1");
|
proxy->set_proxy_user("unknown_1");
|
||||||
proxy->setPass("secret_1");
|
proxy->set_proxy_pass("secret_1");
|
||||||
|
|
||||||
TEST(proxy->type(), 3);
|
TEST(proxy->proxy_type(), 3);
|
||||||
TEST(proxy->port(), 8080);
|
TEST(proxy->proxy_port(), 8080);
|
||||||
TEST(proxy->auth(), false);
|
TEST(proxy->proxy_auth(), false);
|
||||||
TEST(proxy->host(), QStringLiteral("127.0.0.1"));
|
TEST(proxy->proxy_host(), QStringLiteral("127.0.0.1"));
|
||||||
TEST(proxy->user(), QStringLiteral("unknown_1"));
|
TEST(proxy->proxy_user(), QStringLiteral("unknown_1"));
|
||||||
TEST(proxy->pass(), QStringLiteral("secret_1"));
|
TEST(proxy->proxy_pass(), QStringLiteral("secret_1"));
|
||||||
|
|
||||||
auto planner = pref->planner_settings;
|
auto planner = pref->planner_settings;
|
||||||
planner->setLastStop(true);
|
planner->setLastStop(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue