From 62e0a9d46eb4cbabe9fad31903a63d31df9e8432 Mon Sep 17 00:00:00 2001 From: Dario Freddi Date: Tue, 13 Oct 2009 00:40:44 +0200 Subject: Remove rekonq's custom proxy implementation to use KDE's proxy settings through KProtocolManager. This makes rekonq much more integrated withing KDE, as the user expects that changes in System Settings would take place everywhere. And it also leaves less code to maintain Signed-off-by: Dario Freddi --- src/CMakeLists.txt | 1 - src/networkaccessmanager.cpp | 39 +++++++----- src/rekonq.kcfg | 19 ------ src/settings.cpp | 15 +---- src/settings_proxy.ui | 145 ------------------------------------------- 5 files changed, 25 insertions(+), 194 deletions(-) delete mode 100644 src/settings_proxy.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 11fc5c6b..8b7e6f78 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,7 +34,6 @@ KDE4_ADD_UI_FILES( rekonq_SRCS proxy.ui settings_general.ui settings_fonts.ui - settings_proxy.ui settings_webkit.ui cleardata.ui ) diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index fd975062..1cdc6700 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -42,6 +42,7 @@ // KDE Includes #include #include +#include // Qt Includes #include @@ -69,7 +70,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) // load AccessManager Settings loadSettings(); - + // resetting disk cache resetDiskCache(); } @@ -77,23 +78,31 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) void NetworkAccessManager::loadSettings() { - if (ReKonfig::isProxyEnabled()) + // Grab proxy settings from KDE settings + if (KProtocolManager::useProxy()) { - QNetworkProxy proxy; - if (ReKonfig::proxyType() == 0) - { - proxy.setType(QNetworkProxy::Socks5Proxy); - } - else + QString proxyAddress = KProtocolManager::proxyFor("http"); + + if(!proxyAddress.isEmpty()) { - proxy.setType(QNetworkProxy::HttpProxy); + KUrl proxyUrl(proxyAddress); + QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy; + + // See what kind of proxy we have here + if(proxyUrl.protocol() == "socks") + { + proxyType = QNetworkProxy::Socks5Proxy; + } + else + { + proxyType = QNetworkProxy::HttpProxy; + } + + QNetworkProxy proxy(proxyType, proxyUrl.host(), (quint16)proxyUrl.port(), + proxyUrl.user(), proxyUrl.pass()); + + setProxy(proxy); } - proxy.setHostName(ReKonfig::proxyHostName()); - proxy.setPort(ReKonfig::proxyPort()); - proxy.setUser(ReKonfig::proxyUserName()); - proxy.setPassword(ReKonfig::proxyPassword()); - - setProxy(proxy); } } diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 0a63922f..9e854f76 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -75,25 +75,6 @@ - - - - false - - - 0 - - - - - 8080 - - - - - - - diff --git a/src/settings.cpp b/src/settings.cpp index ec5094c2..7b320448 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -42,7 +42,6 @@ //Ui Includes #include "ui_settings_general.h" #include "ui_settings_fonts.h" -#include "ui_settings_proxy.h" #include "ui_settings_webkit.h" // KDE Includes @@ -63,7 +62,6 @@ class Private private: Ui::general generalUi; Ui::fonts fontsUi; - Ui::proxy proxyUi; Ui::webkit webkitUi; KCModuleProxy *ebrowsingModule; KCModuleProxy *cookiesModule; @@ -84,7 +82,7 @@ Private::Private(SettingsDialog *parent) widget->layout()->setMargin(0); pageItem = parent->addPage(widget , i18n("General")); pageItem->setIcon(KIcon("rekonq")); - + widget = new QWidget; fontsUi.setupUi(widget); widget->layout()->setMargin(0); @@ -96,12 +94,6 @@ Private::Private(SettingsDialog *parent) pageItem = parent->addPage(cookiesModule, i18n(cookiesInfo.moduleName().toLocal8Bit())); pageItem->setIcon(KIcon(cookiesInfo.icon())); - widget = new QWidget; - proxyUi.setupUi(widget); - widget->layout()->setMargin(0); - pageItem = parent->addPage(widget , i18n("Proxy")); - pageItem->setIcon(KIcon("preferences-system-network")); - widget = new QWidget; webkitUi.setupUi(widget); widget->layout()->setMargin(0); @@ -185,11 +177,6 @@ void SettingsDialog::readConfig() // ======= Fonts d->fontsUi.kcfg_fixedFont->setOnlyFixed(true); - - // ======= Proxy - bool proxyEnabled = ReKonfig::isProxyEnabled(); - d->proxyUi.groupBox->setEnabled(proxyEnabled); - connect(d->proxyUi.kcfg_isProxyEnabled, SIGNAL(clicked(bool)), d->proxyUi.groupBox, SLOT(setEnabled(bool))); } diff --git a/src/settings_proxy.ui b/src/settings_proxy.ui deleted file mode 100644 index 938529b0..00000000 --- a/src/settings_proxy.ui +++ /dev/null @@ -1,145 +0,0 @@ - - proxy - - - - 0 - 0 - 440 - 223 - - - - Proxy - - - - - - Enable proxy - - - - - - - Proxy Settings - - - - - - Type: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - SOCKS 5 - - - - - HTTP - - - - - - - - Host: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Port: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 10000 - - - 1080 - - - - - - - Qt::Horizontal - - - - 293 - 20 - - - - - - - - Username: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Password: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Qt::Vertical - - - - 20 - 8 - - - - - - - - - - - - -- cgit v1.2.1