FEATURE: User can choose to apply transfer limits on LAN too

This commit is contained in:
Christophe Dumez 2010-01-31 15:42:24 +00:00
parent 81d3e64518
commit 51e474c893
4 changed files with 26 additions and 2 deletions

View file

@ -5,6 +5,7 @@
- FEATURE: Added "Upload/Download limit" columns to transfer list - FEATURE: Added "Upload/Download limit" columns to transfer list
- FEATURE: Torrent files can be exported to a given directory - FEATURE: Torrent files can be exported to a given directory
- FEATURE: Outgoing ports range can be customized (for QoS) - FEATURE: Outgoing ports range can be customized (for QoS)
- FEATURE: User can choose to apply transfer limits on LAN too
* Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0 * Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0
- FEATURE: Graphical User Interface can be disabled at compilation time (headless running) - FEATURE: Graphical User Interface can be disabled at compilation time (headless running)

View file

@ -4,17 +4,19 @@
#include <QTableWidget> #include <QTableWidget>
#include <QHeaderView> #include <QHeaderView>
#include <QSpinBox> #include <QSpinBox>
#include <QCheckBox>
#include "preferences.h" #include "preferences.h"
enum AdvSettingsCols {PROPERTY, VALUE}; enum AdvSettingsCols {PROPERTY, VALUE};
enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX }; enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN };
#define ROW_COUNT 3 #define ROW_COUNT 4
class AdvancedSettings: public QTableWidget { class AdvancedSettings: public QTableWidget {
Q_OBJECT Q_OBJECT
private: private:
QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max; QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max;
QCheckBox *cb_ignore_limits_lan;
public: public:
AdvancedSettings(QWidget *parent=0): QTableWidget(parent) { AdvancedSettings(QWidget *parent=0): QTableWidget(parent) {
@ -35,6 +37,7 @@ public:
delete spin_cache; delete spin_cache;
delete outgoing_ports_min; delete outgoing_ports_min;
delete outgoing_ports_max; delete outgoing_ports_max;
delete cb_ignore_limits_lan;
} }
public slots: public slots:
@ -44,6 +47,8 @@ public:
// Outgoing ports // Outgoing ports
Preferences::setOutgoingPortsMin(outgoing_ports_min->value()); Preferences::setOutgoingPortsMin(outgoing_ports_min->value());
Preferences::setOutgoingPortsMax(outgoing_ports_max->value()); Preferences::setOutgoingPortsMax(outgoing_ports_max->value());
// Ignore limits on LAN
Preferences::ignoreLimitsOnLAN(cb_ignore_limits_lan->isChecked());
} }
protected slots: protected slots:
@ -72,6 +77,12 @@ protected slots:
outgoing_ports_max->setMaximum(65535); outgoing_ports_max->setMaximum(65535);
outgoing_ports_max->setValue(Preferences::outgoingPortsMax()); outgoing_ports_max->setValue(Preferences::outgoingPortsMax());
setCellWidget(OUTGOING_PORT_MAX, VALUE, outgoing_ports_max); setCellWidget(OUTGOING_PORT_MAX, VALUE, outgoing_ports_max);
// Ignore transfer limits on local network
setItem(IGNORE_LIMIT_LAN, PROPERTY, new QTableWidgetItem(tr("Ignore transfer limits on local network")));
cb_ignore_limits_lan = new QCheckBox();
connect(cb_ignore_limits_lan, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
cb_ignore_limits_lan->setChecked(Preferences::ignoreLimitsOnLAN());
setCellWidget(IGNORE_LIMIT_LAN, VALUE, cb_ignore_limits_lan);
} }
void emitSettingsChanged() { void emitSettingsChanged() {

View file

@ -430,6 +430,8 @@ void Bittorrent::configureSession() {
// Outgoing ports // Outgoing ports
sessionSettings.outgoing_ports = std::make_pair(Preferences::outgoingPortsMin(), Preferences::outgoingPortsMax()); sessionSettings.outgoing_ports = std::make_pair(Preferences::outgoingPortsMin(), Preferences::outgoingPortsMax());
setSessionSettings(sessionSettings); setSessionSettings(sessionSettings);
// Ignore limits on LAN
sessionSettings.ignore_limits_on_local_network = Preferences::ignoreLimitsOnLAN();
// Bittorrent // Bittorrent
// * Max connections limit // * Max connections limit
setMaxConnections(Preferences::getMaxConnecs()); setMaxConnections(Preferences::getMaxConnecs());

View file

@ -858,6 +858,16 @@ public:
settings.setValue(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMax"), val); settings.setValue(QString::fromUtf8("Preferences/Advanced/OutgoingPortsMax"), val);
} }
static bool ignoreLimitsOnLAN() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Advanced/IgnoreLimitsLAN"), true).toBool();
}
static void ignoreLimitsOnLAN(bool ignore) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Advanced/IgnoreLimitsLAN"), ignore);
}
}; };
#endif // PREFERENCES_H #endif // PREFERENCES_H