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:
sledgehammer999 2018-08-12 16:31:01 +03:00 committed by GitHub
commit 366239ca7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 72 additions and 36 deletions

View file

@ -255,14 +255,24 @@ void Preferences::setSplashScreenDisabled(bool b)
}
// Preventing from system suspend while active torrents are presented.
bool Preferences::preventFromSuspend() const
bool Preferences::preventFromSuspendWhenDownloading() const
{
return value("Preferences/General/PreventFromSuspend", false).toBool();
return value("Preferences/General/PreventFromSuspendWhenDownloading", false).toBool();
}
void Preferences::setPreventFromSuspend(bool b)
void Preferences::setPreventFromSuspendWhenDownloading(bool b)
{
setValue("Preferences/General/PreventFromSuspend", b);
setValue("Preferences/General/PreventFromSuspendWhenDownloading", b);
}
bool Preferences::preventFromSuspendWhenSeeding() const
{
return value("Preferences/General/PreventFromSuspendWhenSeeding", false).toBool();
}
void Preferences::setPreventFromSuspendWhenSeeding(bool b)
{
setValue("Preferences/General/PreventFromSuspendWhenSeeding", b);
}
#ifdef Q_OS_WIN
@ -1582,6 +1592,8 @@ void Preferences::setSpeedWidgetGraphEnable(int id, const bool enable)
void Preferences::upgrade()
{
SettingsStorage *settingsStorage = SettingsStorage::instance();
QStringList labels = value("TransferListFilters/customLabels").toStringList();
if (!labels.isEmpty()) {
QVariantMap categories = value("BitTorrent/Session/Categories").toMap();
@ -1590,10 +1602,17 @@ void Preferences::upgrade()
categories[label] = "";
}
setValue("BitTorrent/Session/Categories", categories);
SettingsStorage::instance()->removeValue("TransferListFilters/customLabels");
settingsStorage->removeValue("TransferListFilters/customLabels");
}
SettingsStorage::instance()->removeValue("Preferences/Downloads/AppendLabel");
settingsStorage->removeValue("Preferences/Downloads/AppendLabel");
// Inhibit sleep based on running downloads/available seeds rather than network activity.
if (value("Preferences/General/PreventFromSuspend", false).toBool()) {
setPreventFromSuspendWhenDownloading(true);
setPreventFromSuspendWhenSeeding(true);
}
settingsStorage->removeValue("Preferences/General/PreventFromSuspend");
}
void Preferences::apply()