summaryrefslogtreecommitdiffstats
path: root/qt-ui/preferences.cpp
diff options
context:
space:
mode:
authorGravatar Sergey Starosek <sergey.starosek@gmail.com>2014-06-26 16:45:14 +0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-26 15:44:13 -0700
commitb5e90d7c9330d359bef3d6ec72fc3831faa970ed (patch)
treed081dc0e2635f8345e3d121b75fb5aa6c82c6b00 /qt-ui/preferences.cpp
parent1dd79d412fb54fd27211eceb3e1a87baeb5be505 (diff)
downloadsubsurface-b5e90d7c9330d359bef3d6ec72fc3831faa970ed.tar.gz
UI setup for "Network settings" page
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/preferences.cpp')
-rw-r--r--qt-ui/preferences.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index fe4c87247..d0880d6fb 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -6,6 +6,7 @@
#include <QMessageBox>
#include <QSortFilterProxyModel>
#include <QShortcut>
+#include <QNetworkProxy>
PreferencesDialog *PreferencesDialog::instance()
{
@@ -18,6 +19,12 @@ PreferencesDialog *PreferencesDialog::instance()
PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
{
ui.setupUi(this);
+ ui.proxyType->clear();
+ ui.proxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy);
+ ui.proxyType->addItem(tr("System proxy"), QNetworkProxy::DefaultProxy);
+ ui.proxyType->addItem(tr("HTTP proxy"), QNetworkProxy::HttpProxy);
+ ui.proxyType->addItem(tr("SOCKS proxy"), QNetworkProxy::Socks5Proxy);
+ connect(ui.proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(on_proxyType_changed(int)));
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
connect(ui.gflow, SIGNAL(valueChanged(int)), this, SLOT(gflowChanged(int)));
connect(ui.gfhigh, SIGNAL(valueChanged(int)), this, SLOT(gfhighChanged(int)));
@@ -378,3 +385,19 @@ void PreferencesDialog::emitSettingsChanged()
{
emit settingsChanged();
}
+
+void PreferencesDialog::on_proxyType_changed(int idx)
+{
+ if (idx == -1) {
+ return;
+ }
+
+ int proxyType = ui.proxyType->itemData(idx).toInt();
+ bool hpEnabled = (proxyType == QNetworkProxy::Socks5Proxy || proxyType == QNetworkProxy::HttpProxy);
+ ui.proxyHost->setEnabled(hpEnabled);
+ ui.proxyPort->setEnabled(hpEnabled);
+ ui.proxyAuthRequired->setEnabled(hpEnabled);
+ ui.proxyUsername->setEnabled(hpEnabled & ui.proxyAuthRequired->isChecked());
+ ui.proxyPassword->setEnabled(hpEnabled & ui.proxyAuthRequired->isChecked());
+ ui.proxyAuthRequired->setChecked(ui.proxyAuthRequired->isChecked());
+}