mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Add option to hibernate computer in Auto-Shutdown menu
This commit is contained in:
parent
273725d9dc
commit
00e09435b2
8 changed files with 59 additions and 13 deletions
|
@ -197,8 +197,8 @@ QBtSession::~QBtSession() {
|
|||
qDebug("BTSession destructor OUT");
|
||||
#ifndef DISABLE_GUI
|
||||
if (m_shutdownAct != NO_SHUTDOWN) {
|
||||
qDebug() << "Sending computer shutdown/suspend signal...";
|
||||
misc::shutdownComputer(m_shutdownAct == SUSPEND_COMPUTER);
|
||||
qDebug() << "Sending computer shutdown/suspend/hibernate signal...";
|
||||
misc::shutdownComputer(m_shutdownAct);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -2282,7 +2282,8 @@ void QBtSession::handleTorrentFinishedAlert(libtorrent::torrent_finished_alert*
|
|||
#ifndef DISABLE_GUI
|
||||
bool will_shutdown = (pref.shutdownWhenDownloadsComplete() ||
|
||||
pref.shutdownqBTWhenDownloadsComplete() ||
|
||||
pref.suspendWhenDownloadsComplete())
|
||||
pref.suspendWhenDownloadsComplete() ||
|
||||
pref.hibernateWhenDownloadsComplete())
|
||||
&& !hasDownloadingTorrents();
|
||||
#else
|
||||
bool will_shutdown = false;
|
||||
|
@ -2300,11 +2301,14 @@ void QBtSession::handleTorrentFinishedAlert(libtorrent::torrent_finished_alert*
|
|||
// Auto-Shutdown
|
||||
if (will_shutdown) {
|
||||
bool suspend = pref.suspendWhenDownloadsComplete();
|
||||
bool hibernate = pref.hibernateWhenDownloadsComplete();
|
||||
bool shutdown = pref.shutdownWhenDownloadsComplete();
|
||||
// Confirm shutdown
|
||||
QString confirm_msg;
|
||||
if (suspend) {
|
||||
confirm_msg = tr("The computer will now go to sleep mode unless you cancel within the next 15 seconds...");
|
||||
} else if (hibernate) {
|
||||
confirm_msg = tr("The computer will now go to hibernation mode unless you cancel within the next 15 seconds...");
|
||||
} else if (shutdown) {
|
||||
confirm_msg = tr("The computer will now be switched off unless you cancel within the next 15 seconds...");
|
||||
} else {
|
||||
|
@ -2313,14 +2317,17 @@ void QBtSession::handleTorrentFinishedAlert(libtorrent::torrent_finished_alert*
|
|||
if (!ShutdownConfirmDlg::askForConfirmation(confirm_msg))
|
||||
return;
|
||||
// Actually shut down
|
||||
if (suspend || shutdown) {
|
||||
if (suspend || hibernate || shutdown) {
|
||||
qDebug("Preparing for auto-shutdown because all downloads are complete!");
|
||||
// Disabling it for next time
|
||||
pref.setShutdownWhenDownloadsComplete(false);
|
||||
pref.setSuspendWhenDownloadsComplete(false);
|
||||
pref.setHibernateWhenDownloadsComplete(false);
|
||||
// Make sure preferences are synced before exiting
|
||||
if (suspend)
|
||||
m_shutdownAct = SUSPEND_COMPUTER;
|
||||
else if (hibernate)
|
||||
m_shutdownAct = HIBERNATE_COMPUTER;
|
||||
else
|
||||
m_shutdownAct = SHUTDOWN_COMPUTER;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue