From 77239db3c59abdf41f5af6d1582d8232d3c09652 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 31 Jan 2010 16:14:56 +0000 Subject: [PATCH] FEATURE: Torrents can be automatically rechecked on completion --- Changelog | 1 + src/advancedsettings.h | 17 +++++++++++++---- src/bittorrent.cpp | 3 +++ src/preferences.h | 10 ++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index afc0ff045..45110f761 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,7 @@ - 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 + - FEATURE: Torrents can be automatically rechecked on completion * 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 d44365cf2..2cfb47d6d 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 }; -#define ROW_COUNT 5 +enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED }; +#define ROW_COUNT 6 class AdvancedSettings: public QTableWidget { Q_OBJECT private: QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max; - QCheckBox *cb_ignore_limits_lan, *cb_count_overhead; + QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed; public: AdvancedSettings(QWidget *parent=0): QTableWidget(parent) { @@ -39,9 +39,10 @@ public: delete outgoing_ports_max; delete cb_ignore_limits_lan; delete cb_count_overhead; + delete cb_recheck_completed; } - public slots: +public slots: void saveAdvancedSettings() { // Disk write cache Preferences::setDiskCacheSize(spin_cache->value()); @@ -52,6 +53,8 @@ public: Preferences::ignoreLimitsOnLAN(cb_ignore_limits_lan->isChecked()); // Include protocol overhead in transfer limits Preferences::includeOverheadInLimits(cb_count_overhead->isChecked()); + // Recheck torrents on completion + Preferences::recheckTorrentsOnCompletion(cb_recheck_completed->isChecked()); } protected slots: @@ -92,6 +95,12 @@ protected slots: connect(cb_count_overhead, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); cb_count_overhead->setChecked(Preferences::includeOverheadInLimits()); setCellWidget(COUNT_OVERHEAD, VALUE, cb_count_overhead); + // Recheck completed torrents + setItem(RECHECK_COMPLETED, PROPERTY, new QTableWidgetItem(tr("Recheck torrents on completion"))); + cb_recheck_completed = new QCheckBox(); + connect(cb_recheck_completed, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); + cb_recheck_completed->setChecked(Preferences::recheckTorrentsOnCompletion()); + setCellWidget(RECHECK_COMPLETED, VALUE, cb_recheck_completed); } void emitSettingsChanged() { diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index bc0d99d05..a526578ee 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -1845,6 +1845,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { } } } + // Recheck if the user asked to + if(Preferences::recheckTorrentsOnCompletion()) + h.force_recheck(); qDebug("Received finished alert for %s", h.name().toLocal8Bit().data()); } } diff --git a/src/preferences.h b/src/preferences.h index 9f770d907..9c0ff7e64 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -878,6 +878,16 @@ public: settings.setValue(QString::fromUtf8("Preferences/Advanced/IncludeOverhead"), include); } + static bool recheckTorrentsOnCompletion() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Advanced/RecheckOnCompletion"), false).toBool(); + } + + static void recheckTorrentsOnCompletion(bool recheck) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Advanced/RecheckOnCompletion"), recheck); + } + }; #endif // PREFERENCES_H