1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

Option to disable connections not supported by proxies. Closes #1894.

This commit is contained in:
sledgehammer999 2014-08-26 00:32:10 +03:00
parent cd99f0ea43
commit 0b8fad69fa
6 changed files with 55 additions and 1 deletions

View File

@ -31,7 +31,6 @@
#ifndef MISC_H
#define MISC_H
#include <libtorrent/version.hpp>
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/torrent_handle.hpp>
#include <sstream>

View File

@ -1372,6 +1372,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkForceProxy">
<property name="text">
<string>Disable connections not supported by proxies</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="checkProxyAuth">
<property name="enabled">
@ -2030,6 +2040,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="checkAnonymousMode">
<property name="toolTip">
<string>Enable when using a proxy or a VPN connection</string>
</property>
<property name="text">
<string>Enable anonymous mode</string>
</property>

View File

@ -215,6 +215,9 @@ options_imp::options_imp(QWidget *parent):
connect(textProxyIP, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinProxyPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkProxyPeerConnecs, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
#if LIBTORRENT_VERSION_NUM >= 10000
connect(checkForceProxy, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
#endif
connect(checkProxyAuth, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(textProxyUsername, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(textProxyPassword, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
@ -252,6 +255,11 @@ options_imp::options_imp(QWidget *parent):
scrollArea_advanced->setLayout(adv_layout);
connect(advancedSettings, SIGNAL(settingsChanged()), this, SLOT(enableApplyButton()));
//Hide incompatible options
#if LIBTORRENT_VERSION_NUM < 10000
checkForceProxy->setVisible(false);
#endif
// Adapt size
show();
loadWindowState();
@ -418,6 +426,9 @@ void options_imp::saveOptions() {
pref->setProxyIp(getProxyIp());
pref->setProxyPort(getProxyPort());
pref->setProxyPeerConnections(checkProxyPeerConnecs->isChecked());
#if LIBTORRENT_VERSION_NUM >= 10000
pref->setForceProxy(checkForceProxy->isChecked());
#endif
pref->setProxyAuthEnabled(isProxyAuthEnabled());
pref->setProxyUsername(getProxyUsername());
pref->setProxyPassword(getProxyPassword());
@ -643,6 +654,9 @@ void options_imp::loadOptions() {
textProxyIP->setText(pref->getProxyIp());
spinProxyPort->setValue(pref->getProxyPort());
checkProxyPeerConnecs->setChecked(pref->proxyPeerConnections());
#if LIBTORRENT_VERSION_NUM >= 10000
checkForceProxy->setChecked(pref->getForceProxy());
#endif
checkProxyAuth->setChecked(pref->isProxyAuthEnabled());
textProxyUsername->setText(pref->getProxyUsername());
textProxyPassword->setText(pref->getProxyPassword());
@ -930,6 +944,9 @@ void options_imp::enableProxy(int index) {
lblProxyPort->setEnabled(true);
spinProxyPort->setEnabled(true);
checkProxyPeerConnecs->setEnabled(true);
#if LIBTORRENT_VERSION_NUM >= 10000
checkForceProxy->setEnabled(true);
#endif
if (index > 1) {
checkProxyAuth->setEnabled(true);
} else {
@ -943,6 +960,9 @@ void options_imp::enableProxy(int index) {
lblProxyPort->setEnabled(false);
spinProxyPort->setEnabled(false);
checkProxyPeerConnecs->setEnabled(false);
#if LIBTORRENT_VERSION_NUM >= 10000
checkForceProxy->setEnabled(false);
#endif
checkProxyAuth->setEnabled(false);
checkProxyAuth->setChecked(false);
}

View File

@ -698,6 +698,16 @@ void Preferences::setProxyPeerConnections(bool enabled) {
setValue("Preferences/Connection/ProxyPeerConnections", enabled);
}
#if LIBTORRENT_VERSION_NUM >= 10000
bool Preferences::getForceProxy() const {
return value("Preferences/Connection/ProxyForce", true).toBool();
}
void Preferences::setForceProxy(bool enabled) {
setValue("Preferences/Connection/ProxyForce", enabled);
}
#endif
// Bittorrent options
int Preferences::getMaxConnecs() const {
return value("Preferences/Bittorrent/MaxConnecs", 500).toInt();

View File

@ -42,6 +42,8 @@
#include <QNetworkCookie>
#include <QVariant>
#include <libtorrent/version.hpp>
#define QBT_REALM "Web UI Access"
enum scheduler_days { EVERY_DAY, WEEK_DAYS, WEEK_ENDS, MON, TUE, WED, THU, FRI, SAT, SUN };
enum maxRatioAction {PAUSE_ACTION, REMOVE_ACTION};
@ -203,6 +205,10 @@ public:
void setProxyType(int type);
bool proxyPeerConnections() const;
void setProxyPeerConnections(bool enabled);
#if LIBTORRENT_VERSION_NUM >= 10000
bool getForceProxy() const;
void setForceProxy(bool enabled);
#endif
// Bittorrent options
int getMaxConnecs() const;

View File

@ -482,6 +482,12 @@ void QBtSession::configureSession() {
else
sessionSettings.mixed_mode_algorithm = session_settings::peer_proportional;
sessionSettings.connection_speed = 20; //default is 10
#if LIBTORRENT_VERSION_NUM >= 10000
if (pref->isProxyEnabled())
sessionSettings.force_proxy = pref->getForceProxy();
else
sessionSettings.force_proxy = false;
#endif
qDebug() << "Settings SessionSettings";
setSessionSettings(sessionSettings);
// Bittorrent