1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Bring back proxy configuration

This commit is contained in:
David Rosca 2015-10-15 14:39:18 +02:00
parent 1c63a90e1a
commit 0845606cc7
4 changed files with 27 additions and 163 deletions

View File

@ -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();
}

View File

@ -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()

View File

@ -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);

View File

@ -1358,28 +1358,7 @@
<string>Proxy Configuration</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label_54">
<property name="text">
<string>&lt;b&gt;Exceptions&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="9" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_27">
<item>
<widget class="QLabel" name="label_40">
<property name="text">
<string>Don't use on:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="proxyExceptions"/>
</item>
</layout>
</item>
<item row="10" column="0">
<item row="4" column="0">
<spacer name="verticalSpacer_14">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -1392,14 +1371,14 @@
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<item row="0" column="0" colspan="2">
<widget class="QRadioButton" name="systemProxy">
<property name="text">
<string>System proxy configuration</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<spacer name="horizontalSpacer_29">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -1415,14 +1394,14 @@
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="manualProxy">
<property name="text">
<string>Manual configuration</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QComboBox" name="proxyType">
@ -1460,7 +1439,7 @@
</item>
</layout>
</item>
<item row="4" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<widget class="QLabel" name="label_38">
@ -1497,88 +1476,6 @@
</item>
</layout>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="useHttpsProxy">
<property name="text">
<string>Use different proxy for https connection</string>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QLabel" name="label_55">
<property name="text">
<string>Server:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="httpsProxyServer"/>
</item>
<item>
<widget class="QLabel" name="label_58">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="httpsProxyPort">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_24">
<item>
<widget class="QLabel" name="label_56">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="httpsProxyUsername"/>
</item>
<item>
<widget class="QLabel" name="label_57">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="httpsProxyPassword"/>
</item>
<item>
<spacer name="horizontalSpacer_28">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0" colspan="2">
<widget class="QRadioButton" name="noProxy">
<property name="text">
<string>Do not use proxy</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@ -2643,7 +2540,6 @@
<tabstop>proxyPort</tabstop>
<tabstop>manualProxy</tabstop>
<tabstop>systemProxy</tabstop>
<tabstop>noProxy</tabstop>
<tabstop>showStatusbar</tabstop>
<tabstop>showNavigationToolbar</tabstop>
<tabstop>showHome</tabstop>