mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-10 15:32:48 -07:00
Unify and simplify setting to use proxy for torrents only.
This commit is contained in:
parent
5cbc7b16c0
commit
6053390bf5
5 changed files with 20 additions and 18 deletions
|
@ -213,7 +213,7 @@ void DownloadManager::applyProxySettings()
|
|||
ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
|
||||
QNetworkProxy proxy;
|
||||
|
||||
if (!proxyManager->isProxyDisabled() && (proxyConfig.type != ProxyType::None)) {
|
||||
if (!proxyManager->isProxyOnlyForTorrents() && (proxyConfig.type != ProxyType::None)) {
|
||||
// Proxy enabled
|
||||
proxy.setHostName(proxyConfig.ip);
|
||||
proxy.setPort(proxyConfig.port);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "base/settingsstorage.h"
|
||||
|
||||
#define SETTINGS_KEY(name) "Network/Proxy/" name
|
||||
const QString KEY_DISABLED = SETTINGS_KEY("Disabled");
|
||||
const QString KEY_ONLY_FOR_TORRENTS = SETTINGS_KEY("OnlyForTorrents");
|
||||
const QString KEY_TYPE = SETTINGS_KEY("Type");
|
||||
const QString KEY_IP = SETTINGS_KEY("IP");
|
||||
const QString KEY_PORT = SETTINGS_KEY("Port");
|
||||
|
@ -58,7 +58,7 @@ ProxyConfigurationManager *ProxyConfigurationManager::m_instance = nullptr;
|
|||
ProxyConfigurationManager::ProxyConfigurationManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_proxyDisabled = settings()->loadValue(KEY_DISABLED, false).toBool();
|
||||
m_isProxyOnlyForTorrents = settings()->loadValue(KEY_ONLY_FOR_TORRENTS, false).toBool();
|
||||
m_config.type = static_cast<ProxyType>(
|
||||
settings()->loadValue(KEY_TYPE, static_cast<int>(ProxyType::None)).toInt());
|
||||
if ((m_config.type < ProxyType::None) || (m_config.type > ProxyType::SOCKS4))
|
||||
|
@ -109,16 +109,16 @@ void ProxyConfigurationManager::setProxyConfiguration(const ProxyConfiguration &
|
|||
}
|
||||
}
|
||||
|
||||
bool ProxyConfigurationManager::isProxyDisabled() const
|
||||
bool ProxyConfigurationManager::isProxyOnlyForTorrents() const
|
||||
{
|
||||
return m_proxyDisabled;
|
||||
return m_isProxyOnlyForTorrents || (m_config.type == ProxyType::SOCKS4);
|
||||
}
|
||||
|
||||
void ProxyConfigurationManager::setProxyDisabled(bool disabled)
|
||||
void ProxyConfigurationManager::setProxyOnlyForTorrents(bool onlyForTorrents)
|
||||
{
|
||||
if (m_proxyDisabled != disabled) {
|
||||
settings()->storeValue(KEY_DISABLED, disabled);
|
||||
m_proxyDisabled = disabled;
|
||||
if (m_isProxyOnlyForTorrents != onlyForTorrents) {
|
||||
settings()->storeValue(KEY_ONLY_FOR_TORRENTS, onlyForTorrents);
|
||||
m_isProxyOnlyForTorrents = onlyForTorrents;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ void ProxyConfigurationManager::configureProxy()
|
|||
{
|
||||
// Define environment variables for urllib in search engine plugins
|
||||
QString proxyStrHTTP, proxyStrSOCK;
|
||||
if (!m_proxyDisabled) {
|
||||
if (!m_isProxyOnlyForTorrents) {
|
||||
switch (m_config.type) {
|
||||
case ProxyType::HTTP_PW:
|
||||
proxyStrHTTP = QString("http://%1:%2@%3:%4").arg(m_config.username)
|
||||
|
|
|
@ -67,8 +67,8 @@ namespace Net
|
|||
|
||||
ProxyConfiguration proxyConfiguration() const;
|
||||
void setProxyConfiguration(const ProxyConfiguration &config);
|
||||
bool isProxyDisabled() const;
|
||||
void setProxyDisabled(bool disabled);
|
||||
bool isProxyOnlyForTorrents() const;
|
||||
void setProxyOnlyForTorrents(bool onlyForTorrents);
|
||||
|
||||
bool isAuthenticationRequired() const;
|
||||
|
||||
|
@ -80,7 +80,7 @@ namespace Net
|
|||
|
||||
static ProxyConfigurationManager *m_instance;
|
||||
ProxyConfiguration m_config;
|
||||
bool m_proxyDisabled;
|
||||
bool m_isProxyOnlyForTorrents;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace
|
|||
{"BitTorrent/Session/uTPEnabled", "Preferences/Bittorrent/uTP"},
|
||||
{"BitTorrent/Session/uTPRateLimited", "Preferences/Bittorrent/uTP_rate_limited"},
|
||||
{"BitTorrent/TrackerEnabled", "Preferences/Advanced/trackerEnabled"},
|
||||
{"Network/Proxy/Disabled", "Preferences/Connection/ProxyOnlyForTorrents"},
|
||||
{"Network/Proxy/OnlyForTorrents", "Preferences/Connection/ProxyOnlyForTorrents"},
|
||||
{"Network/Proxy/Type", "Preferences/Connection/ProxyType"},
|
||||
{"Network/Proxy/Authentication", "Preferences/Connection/Proxy/Authentication"},
|
||||
{"Network/Proxy/Username", "Preferences/Connection/Proxy/Username"},
|
||||
|
|
|
@ -563,7 +563,7 @@ void OptionsDialog::saveOptions()
|
|||
proxyConf.port = getProxyPort();
|
||||
proxyConf.username = getProxyUsername();
|
||||
proxyConf.password = getProxyPassword();
|
||||
proxyConfigManager->setProxyDisabled(m_ui->isProxyOnlyForTorrents->isChecked());
|
||||
proxyConfigManager->setProxyOnlyForTorrents(m_ui->isProxyOnlyForTorrents->isChecked());
|
||||
proxyConfigManager->setProxyConfiguration(proxyConf);
|
||||
|
||||
session->setProxyPeerConnectionsEnabled(m_ui->checkProxyPeerConnecs->isChecked());
|
||||
|
@ -858,7 +858,6 @@ void OptionsDialog::loadOptions()
|
|||
default:
|
||||
m_ui->comboProxyType->setCurrentIndex(0);
|
||||
}
|
||||
enableProxy(m_ui->comboProxyType->currentIndex() > 0);
|
||||
m_ui->textProxyIP->setText(proxyConf.ip);
|
||||
m_ui->spinProxyPort->setValue(proxyConf.port);
|
||||
m_ui->checkProxyAuth->setChecked(useProxyAuth);
|
||||
|
@ -867,7 +866,8 @@ void OptionsDialog::loadOptions()
|
|||
|
||||
m_ui->checkProxyPeerConnecs->setChecked(session->isProxyPeerConnectionsEnabled());
|
||||
m_ui->checkForceProxy->setChecked(session->isForceProxyEnabled());
|
||||
m_ui->isProxyOnlyForTorrents->setChecked(proxyConfigManager->isProxyDisabled());
|
||||
m_ui->isProxyOnlyForTorrents->setChecked(proxyConfigManager->isProxyOnlyForTorrents());
|
||||
enableProxy(m_ui->comboProxyType->currentIndex() > 0);
|
||||
|
||||
m_ui->checkIPFilter->setChecked(session->isIPFilteringEnabled());
|
||||
m_ui->checkIpFilterTrackers->setChecked(session->isTrackerFilteringEnabled());
|
||||
|
@ -1194,13 +1194,15 @@ void OptionsDialog::enableProxy(int index)
|
|||
m_ui->spinProxyPort->setEnabled(true);
|
||||
m_ui->checkProxyPeerConnecs->setEnabled(true);
|
||||
m_ui->checkForceProxy->setEnabled(true);
|
||||
m_ui->isProxyOnlyForTorrents->setEnabled(true);
|
||||
if (index > 1) {
|
||||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue