Allow to globally disable the use of proxy

PR #19273.
Closes #19141.
This commit is contained in:
Vladimir Golovnev 2023-07-04 09:27:46 +03:00 committed by GitHub
parent 66e533f505
commit 7ec80263e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 105 additions and 80 deletions

View file

@ -804,6 +804,7 @@ void OptionsDialog::loadConnectionTabOptions()
const auto *proxyConfigManager = Net::ProxyConfigurationManager::instance();
const Net::ProxyConfiguration proxyConf = proxyConfigManager->proxyConfiguration();
m_ui->comboProxyType->addItem(tr("(None)"), QVariant::fromValue(Net::ProxyType::None));
m_ui->comboProxyType->addItem(tr("SOCKS4"), QVariant::fromValue(Net::ProxyType::SOCKS4));
m_ui->comboProxyType->addItem(tr("SOCKS5"), QVariant::fromValue(Net::ProxyType::SOCKS5));
m_ui->comboProxyType->addItem(tr("HTTP"), QVariant::fromValue(Net::ProxyType::HTTP));
@ -1537,26 +1538,53 @@ void OptionsDialog::toggleComboRatioLimitAct()
void OptionsDialog::adjustProxyOptions()
{
const auto currentProxyType = m_ui->comboProxyType->currentData().value<Net::ProxyType>();
const bool isAuthSupported = (currentProxyType != Net::ProxyType::SOCKS4);
const bool isAuthSupported = ((currentProxyType == Net::ProxyType::SOCKS5)
|| (currentProxyType == Net::ProxyType::HTTP));
m_ui->checkProxyAuth->setEnabled(isAuthSupported);
if (currentProxyType == Net::ProxyType::SOCKS4)
if (currentProxyType == Net::ProxyType::None)
{
m_ui->labelProxyTypeIncompatible->setVisible(true);
m_ui->labelProxyTypeIncompatible->setVisible(false);
m_ui->lblProxyIP->setEnabled(false);
m_ui->textProxyIP->setEnabled(false);
m_ui->lblProxyPort->setEnabled(false);
m_ui->spinProxyPort->setEnabled(false);
m_ui->checkProxyHostnameLookup->setEnabled(false);
m_ui->checkProxyRSS->setEnabled(false);
m_ui->checkProxyMisc->setEnabled(false);
m_ui->checkProxyBitTorrent->setEnabled(false);
m_ui->checkProxyPeerConnections->setEnabled(false);
}
else
{
// SOCKS5 or HTTP
m_ui->labelProxyTypeIncompatible->setVisible(false);
m_ui->lblProxyIP->setEnabled(true);
m_ui->textProxyIP->setEnabled(true);
m_ui->lblProxyPort->setEnabled(true);
m_ui->spinProxyPort->setEnabled(true);
m_ui->checkProxyHostnameLookup->setEnabled(true);
m_ui->checkProxyRSS->setEnabled(true);
m_ui->checkProxyMisc->setEnabled(true);
m_ui->checkProxyBitTorrent->setEnabled(true);
m_ui->checkProxyPeerConnections->setEnabled(true);
if (currentProxyType == Net::ProxyType::SOCKS4)
{
m_ui->labelProxyTypeIncompatible->setVisible(true);
m_ui->checkProxyHostnameLookup->setEnabled(false);
m_ui->checkProxyRSS->setEnabled(false);
m_ui->checkProxyMisc->setEnabled(false);
}
else
{
// SOCKS5 or HTTP
m_ui->labelProxyTypeIncompatible->setVisible(false);
m_ui->checkProxyHostnameLookup->setEnabled(true);
m_ui->checkProxyRSS->setEnabled(true);
m_ui->checkProxyMisc->setEnabled(true);
}
}
}