From 245a8e0a3a089e72b65c3e176687a3ad22b17d20 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 31 Jan 2010 15:57:07 +0000 Subject: [PATCH] FEATURE: User can choose to include the protocol overhead in transfer limits --- Changelog | 1 + src/advancedsettings.h | 15 ++++++++++++--- src/bittorrent.cpp | 2 ++ src/preferences.h | 10 ++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 2541205db..afc0ff045 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ - FEATURE: Torrent files can be exported to a given directory - FEATURE: Outgoing ports range can be customized (for QoS) - FEATURE: User can choose to apply transfer limits on LAN too + - FEATURE: User can choose to include the protocol overhead in transfer limits * Mon Jan 18 2010 - Christophe Dumez - v2.1.0 - FEATURE: Graphical User Interface can be disabled at compilation time (headless running) diff --git a/src/advancedsettings.h b/src/advancedsettings.h index 5ae3e9864..d44365cf2 100644 --- a/src/advancedsettings.h +++ b/src/advancedsettings.h @@ -8,15 +8,15 @@ #include "preferences.h" enum AdvSettingsCols {PROPERTY, VALUE}; -enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN }; -#define ROW_COUNT 4 +enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD }; +#define ROW_COUNT 5 class AdvancedSettings: public QTableWidget { Q_OBJECT private: QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max; - QCheckBox *cb_ignore_limits_lan; + QCheckBox *cb_ignore_limits_lan, *cb_count_overhead; public: AdvancedSettings(QWidget *parent=0): QTableWidget(parent) { @@ -38,6 +38,7 @@ public: delete outgoing_ports_min; delete outgoing_ports_max; delete cb_ignore_limits_lan; + delete cb_count_overhead; } public slots: @@ -49,6 +50,8 @@ public: Preferences::setOutgoingPortsMax(outgoing_ports_max->value()); // Ignore limits on LAN Preferences::ignoreLimitsOnLAN(cb_ignore_limits_lan->isChecked()); + // Include protocol overhead in transfer limits + Preferences::includeOverheadInLimits(cb_count_overhead->isChecked()); } protected slots: @@ -83,6 +86,12 @@ protected slots: 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); + // Consider protocol overhead in transfer limits + setItem(COUNT_OVERHEAD, PROPERTY, new QTableWidgetItem(tr("Include TCP/IP overhead in transfer limits"))); + cb_count_overhead = new QCheckBox(); + connect(cb_count_overhead, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); + cb_count_overhead->setChecked(Preferences::includeOverheadInLimits()); + setCellWidget(COUNT_OVERHEAD, VALUE, cb_count_overhead); } void emitSettingsChanged() { diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index e1d02170d..bc0d99d05 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -432,6 +432,8 @@ void Bittorrent::configureSession() { setSessionSettings(sessionSettings); // Ignore limits on LAN sessionSettings.ignore_limits_on_local_network = Preferences::ignoreLimitsOnLAN(); + // Include overhead in transfer limits + sessionSettings.rate_limit_ip_overhead = Preferences::includeOverheadInLimits(); // Bittorrent // * Max connections limit setMaxConnections(Preferences::getMaxConnecs()); diff --git a/src/preferences.h b/src/preferences.h index 656c832b9..9f770d907 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -868,6 +868,16 @@ public: settings.setValue(QString::fromUtf8("Preferences/Advanced/IgnoreLimitsLAN"), ignore); } + static bool includeOverheadInLimits() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Advanced/IncludeOverhead"), false).toBool(); + } + + static void includeOverheadInLimits(bool include) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Advanced/IncludeOverhead"), include); + } + }; #endif // PREFERENCES_H