From 86e5c8c11cfd2dd883f035b339989647721d1552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 9 Feb 2024 19:46:23 +0100 Subject: [PATCH] Update config Add screen saver timeout (default 5min). --- src/powerkit_common.h | 1 + src/powerkit_dialog.cpp | 24 +++++++++++++++++++++++- src/powerkit_dialog.h | 3 +++ src/powerkit_screensaver.cpp | 2 -- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/powerkit_common.h b/src/powerkit_common.h index 13ef670..0d78921 100644 --- a/src/powerkit_common.h +++ b/src/powerkit_common.h @@ -160,5 +160,6 @@ namespace PowerKit #define PK_SCREENSAVER_SERVICE "org.freedesktop.ScreenSaver" #define PK_SCREENSAVER_PATH_ROOT "/ScreenSaver" #define PK_SCREENSAVER_PATH_FULL "/org/freedesktop/ScreenSaver" +#define PK_SCREENSAVER_TIMEOUT_BLANK 300 #endif // POWERKIT_COMMON_H diff --git a/src/powerkit_dialog.cpp b/src/powerkit_dialog.cpp index d1db709..c69d62b 100644 --- a/src/powerkit_dialog.cpp +++ b/src/powerkit_dialog.cpp @@ -52,6 +52,7 @@ Dialog::Dialog(QWidget *parent, , batteryStatusLabel(nullptr) , cpuFreqLabel(nullptr) , cpuTempLabel(nullptr) + , screensaverBlank(nullptr) , hasCpuCoreTemp(false) , hasBattery(false) { @@ -451,7 +452,18 @@ void Dialog::setupWidgets() // screensaver QGroupBox *ssContainer = new QGroupBox(this); ssContainer->setTitle(tr("Screen saver")); - //QVBoxLayout *ssContainerLayout = new QVBoxLayout(ssContainer); + QHBoxLayout *ssContainerLayout = new QHBoxLayout(ssContainer); + + const auto screensaverBlankLabel = new QLabel(tr("Timeout"), this); + screensaverBlank = new QSpinBox(this); + screensaverBlank->setMaximumWidth(MAX_WIDTH); + screensaverBlank->setMinimumWidth(MAX_WIDTH); + screensaverBlank->setMinimum(1); + screensaverBlank->setMaximum(1000); + screensaverBlank->setSuffix(QString(" %1").arg(tr("min"))); + + ssContainerLayout->addWidget(screensaverBlankLabel); + ssContainerLayout->addWidget(screensaverBlank); // notify QGroupBox *notifyContainer = new QGroupBox(this); @@ -635,6 +647,8 @@ void Dialog::connectWidgets() this, SLOT(handleNotifyNewInhibitor(bool))); connect(backlightMouseWheel, SIGNAL(toggled(bool)), this, SLOT(handleBacklightMouseWheel(bool))); + connect(screensaverBlank, SIGNAL(valueChanged(int)), + this, SLOT(handleScreensaverBlank(int))); } // load settings and set defaults @@ -791,6 +805,9 @@ void Dialog::loadSettings() enableLid(Client::lidIsPresent(dbus)); hasCpuCoreTemp = Cpu::hasCoreTemp(); if (!hasCpuCoreTemp) { cpuTempLabel->setVisible(false); } + + screensaverBlank->setValue(Settings::getValue(CONF_SCREENSAVER_TIMEOUT_BLANK, + PK_SCREENSAVER_TIMEOUT_BLANK).toInt() / 60); } void Dialog::saveSettings() @@ -1163,3 +1180,8 @@ void Dialog::handleBacklightMouseWheel(bool triggered) { Settings::setValue(CONF_BACKLIGHT_MOUSE_WHEEL, triggered); } + +void Dialog::handleScreensaverBlank(int value) +{ + Settings::setValue(CONF_SCREENSAVER_TIMEOUT_BLANK, value * 60); +} diff --git a/src/powerkit_dialog.h b/src/powerkit_dialog.h index 3c1e89d..efedf1d 100644 --- a/src/powerkit_dialog.h +++ b/src/powerkit_dialog.h @@ -77,6 +77,8 @@ namespace PowerKit QLabel *cpuFreqLabel; QLabel *cpuTempLabel; + QSpinBox *screensaverBlank; + bool hasCpuCoreTemp; bool hasBattery; @@ -124,6 +126,7 @@ namespace PowerKit void handleNotifyNewInhibitor(bool triggered); void enableLid(bool enabled); void handleBacklightMouseWheel(bool triggered); + void handleScreensaverBlank(int value); }; } diff --git a/src/powerkit_screensaver.cpp b/src/powerkit_screensaver.cpp index fea9cca..3828ee1 100644 --- a/src/powerkit_screensaver.cpp +++ b/src/powerkit_screensaver.cpp @@ -42,8 +42,6 @@ #define PK_SCREENSAVER_TIMER 10000 #define PK_SCREENSAVER_MAX_INHIBIT 18000 #define PK_SCREENSAVER_ACTIVITY "SimulateUserActivity" -#define PK_SCREENSAVER_TIMEOUT_BLANK 300 -#define PK_SCREENSAVER_TIMEOUT_LOCK 250 using namespace PowerKit;