Browse Source

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

adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
0b8fad69fa
  1. 1
      src/misc.h
  2. 13
      src/preferences/options.ui
  3. 20
      src/preferences/options_imp.cpp
  4. 10
      src/preferences/preferences.cpp
  5. 6
      src/preferences/preferences.h
  6. 6
      src/qtlibtorrent/qbtsession.cpp

1
src/misc.h

@ -31,7 +31,6 @@ @@ -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>

13
src/preferences/options.ui

@ -1372,6 +1372,16 @@ @@ -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 @@ @@ -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>

20
src/preferences/options_imp.cpp

@ -215,6 +215,9 @@ options_imp::options_imp(QWidget *parent): @@ -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): @@ -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() { @@ -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() { @@ -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) { @@ -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) { @@ -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);
}

10
src/preferences/preferences.cpp

@ -698,6 +698,16 @@ void Preferences::setProxyPeerConnections(bool enabled) { @@ -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();

6
src/preferences/preferences.h

@ -42,6 +42,8 @@ @@ -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: @@ -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;

6
src/qtlibtorrent/qbtsession.cpp

@ -482,6 +482,12 @@ void QBtSession::configureSession() { @@ -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

Loading…
Cancel
Save