From b97c0ed8a2d024bd814e499ab6730879d0b0ac5e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 21 Oct 2019 12:35:27 +0200 Subject: [PATCH] Network Settings: Show a warning that proxy settings do not apply to localhost Only show this if at least one account is detected to have an url that looks like localhost, because this could otherwise be confusing Issue #7169 --- src/gui/networksettings.cpp | 22 ++++++++++++++++++++++ src/gui/networksettings.h | 2 ++ src/gui/networksettings.ui | 25 ++++++++++++++++--------- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/gui/networksettings.cpp b/src/gui/networksettings.cpp index b2b72ed08..1c3631d4f 100644 --- a/src/gui/networksettings.cpp +++ b/src/gui/networksettings.cpp @@ -55,6 +55,8 @@ NetworkSettings::NetworkSettings(QWidget *parent) _ui->manualSettings, &QWidget::setEnabled); connect(_ui->manualProxyRadioButton, &QAbstractButton::toggled, _ui->typeComboBox, &QWidget::setEnabled); + connect(_ui->manualProxyRadioButton, &QAbstractButton::toggled, + this, &NetworkSettings::checkAccountLocalhost); loadProxySettings(); loadBWLimitSettings(); @@ -80,6 +82,7 @@ NetworkSettings::NetworkSettings(QWidget *parent) // Warn about empty proxy host connect(_ui->hostLineEdit, &QLineEdit::textChanged, this, &NetworkSettings::checkEmptyProxyHost); checkEmptyProxyHost(); + checkAccountLocalhost(); } NetworkSettings::~NetworkSettings() @@ -233,8 +236,27 @@ void NetworkSettings::showEvent(QShowEvent *event) checkEmptyProxyHost(); saveProxySettings(); } + checkAccountLocalhost(); QWidget::showEvent(event); } + +void NetworkSettings::checkAccountLocalhost() +{ + bool visible = false; + if (_ui->manualProxyRadioButton->isChecked()) { + // Check if at least one account is using localhost, because Qt proxy settings have no + // effect for localhost (#7169) + for (const auto &account : AccountManager::instance()->accounts()) { + const auto host = account->account()->url().host(); + // Some typical url for localhost + if (host == "localhost" || host.startsWith("127.") || host == "[::1]") + visible = true; + } + } + _ui->labelLocalhost->setVisible(visible); +} + + } // namespace OCC diff --git a/src/gui/networksettings.h b/src/gui/networksettings.h index ee07a39d1..4fd6db572 100644 --- a/src/gui/networksettings.h +++ b/src/gui/networksettings.h @@ -44,6 +44,8 @@ private slots: /// Red marking of host field if empty and enabled void checkEmptyProxyHost(); + void checkAccountLocalhost(); + protected: void showEvent(QShowEvent *event) override; diff --git a/src/gui/networksettings.ui b/src/gui/networksettings.ui index 2ee112226..dd21dc646 100644 --- a/src/gui/networksettings.ui +++ b/src/gui/networksettings.ui @@ -6,8 +6,8 @@ 0 0 - 516 - 444 + 623 + 581 @@ -23,6 +23,13 @@ Proxy Settings + + + + false + + + @@ -56,13 +63,6 @@ - - - - false - - - @@ -170,6 +170,13 @@ + + + + Note: proxy settings have no effects for accounts on localhost + + +