summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/preferences.cpp23
-rw-r--r--qt-ui/preferences.h1
2 files changed, 24 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());
+}
diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h
index 474064b10..a32c725e0 100644
--- a/qt-ui/preferences.h
+++ b/qt-ui/preferences.h
@@ -28,6 +28,7 @@ slots:
void rememberPrefs();
void gflowChanged(int gf);
void gfhighChanged(int gf);
+ void on_proxyType_changed(int idx);
private:
explicit PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);