From fb874695c9b225bc11d4d5a02629942df803599a Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 25 Mar 2010 19:31:48 +0000 Subject: [PATCH] Added support for strict super seeding --- Changelog | 1 + src/advancedsettings.h | 22 +++++++++++++++++++--- src/preferences.h | 12 ++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 3e5c5c997..6ac911dea 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ * Unreleased - Christophe Dumez - v2.3.0 - FEATURE: Max number of half-open connections can now be edited + - FEATURE: Added support for strict super seeding * Sun Mar 14 2010 - Christophe Dumez - v2.2.0 - FEATURE: User can set alternative speed limits for fast toggling diff --git a/src/advancedsettings.h b/src/advancedsettings.h index d5cd0a8e0..c90e9f330 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, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN }; -#define ROW_COUNT 10 +enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING }; +#define ROW_COUNT 11 class AdvancedSettings: public QTableWidget { Q_OBJECT private: QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh, *spin_maxhalfopen; - QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts; + QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts, *cb_super_seeding; public: AdvancedSettings(QWidget *parent=0): QTableWidget(parent) { @@ -46,6 +46,7 @@ public: delete cb_resolve_countries; delete cb_resolve_hosts; delete spin_maxhalfopen; + delete cb_super_seeding; } public slots: @@ -68,6 +69,10 @@ public slots: Preferences::resolvePeerHostNames(cb_resolve_hosts->isChecked()); // Max Half-Open connections Preferences::setMaxHalfOpenConnections(spin_maxhalfopen->value()); +#ifdef LIBTORRENT_0_15 + // Super seeding + Preferences::enableSuperSeeding(cb_super_seeding->isChecked()); +#endif } protected slots: @@ -143,6 +148,17 @@ protected slots: spin_maxhalfopen->setMinimum(0); spin_maxhalfopen->setMaximum(99999); spin_maxhalfopen->setValue(Preferences::getMaxHalfOpenConnections()); + setCellWidget(MAX_HALF_OPEN, VALUE, spin_maxhalfopen); + // Super seeding + setItem(SUPER_SEEDING, PROPERTY, new QTableWidgetItem(tr("Strict super seeding"))); + cb_super_seeding = new QCheckBox(); + connect(cb_super_seeding, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); + #ifdef LIBTORRENT_0_15 + cb_super_seeding->setChecked(Preferences::isSuperSeedingEnabled()); +#else + cb_super_seeding->setEnabled(false); +#endif + setCellWidget(SUPER_SEEDING, VALUE, cb_super_seeding); } void emitSettingsChanged() { diff --git a/src/preferences.h b/src/preferences.h index aa0dc08cd..e9ad47b0f 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -929,6 +929,18 @@ public: settings.setValue(QString::fromUtf8("Preferences/Connection/MaxHalfOpenConnec"), value); } +#ifdef LIBTORRENT_0_15 + static bool isSuperSeedingEnabled() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), false).toBool(); + } + + static void enableSuperSeeding(bool enabled) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Advanced/SuperSeeding"), enabled); + } +#endif + }; #endif // PREFERENCES_H