diff options
-rw-r--r-- | networksettings.cpp | 10 | ||||
-rw-r--r-- | networksettings.h | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/networksettings.cpp b/networksettings.cpp index 6b023bd5..48bd09f3 100644 --- a/networksettings.cpp +++ b/networksettings.cpp @@ -20,6 +20,12 @@ using namespace QMatrixClient; -QMC_DEFINE_SETTING(NetworkSettings, QNetworkProxy::ProxyType, proxyType, "proxy_type", QNetworkProxy::NoProxy, setProxyType) +void NetworkSettings::setupApplicationProxy() const +{ + QNetworkProxy::setApplicationProxy( + { proxyType(), proxyHostName(), proxyPort() }); +} + +QMC_DEFINE_SETTING(NetworkSettings, QNetworkProxy::ProxyType, proxyType, "proxy_type", QNetworkProxy::DefaultProxy, setProxyType) QMC_DEFINE_SETTING(NetworkSettings, QString, proxyHostName, "proxy_hostname", "", setProxyHostName) -QMC_DEFINE_SETTING(NetworkSettings, int, proxyPort, "proxy_port", -1, setProxyPort) +QMC_DEFINE_SETTING(NetworkSettings, quint16, proxyPort, "proxy_port", -1, setProxyPort) diff --git a/networksettings.h b/networksettings.h index e113cd9b..83613060 100644 --- a/networksettings.h +++ b/networksettings.h @@ -30,7 +30,7 @@ namespace QMatrixClient { Q_OBJECT QMC_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType) QMC_DECLARE_SETTING(QString, proxyHostName, setProxyHostName) - QMC_DECLARE_SETTING(int, proxyPort, setProxyPort) + QMC_DECLARE_SETTING(quint16, proxyPort, setProxyPort) Q_PROPERTY(QString proxyHost READ proxyHostName WRITE setProxyHostName) public: template <typename... ArgTs> @@ -38,5 +38,7 @@ namespace QMatrixClient { : SettingsGroup(QStringLiteral("Network"), qsettingsArgs...) { } ~NetworkSettings() override = default; + + Q_INVOKABLE void setupApplicationProxy() const; }; } |