mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 14:38:04 -06:00
Merge pull request #9244 from Couchy/inhibit_sleep_options
Inhibit sleep for running downloads or uploads regardless of network activity
This commit is contained in:
@@ -344,7 +344,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
m_pwr = new PowerManagement(this);
|
||||
m_preventTimer = new QTimer(this);
|
||||
connect(m_preventTimer, &QTimer::timeout, this, &MainWindow::checkForActiveTorrents);
|
||||
connect(m_preventTimer, &QTimer::timeout, this, &MainWindow::updatePowerManagementState);
|
||||
|
||||
// Configure BT session according to options
|
||||
loadPreferences(false);
|
||||
@@ -1478,7 +1478,7 @@ void MainWindow::loadPreferences(bool configureSession)
|
||||
|
||||
showStatusBar(pref->isStatusbarDisplayed());
|
||||
|
||||
if (pref->preventFromSuspend() && !m_preventTimer->isActive()) {
|
||||
if ((pref->preventFromSuspendWhenDownloading() || pref->preventFromSuspendWhenSeeding()) && !m_preventTimer->isActive()) {
|
||||
m_preventTimer->start(PREVENT_SUSPEND_INTERVAL);
|
||||
}
|
||||
else {
|
||||
@@ -2004,9 +2004,11 @@ void MainWindow::on_actionAutoShutdown_toggled(bool enabled)
|
||||
Preferences::instance()->setShutdownWhenDownloadsComplete(enabled);
|
||||
}
|
||||
|
||||
void MainWindow::checkForActiveTorrents()
|
||||
void MainWindow::updatePowerManagementState()
|
||||
{
|
||||
m_pwr->setActivityState(BitTorrent::Session::instance()->hasActiveTorrents());
|
||||
const bool inhibitSuspend = (Preferences::instance()->preventFromSuspendWhenDownloading() && BitTorrent::Session::instance()->hasUnfinishedTorrents())
|
||||
|| (Preferences::instance()->preventFromSuspendWhenSeeding() && BitTorrent::Session::instance()->hasRunningSeed());
|
||||
m_pwr->setActivityState(inhibitSuspend);
|
||||
}
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
|
||||
Reference in New Issue
Block a user