Browse Source

FEATURE: Added feature to shutdown qbittorrent on torrents completion

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
86fb4a323a
  1. 3
      Changelog
  2. 6
      src/GUI.cpp
  3. 1
      src/GUI.h
  4. 10
      src/preferences.h
  5. 37
      src/qtlibtorrent/qbtsession.cpp
  6. 11
      src/ui/mainwindow.ui

3
Changelog

@ -1,3 +1,6 @@
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.5.0
- FEATURE: Added feature to shutdown qbittorrent on torrents completion
* Tue Aug 24 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.4.0 * Tue Aug 24 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.4.0
- FEATURE: Added actions to "Move to top/bottom" of priority queue - FEATURE: Added actions to "Move to top/bottom" of priority queue
- FEATURE: Auto-Shutdown on downloads completion - FEATURE: Auto-Shutdown on downloads completion

6
src/GUI.cpp

@ -202,6 +202,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), for
displaySearchTab(actionSearch_engine->isChecked()); displaySearchTab(actionSearch_engine->isChecked());
displayRSSTab(actionRSS_Reader->isChecked()); displayRSSTab(actionRSS_Reader->isChecked());
actionShutdown_when_downloads_complete->setChecked(Preferences::shutdownWhenDownloadsComplete()); actionShutdown_when_downloads_complete->setChecked(Preferences::shutdownWhenDownloadsComplete());
actionShutdown_qBittorrent_when_downloads_complete->setChecked(Preferences::shutdownqBTWhenDownloadsComplete());
show(); show();
@ -1178,6 +1179,11 @@ void GUI::on_actionShutdown_when_downloads_complete_triggered() {
Preferences::setShutdownWhenDownloadsComplete(is_checked); Preferences::setShutdownWhenDownloadsComplete(is_checked);
} }
void GUI::on_actionShutdown_qBittorrent_when_downloads_complete_triggered() {
bool is_checked = static_cast<QAction*>(sender())->isChecked();
Preferences::setShutdownqBTWhenDownloadsComplete(is_checked);
}
void GUI::on_actionSpeed_in_title_bar_triggered() { void GUI::on_actionSpeed_in_title_bar_triggered() {
displaySpeedInTitle = static_cast<QAction*>(sender())->isChecked(); displaySpeedInTitle = static_cast<QAction*>(sender())->isChecked();
Preferences::showSpeedInTitleBar(displaySpeedInTitle); Preferences::showSpeedInTitleBar(displaySpeedInTitle);

1
src/GUI.h

@ -183,6 +183,7 @@ private slots:
void on_actionSpeed_in_title_bar_triggered(); void on_actionSpeed_in_title_bar_triggered();
void on_actionTop_tool_bar_triggered(); void on_actionTop_tool_bar_triggered();
void on_actionShutdown_when_downloads_complete_triggered(); void on_actionShutdown_when_downloads_complete_triggered();
void on_actionShutdown_qBittorrent_when_downloads_complete_triggered();
}; };
#endif #endif

10
src/preferences.h

@ -935,6 +935,16 @@ public:
settings.setValue(QString::fromUtf8("Preferences/Downloads/AutoShutDownOnCompletion"), shutdown); 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() { static uint diskCacheSize() {
QIniSettings settings("qBittorrent", "qBittorrent"); QIniSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Downloads/DiskCache"), 16).toUInt(); return settings.value(QString::fromUtf8("Preferences/Downloads/DiskCache"), 16).toUInt();

37
src/qtlibtorrent/qbtsession.cpp

@ -2048,14 +2048,14 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
} }
} }
} }
} // Move to download directory if necessary
// Move to download directory if necessary if(!defaultTempPath.isEmpty()) {
if(!defaultTempPath.isEmpty()) { // Check if directory is different
// Check if directory is different const QDir current_dir(h.save_path());
const QDir current_dir(h.save_path()); const QDir save_dir(getSavePath(hash));
const QDir save_dir(getSavePath(hash)); if(current_dir != save_dir) {
if(current_dir != save_dir) { h.move_storage(save_dir.absolutePath());
h.move_storage(save_dir.absolutePath()); }
} }
// Remember finished state // Remember finished state
TorrentPersistentData::saveSeedStatus(h); TorrentPersistentData::saveSeedStatus(h);
@ -2065,7 +2065,8 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
} }
emit finishedTorrent(h); emit finishedTorrent(h);
qDebug("Received finished alert for %s", qPrintable(h.name())); 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 // AutoRun program
if(Preferences::isAutoRunEnabled()) if(Preferences::isAutoRunEnabled())
autoRunExternalProgram(h, will_shutdown); autoRunExternalProgram(h, will_shutdown);
@ -2074,16 +2075,18 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
sendNotificationEmail(h); sendNotificationEmail(h);
// Auto-Shutdown // Auto-Shutdown
if(will_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 #if LIBTORRENT_VERSION_MINOR < 15
saveDHTEntry(); saveDHTEntry();
#endif #endif
qDebug("Saving session state"); qDebug("Saving session state");
saveSessionState(); saveSessionState();
qDebug("Saving fast resume data"); qDebug("Saving fast resume data");
saveFastResumeData(); saveFastResumeData();
qDebug("Sending computer shutdown signal"); qDebug("Sending computer shutdown signal");
misc::shutdownComputer(); misc::shutdownComputer();
}
qDebug("Exiting the application"); qDebug("Exiting the application");
qApp->exit(); qApp->exit();
return; return;

11
src/ui/mainwindow.ui

@ -29,7 +29,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>914</width> <width>914</width>
<height>23</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menu_Edit"> <widget class="QMenu" name="menu_Edit">
@ -66,6 +66,7 @@
<addaction name="actionOptions"/> <addaction name="actionOptions"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionShutdown_when_downloads_complete"/> <addaction name="actionShutdown_when_downloads_complete"/>
<addaction name="actionShutdown_qBittorrent_when_downloads_complete"/>
</widget> </widget>
<widget class="QMenu" name="menu_File"> <widget class="QMenu" name="menu_File">
<property name="title"> <property name="title">
@ -348,6 +349,14 @@
<string>Ctrl+L</string> <string>Ctrl+L</string>
</property> </property>
</action> </action>
<action name="actionShutdown_qBittorrent_when_downloads_complete">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Shutdown qBittorrent when downloads complete</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../icons.qrc"/> <include location="../icons.qrc"/>

Loading…
Cancel
Save