Skip to content

Commit

Permalink
Merge pull request #12528 from thalieht/proxycheckbox
Browse files Browse the repository at this point in the history
Don't uncheck Authentication checkbox when changing proxy type
  • Loading branch information
Chocobo1 committed Apr 20, 2020
2 parents 48c1ad8 + 5d16379 commit 8ed63d6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
13 changes: 5 additions & 8 deletions src/gui/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1443,36 +1442,34 @@ 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);
}
else {
m_ui->checkProxyAuth->setEnabled(false);
m_ui->checkProxyAuth->setChecked(false);
m_ui->isProxyOnlyForTorrents->setEnabled(false);
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);
m_ui->spinProxyPort->setEnabled(false);
m_ui->checkProxyPeerConnecs->setEnabled(false);
m_ui->isProxyOnlyForTorrents->setEnabled(false);
m_ui->checkProxyAuth->setEnabled(false);
m_ui->checkProxyAuth->setChecked(false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/optionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class OptionsDialog final : public QDialog
public:
// Constructor / Destructor
OptionsDialog(QWidget *parent = nullptr);
~OptionsDialog();
~OptionsDialog() override;

public slots:
void showConnectionTab();
Expand Down
23 changes: 8 additions & 15 deletions src/webui/www/private/views/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down

0 comments on commit 8ed63d6

Please sign in to comment.