Skip to content

Commit

Permalink
feat: inhibit hibernate (sleep) feature in windows when xfers are ac…
Browse files Browse the repository at this point in the history
…tive. fixes transmission#195
  • Loading branch information
ericfrazer committed Dec 20, 2023
1 parent 7c9e04d commit b3d8867
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions qt/MainWindow.cc
Expand Up @@ -859,6 +859,22 @@ void MainWindow::refreshStatusBar(TransferStats const& stats)
}

ui_.statsLabel->setText(str);

if (prefs_.getBool(Prefs::INHIBIT_HIBERNATION))
{
if (stats.peers_sending || stats.peers_receiving)
{
::SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED); // transfers in progress, inhibit sleep
}
else
{
::SetThreadExecutionState(ES_CONTINUOUS); // no transfers, allow sleep
}
}
else
{
::SetThreadExecutionState(ES_CONTINUOUS); // no transfers, allow sleep
}
}

void MainWindow::refreshTorrentViewHeader()
Expand Down
1 change: 1 addition & 0 deletions qt/PrefsDialog.cc
Expand Up @@ -422,6 +422,7 @@ void PrefsDialog::initSpeedTab()

void PrefsDialog::initDesktopTab()
{
linkWidgetToPref(ui_.inhibitHibernationCheck, Prefs::INHIBIT_HIBERNATION);
linkWidgetToPref(ui_.showTrayIconCheck, Prefs::SHOW_TRAY_ICON);
linkWidgetToPref(ui_.startMinimizedCheck, Prefs::START_MINIMIZED);
linkWidgetToPref(ui_.notifyOnTorrentAddedCheck, Prefs::SHOW_NOTIFICATION_ON_ADD);
Expand Down
7 changes: 7 additions & 0 deletions qt/PrefsDialog.ui
Expand Up @@ -1072,6 +1072,13 @@
<property name="leftMargin">
<number>18</number>
</property>
<item>
<widget class="QCheckBox" name="inhibitHibernationCheck">
<property name="text">
<string>&amp;Inhibit hibernation when torrents are active</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showTrayIconCheck">
<property name="text">
Expand Down

0 comments on commit b3d8867

Please sign in to comment.