mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-01 01:16:01 +00:00
FEATURE: Added feature to shutdown qbittorrent on torrents completion
This commit is contained in:
parent
38c56a2b5f
commit
86fb4a323a
@ -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
|
||||
- FEATURE: Added actions to "Move to top/bottom" of priority queue
|
||||
- FEATURE: Auto-Shutdown on downloads completion
|
||||
|
@ -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<QAction*>(sender())->isChecked();
|
||||
Preferences::setShutdownqBTWhenDownloadsComplete(is_checked);
|
||||
}
|
||||
|
||||
void GUI::on_actionSpeed_in_title_bar_triggered() {
|
||||
displaySpeedInTitle = static_cast<QAction*>(sender())->isChecked();
|
||||
Preferences::showSpeedInTitleBar(displaySpeedInTitle);
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -29,7 +29,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>914</width>
|
||||
<height>23</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_Edit">
|
||||
@ -66,6 +66,7 @@
|
||||
<addaction name="actionOptions"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionShutdown_when_downloads_complete"/>
|
||||
<addaction name="actionShutdown_qBittorrent_when_downloads_complete"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
<property name="title">
|
||||
@ -348,6 +349,14 @@
|
||||
<string>Ctrl+L</string>
|
||||
</property>
|
||||
</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>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user