From f0549b4cb2894182ac877f61a4ad867c2a85558a Mon Sep 17 00:00:00 2001 From: thalieht Date: Thu, 16 Apr 2020 20:02:45 +0300 Subject: [PATCH 1/2] Make a few cosmetic changes in code --- src/gui/optionsdialog.cpp | 11 +++++------ src/gui/optionsdialog.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index c181b0ea0..f2cef9353 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -882,7 +882,6 @@ Net::ProxyType OptionsDialog::getProxyType() const switch (m_ui->comboProxyType->currentIndex()) { case 1: return Net::ProxyType::SOCKS4; - break; case 2: if (isProxyAuthEnabled()) return Net::ProxyType::SOCKS5_PW; @@ -1443,16 +1442,16 @@ void OptionsDialog::toggleComboRatioLimitAct() m_ui->comboRatioLimitAct->setEnabled(m_ui->checkMaxRatio->isChecked() || m_ui->checkMaxSeedingMinutes->isChecked()); } -void OptionsDialog::enableProxy(int index) +void OptionsDialog::enableProxy(const int index) { - if (index) { + if (index >= 1) { // Any proxy type is used //enable m_ui->lblProxyIP->setEnabled(true); m_ui->textProxyIP->setEnabled(true); m_ui->lblProxyPort->setEnabled(true); m_ui->spinProxyPort->setEnabled(true); m_ui->checkProxyPeerConnecs->setEnabled(true); - if (index > 1) { + if (index >= 2) { // SOCKS5 or HTTP m_ui->checkProxyAuth->setEnabled(true); m_ui->isProxyOnlyForTorrents->setEnabled(true); } @@ -1463,8 +1462,8 @@ void OptionsDialog::enableProxy(int index) m_ui->isProxyOnlyForTorrents->setChecked(true); } } - else { - //disable + else { // No proxy + // disable m_ui->lblProxyIP->setEnabled(false); m_ui->textProxyIP->setEnabled(false); m_ui->lblProxyPort->setEnabled(false); diff --git a/src/gui/optionsdialog.h b/src/gui/optionsdialog.h index 72ee2e343..884756778 100644 --- a/src/gui/optionsdialog.h +++ b/src/gui/optionsdialog.h @@ -82,7 +82,7 @@ class OptionsDialog : public QDialog public: // Constructor / Destructor OptionsDialog(QWidget *parent = nullptr); - ~OptionsDialog(); + ~OptionsDialog() override; public slots: void showConnectionTab(); From 5d16379941c1cbe85c459fc67492d95698961ff9 Mon Sep 17 00:00:00 2001 From: thalieht Date: Thu, 16 Apr 2020 22:34:33 +0300 Subject: [PATCH 2/2] Don't uncheck Authentication checkbox when changing proxy type Closes #12525 --- src/gui/optionsdialog.cpp | 2 -- src/webui/www/private/views/preferences.html | 23 +++++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index f2cef9353..a771a0581 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -1457,7 +1457,6 @@ void OptionsDialog::enableProxy(const int index) } else { m_ui->checkProxyAuth->setEnabled(false); - m_ui->checkProxyAuth->setChecked(false); m_ui->isProxyOnlyForTorrents->setEnabled(false); m_ui->isProxyOnlyForTorrents->setChecked(true); } @@ -1471,7 +1470,6 @@ void OptionsDialog::enableProxy(const int index) m_ui->checkProxyPeerConnecs->setEnabled(false); m_ui->isProxyOnlyForTorrents->setEnabled(false); m_ui->checkProxyAuth->setEnabled(false); - m_ui->checkProxyAuth->setChecked(false); } } diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 150590f0f..276cc5b6d 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -1292,26 +1292,19 @@ $('peer_proxy_host_text').setProperty('disabled', !isPeerProxyTypeSelected); $('peer_proxy_port_value').setProperty('disabled', !isPeerProxyTypeSelected); $('use_peer_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected); - $('proxy_only_for_torrents_checkbox').setProperty('disabled', !isPeerProxyTypeSelected); + const isPeerProxyAuthenticatable = ($('peer_proxy_type_select').getProperty('value') === "socks5" || $('peer_proxy_type_select').getProperty('value') === "http"); + $('proxy_only_for_torrents_checkbox').setProperty('disabled', !isPeerProxyAuthenticatable); - if (isPeerProxyTypeSelected) { - const isPeerProxyTypeSocks5 = $('peer_proxy_type_select').getProperty('value') == "socks5"; - $('peer_proxy_auth_checkbox').setProperty('disabled', !isPeerProxyTypeSocks5); + if ($('peer_proxy_type_select').getProperty('value') === "socks4") + $('proxy_only_for_torrents_checkbox').setProperty('checked', true); - if (!isPeerProxyTypeSocks5) { - $('peer_proxy_auth_checkbox').setProperty('checked', isPeerProxyTypeSocks5); - updatePeerProxyAuthSettings(); - } - } - else { - $('peer_proxy_auth_checkbox').setProperty('disabled', !isPeerProxyTypeSelected); - $('peer_proxy_auth_checkbox').setProperty('checked', isPeerProxyTypeSelected); - updatePeerProxyAuthSettings(); - } + $('peer_proxy_auth_checkbox').setProperty('disabled', !isPeerProxyAuthenticatable); + + updatePeerProxyAuthSettings(); }; const updatePeerProxyAuthSettings = function() { - const isPeerProxyAuthEnabled = $('peer_proxy_auth_checkbox').getProperty('checked'); + const isPeerProxyAuthEnabled = (!$('peer_proxy_auth_checkbox').getProperty('disabled') && $('peer_proxy_auth_checkbox').getProperty('checked')); $('peer_proxy_username_text').setProperty('disabled', !isPeerProxyAuthEnabled); $('peer_proxy_password_text').setProperty('disabled', !isPeerProxyAuthEnabled); };