return mSettings.value(PROXY_PORT_SETTING).toUInt();
}
-//QNetworkProxy::ProxyType
-int AppSettings::proxyType()
+QNetworkProxy::ProxyType AppSettings::proxyType()
{
- return mSettings.value(PROXY_TYPE_SETTING).toInt();
+ bool ok;
+ int proxyType = mSettings.value(PROXY_TYPE_SETTING).toInt(&ok);
+ if (!ok || proxyType < 0 || proxyType > 5) return QNetworkProxy::DefaultProxy;
+ return QNetworkProxy::ProxyType(proxyType);
}
bool AppSettings::isDirectConnection()
mSettings.setValue(PROXY_PORT_SETTING, aPort);
}
-// QNetworkProxy::ProxyType
-void AppSettings::setProxyType(const int aType)
+void AppSettings::setProxyType(QNetworkProxy::ProxyType aProxyType)
{
- mSettings.setValue(PROXY_TYPE_SETTING, aType);
+ mSettings.setValue(PROXY_TYPE_SETTING, aProxyType);
}
void AppSettings::setDirectConnection(bool aDirectConnection)
static QString proxyAddress();
static quint16 proxyPort();
- static int proxyType(); // QNetworkProxy::ProxyType
+ static QNetworkProxy::ProxyType proxyType();
static bool isDirectConnection();
static void setProxyAddress(const QString &aAddress);
static void setProxyPort(const quint16 aPort);
- static void setProxyType(const int aProxyType); // QNetworkProxy::ProxyType
+ static void setProxyType(QNetworkProxy::ProxyType aProxyType);
static void setDirectConnection(bool aDirectConnection);
static int preEventAlarmSec() {return 60*15;} ///< seconds that alarm should ring before an event starts
};
// deserialize dialog data
address->setText(AppSettings::proxyAddress());
port->setValue(AppSettings::proxyPort());
- const int proxyType = AppSettings::proxyType(); // QNetworkProxy::ProxyType
- proxyTypeHTTP->setChecked(proxyType != 1); // HTTP=3, but we enable it by default, i.e. unless SOCKS5=1
- proxyTypeSOCKS5->setChecked(proxyType == 1);
+ const QNetworkProxy::ProxyType proxyType = AppSettings::proxyType();
+ proxyTypeHTTP->setChecked(proxyType != QNetworkProxy::Socks5Proxy); // we enable it by default unless SOCKS5=1
+ proxyTypeSOCKS5->setChecked(proxyType == QNetworkProxy::Socks5Proxy);
directConnection->setChecked(AppSettings::isDirectConnection());
proxyWidget->setDisabled(directConnection->isChecked());
}
// serialize dialog data
AppSettings::setProxyAddress(address->text());
AppSettings::setProxyPort(port->value());
- AppSettings::setProxyType(proxyTypeHTTP->isChecked() ? 3 : proxyTypeSOCKS5->isChecked() ? 1 : 0);
+ AppSettings::setProxyType(proxyTypeHTTP->isChecked() ? QNetworkProxy::HttpProxy : proxyTypeSOCKS5->isChecked() ? QNetworkProxy::Socks5Proxy : QNetworkProxy::DefaultProxy);
AppSettings::setDirectConnection(directConnection->isChecked());
}