diff --git a/Changelog b/Changelog index ec21b0fd6..3efea5e1b 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +* Unreleased - Christophe Dumez - v2.5.0 + - FEATURE: Added feature to shutdown qbittorrent on torrents completion + * Tue Aug 24 2010 - Christophe Dumez - v2.4.0 - FEATURE: Added actions to "Move to top/bottom" of priority queue - FEATURE: Auto-Shutdown on downloads completion diff --git a/src/GUI.cpp b/src/GUI.cpp index 57aefbcee..f43baa385 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -202,6 +202,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), for displaySearchTab(actionSearch_engine->isChecked()); displayRSSTab(actionRSS_Reader->isChecked()); actionShutdown_when_downloads_complete->setChecked(Preferences::shutdownWhenDownloadsComplete()); + actionShutdown_qBittorrent_when_downloads_complete->setChecked(Preferences::shutdownqBTWhenDownloadsComplete()); show(); @@ -1178,6 +1179,11 @@ void GUI::on_actionShutdown_when_downloads_complete_triggered() { Preferences::setShutdownWhenDownloadsComplete(is_checked); } +void GUI::on_actionShutdown_qBittorrent_when_downloads_complete_triggered() { + bool is_checked = static_cast(sender())->isChecked(); + Preferences::setShutdownqBTWhenDownloadsComplete(is_checked); +} + void GUI::on_actionSpeed_in_title_bar_triggered() { displaySpeedInTitle = static_cast(sender())->isChecked(); Preferences::showSpeedInTitleBar(displaySpeedInTitle); diff --git a/src/GUI.h b/src/GUI.h index 35920b63c..18f0cefff 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -183,6 +183,7 @@ private slots: void on_actionSpeed_in_title_bar_triggered(); void on_actionTop_tool_bar_triggered(); void on_actionShutdown_when_downloads_complete_triggered(); + void on_actionShutdown_qBittorrent_when_downloads_complete_triggered(); }; #endif diff --git a/src/preferences.h b/src/preferences.h index 9fab11e18..74cc5bb3c 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -935,6 +935,16 @@ public: settings.setValue(QString::fromUtf8("Preferences/Downloads/AutoShutDownOnCompletion"), shutdown); } + static bool shutdownqBTWhenDownloadsComplete() { + QIniSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Downloads/AutoShutDownqBTOnCompletion"), false).toBool(); + } + + static void setShutdownqBTWhenDownloadsComplete(bool shutdown) { + QIniSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Downloads/AutoShutDownqBTOnCompletion"), shutdown); + } + static uint diskCacheSize() { QIniSettings settings("qBittorrent", "qBittorrent"); return settings.value(QString::fromUtf8("Preferences/Downloads/DiskCache"), 16).toUInt(); diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index ceb3997ba..965911e55 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -2048,14 +2048,14 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { } } } - } - // Move to download directory if necessary - if(!defaultTempPath.isEmpty()) { - // Check if directory is different - const QDir current_dir(h.save_path()); - const QDir save_dir(getSavePath(hash)); - if(current_dir != save_dir) { - h.move_storage(save_dir.absolutePath()); + // Move to download directory if necessary + if(!defaultTempPath.isEmpty()) { + // Check if directory is different + const QDir current_dir(h.save_path()); + const QDir save_dir(getSavePath(hash)); + if(current_dir != save_dir) { + h.move_storage(save_dir.absolutePath()); + } } // Remember finished state TorrentPersistentData::saveSeedStatus(h); @@ -2065,7 +2065,8 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { } emit finishedTorrent(h); qDebug("Received finished alert for %s", qPrintable(h.name())); - bool will_shutdown = Preferences::shutdownWhenDownloadsComplete() && !hasDownloadingTorrents(); + bool will_shutdown = (Preferences::shutdownWhenDownloadsComplete() || Preferences::shutdownqBTWhenDownloadsComplete()) + && !hasDownloadingTorrents(); // AutoRun program if(Preferences::isAutoRunEnabled()) autoRunExternalProgram(h, will_shutdown); @@ -2074,16 +2075,18 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { sendNotificationEmail(h); // Auto-Shutdown if(will_shutdown) { - qDebug("Preparing for auto-shutdown because all downloads are complete!"); + if(Preferences::shutdownWhenDownloadsComplete()) { + qDebug("Preparing for auto-shutdown because all downloads are complete!"); #if LIBTORRENT_VERSION_MINOR < 15 - saveDHTEntry(); + saveDHTEntry(); #endif - qDebug("Saving session state"); - saveSessionState(); - qDebug("Saving fast resume data"); - saveFastResumeData(); - qDebug("Sending computer shutdown signal"); - misc::shutdownComputer(); + qDebug("Saving session state"); + saveSessionState(); + qDebug("Saving fast resume data"); + saveFastResumeData(); + qDebug("Sending computer shutdown signal"); + misc::shutdownComputer(); + } qDebug("Exiting the application"); qApp->exit(); return; diff --git a/src/ui/mainwindow.ui b/src/ui/mainwindow.ui index 85806b14b..2983946e7 100644 --- a/src/ui/mainwindow.ui +++ b/src/ui/mainwindow.ui @@ -29,7 +29,7 @@ 0 0 914 - 23 + 21 @@ -66,6 +66,7 @@ + @@ -348,6 +349,14 @@ Ctrl+L + + + true + + + Shutdown qBittorrent when downloads complete + +