From 0845606cc74a9199136c446daa8d2d035820e71f Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 15 Oct 2015 14:39:18 +0200 Subject: [PATCH] Bring back proxy configuration --- src/lib/network/networkmanager.cpp | 11 ++- src/lib/preferences/preferences.cpp | 62 +++------------ src/lib/preferences/preferences.h | 1 - src/lib/preferences/preferences.ui | 116 ++-------------------------- 4 files changed, 27 insertions(+), 163 deletions(-) diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index a8985c13b..2d84a1a09 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -233,8 +233,17 @@ void NetworkManager::loadSettings() settings.beginGroup("Language"); QStringList langs = settings.value("acceptLanguage", AcceptLanguage::defaultLanguage()).toStringList(); settings.endGroup(); - mApp->webProfile()->setHttpAcceptLanguage(AcceptLanguage::generateHeader(langs)); + QNetworkProxy proxy; + settings.beginGroup("Web-Proxy"); + proxy.setType(QNetworkProxy::ProxyType(settings.value("ProxyType", QNetworkProxy::NoProxy).toInt())); + proxy.setHostName(settings.value("HostName", QString()).toString()); + proxy.setPort(settings.value("Port", 8080).toInt()); + proxy.setUser(settings.value("Username", QString()).toString()); + proxy.setPassword(settings.value("Password", QString()).toString()); + settings.endGroup(); + QNetworkProxy::setApplicationProxy(proxy); + m_urlInterceptor->loadSettings(); } diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index e75c3e13e..41ab1496f 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -421,38 +421,26 @@ Preferences::Preferences(BrowserWindow* window) // Proxy Configuration settings.beginGroup("Web-Proxy"); - NetworkProxyFactory::ProxyPreference proxyPreference = NetworkProxyFactory::ProxyPreference(settings.value("UseProxy", NetworkProxyFactory::SystemProxy).toInt()); QNetworkProxy::ProxyType proxyType = QNetworkProxy::ProxyType(settings.value("ProxyType", QNetworkProxy::HttpProxy).toInt()); - ui->systemProxy->setChecked(proxyPreference == NetworkProxyFactory::SystemProxy); - ui->noProxy->setChecked(proxyPreference == NetworkProxyFactory::NoProxy); - ui->manualProxy->setChecked(proxyPreference == NetworkProxyFactory::DefinedProxy); - if (proxyType == QNetworkProxy::HttpProxy) { - ui->proxyType->setCurrentIndex(0); + ui->systemProxy->setChecked(proxyType == QNetworkProxy::NoProxy); + ui->manualProxy->setChecked(proxyType != QNetworkProxy::NoProxy); + if (proxyType == QNetworkProxy::Socks5Proxy) { + ui->proxyType->setCurrentIndex(1); } else { - ui->proxyType->setCurrentIndex(1); + ui->proxyType->setCurrentIndex(0); } ui->proxyServer->setText(settings.value("HostName", "").toString()); ui->proxyPort->setText(settings.value("Port", 8080).toString()); ui->proxyUsername->setText(settings.value("Username", "").toString()); ui->proxyPassword->setText(settings.value("Password", "").toString()); - - ui->useHttpsProxy->setChecked(settings.value("UseDifferentProxyForHttps", false).toBool()); - ui->httpsProxyServer->setText(settings.value("HttpsHostName", "").toString()); - ui->httpsProxyPort->setText(settings.value("HttpsPort", 8080).toString()); - ui->httpsProxyUsername->setText(settings.value("HttpsUsername", "").toString()); - ui->httpsProxyPassword->setText(settings.value("HttpsPassword", "").toString()); - - ui->proxyExceptions->setText(settings.value("ProxyExceptions", QStringList() << "localhost" << "127.0.0.1").toStringList().join(",")); settings.endGroup(); - useDifferentProxyForHttpsChanged(ui->useHttpsProxy->isChecked()); - setManualProxyConfigurationEnabled(proxyPreference == NetworkProxyFactory::DefinedProxy); + setManualProxyConfigurationEnabled(proxyType != QNetworkProxy::NoProxy); connect(ui->manualProxy, SIGNAL(toggled(bool)), this, SLOT(setManualProxyConfigurationEnabled(bool))); - connect(ui->useHttpsProxy, SIGNAL(toggled(bool)), this, SLOT(useDifferentProxyForHttpsChanged(bool))); //CONNECTS connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); @@ -633,10 +621,6 @@ void Preferences::setManualProxyConfigurationEnabled(bool state) ui->proxyPort->setEnabled(state); ui->proxyUsername->setEnabled(state); ui->proxyPassword->setEnabled(state); - - useDifferentProxyForHttpsChanged(state ? ui->useHttpsProxy->isChecked() : false); - - ui->useHttpsProxy->setEnabled(state); } void Preferences::saveHistoryChanged(bool stat) @@ -701,14 +685,6 @@ void Preferences::cacheValueChanged(int value) ui->MBlabel->setText(QString::number(value) + " MB"); } -void Preferences::useDifferentProxyForHttpsChanged(bool state) -{ - ui->httpsProxyServer->setEnabled(state); - ui->httpsProxyPort->setEnabled(state); - ui->httpsProxyUsername->setEnabled(state); - ui->httpsProxyPassword->setEnabled(state); -} - void Preferences::changeCachePathClicked() { QString path = QzTools::getExistingDirectory("Preferences-CachePath", this, tr("Choose cache path..."), ui->cachePath->text()); @@ -984,19 +960,11 @@ void Preferences::saveSettings() settings.endGroup(); //Proxy Configuration - NetworkProxyFactory::ProxyPreference proxyPreference; - if (ui->systemProxy->isChecked()) { - proxyPreference = NetworkProxyFactory::SystemProxy; - } - else if (ui->noProxy->isChecked()) { - proxyPreference = NetworkProxyFactory::NoProxy; - } - else { - proxyPreference = NetworkProxyFactory::DefinedProxy; - } - QNetworkProxy::ProxyType proxyType; - if (ui->proxyType->currentIndex() == 0) { + if (ui->systemProxy->isChecked()) { + proxyType = QNetworkProxy::NoProxy; + } + else if (ui->proxyType->currentIndex() == 0) { proxyType = QNetworkProxy::HttpProxy; } else { @@ -1005,19 +973,10 @@ void Preferences::saveSettings() settings.beginGroup("Web-Proxy"); settings.setValue("ProxyType", proxyType); - settings.setValue("UseProxy", proxyPreference); settings.setValue("HostName", ui->proxyServer->text()); settings.setValue("Port", ui->proxyPort->text().toInt()); settings.setValue("Username", ui->proxyUsername->text()); settings.setValue("Password", ui->proxyPassword->text()); - - settings.setValue("UseDifferentProxyForHttps", ui->useHttpsProxy->isChecked()); - settings.setValue("HttpsHostName", ui->httpsProxyServer->text()); - settings.setValue("HttpsPort", ui->httpsProxyPort->text()); - settings.setValue("HttpsUsername", ui->httpsProxyUsername->text()); - settings.setValue("HttpsPassword", ui->httpsProxyPassword->text()); - - settings.setValue("ProxyExceptions", ui->proxyExceptions->text().split(QLatin1Char(','), QString::SkipEmptyParts)); settings.endGroup(); ProfileManager::setStartingProfile(ui->startProfile->currentText()); @@ -1030,6 +989,7 @@ void Preferences::saveSettings() mApp->plugins()->c2f_saveSettings(); mApp->desktopNotifications()->loadSettings(); mApp->autoFill()->loadSettings(); + mApp->networkManager()->loadSettings(); } Preferences::~Preferences() diff --git a/src/lib/preferences/preferences.h b/src/lib/preferences/preferences.h index 1cdc567b9..e780a313d 100644 --- a/src/lib/preferences/preferences.h +++ b/src/lib/preferences/preferences.h @@ -72,7 +72,6 @@ private slots: void showPassManager(bool state); void setManualProxyConfigurationEnabled(bool state); void useExternalDownManagerChanged(bool state); - void useDifferentProxyForHttpsChanged(bool state); void changeCachePathClicked(); void newTabChanged(int value); diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui index 9ca040a3b..70704cd48 100644 --- a/src/lib/preferences/preferences.ui +++ b/src/lib/preferences/preferences.ui @@ -1358,28 +1358,7 @@ Proxy Configuration - - - - <b>Exceptions</b> - - - - - - - - - Don't use on: - - - - - - - - - + Qt::Vertical @@ -1392,14 +1371,14 @@ - + System proxy configuration - + Qt::Horizontal @@ -1415,14 +1394,14 @@ - + Manual configuration - + @@ -1460,7 +1439,7 @@ - + @@ -1497,88 +1476,6 @@ - - - - Use different proxy for https connection - - - - - - - - - Server: - - - - - - - - - - Port: - - - - - - - - 50 - 16777215 - - - - - - - - - - - - Username: - - - - - - - - - - Password: - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Do not use proxy - - - @@ -2643,7 +2540,6 @@ proxyPort manualProxy systemProxy - noProxy showStatusbar showNavigationToolbar showHome