mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-09 13:24:26 +00:00
Avoid excessive power management updates
This commit is contained in:
parent
d357cdd5f9
commit
cffcf5783f
@ -323,8 +323,10 @@ MainWindow::MainWindow(IGUIApplication *app, WindowState initialState)
|
|||||||
// Initialise system sleep inhibition timer
|
// Initialise system sleep inhibition timer
|
||||||
m_pwr = new PowerManagement(this);
|
m_pwr = new PowerManagement(this);
|
||||||
m_preventTimer = new QTimer(this);
|
m_preventTimer = new QTimer(this);
|
||||||
|
m_preventTimer->setSingleShot(true);
|
||||||
connect(m_preventTimer, &QTimer::timeout, this, &MainWindow::updatePowerManagementState);
|
connect(m_preventTimer, &QTimer::timeout, this, &MainWindow::updatePowerManagementState);
|
||||||
m_preventTimer->start(PREVENT_SUSPEND_INTERVAL);
|
connect(pref, &Preferences::changed, this, &MainWindow::updatePowerManagementState);
|
||||||
|
updatePowerManagementState();
|
||||||
|
|
||||||
// Configure BT session according to options
|
// Configure BT session according to options
|
||||||
loadPreferences();
|
loadPreferences();
|
||||||
@ -1465,8 +1467,6 @@ void MainWindow::loadPreferences()
|
|||||||
|
|
||||||
showStatusBar(pref->isStatusbarDisplayed());
|
showStatusBar(pref->isStatusbarDisplayed());
|
||||||
|
|
||||||
updatePowerManagementState();
|
|
||||||
|
|
||||||
m_transferListWidget->setAlternatingRowColors(pref->useAlternatingRowColors());
|
m_transferListWidget->setAlternatingRowColors(pref->useAlternatingRowColors());
|
||||||
m_propertiesWidget->getFilesList()->setAlternatingRowColors(pref->useAlternatingRowColors());
|
m_propertiesWidget->getFilesList()->setAlternatingRowColors(pref->useAlternatingRowColors());
|
||||||
m_propertiesWidget->getTrackerList()->setAlternatingRowColors(pref->useAlternatingRowColors());
|
m_propertiesWidget->getTrackerList()->setAlternatingRowColors(pref->useAlternatingRowColors());
|
||||||
@ -1927,10 +1927,11 @@ void MainWindow::on_actionAutoShutdown_toggled(bool enabled)
|
|||||||
Preferences::instance()->setShutdownWhenDownloadsComplete(enabled);
|
Preferences::instance()->setShutdownWhenDownloadsComplete(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updatePowerManagementState()
|
void MainWindow::updatePowerManagementState() const
|
||||||
{
|
{
|
||||||
const bool preventFromSuspendWhenDownloading = Preferences::instance()->preventFromSuspendWhenDownloading();
|
const auto *pref = Preferences::instance();
|
||||||
const bool preventFromSuspendWhenSeeding = Preferences::instance()->preventFromSuspendWhenSeeding();
|
const bool preventFromSuspendWhenDownloading = pref->preventFromSuspendWhenDownloading();
|
||||||
|
const bool preventFromSuspendWhenSeeding = pref->preventFromSuspendWhenSeeding();
|
||||||
|
|
||||||
const QVector<BitTorrent::Torrent *> allTorrents = BitTorrent::Session::instance()->torrents();
|
const QVector<BitTorrent::Torrent *> allTorrents = BitTorrent::Session::instance()->torrents();
|
||||||
const bool inhibitSuspend = std::any_of(allTorrents.cbegin(), allTorrents.cend(), [&](const BitTorrent::Torrent *torrent)
|
const bool inhibitSuspend = std::any_of(allTorrents.cbegin(), allTorrents.cend(), [&](const BitTorrent::Torrent *torrent)
|
||||||
@ -1944,6 +1945,8 @@ void MainWindow::updatePowerManagementState()
|
|||||||
return torrent->isMoving();
|
return torrent->isMoving();
|
||||||
});
|
});
|
||||||
m_pwr->setActivityState(inhibitSuspend);
|
m_pwr->setActivityState(inhibitSuspend);
|
||||||
|
|
||||||
|
m_preventTimer->start(PREVENT_SUSPEND_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::applyTransferListFilter()
|
void MainWindow::applyTransferListFilter()
|
||||||
|
@ -164,7 +164,7 @@ private slots:
|
|||||||
void on_actionExit_triggered();
|
void on_actionExit_triggered();
|
||||||
void on_actionLock_triggered();
|
void on_actionLock_triggered();
|
||||||
// Check for unpaused downloading or seeding torrents and prevent system suspend/sleep according to preferences
|
// Check for unpaused downloading or seeding torrents and prevent system suspend/sleep according to preferences
|
||||||
void updatePowerManagementState();
|
void updatePowerManagementState() const;
|
||||||
|
|
||||||
void toolbarMenuRequested();
|
void toolbarMenuRequested();
|
||||||
void toolbarIconsOnly();
|
void toolbarIconsOnly();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user