From 86c098af7b7b01442a06f5a7884decb1e489d733 Mon Sep 17 00:00:00 2001 From: liudun Date: Wed, 10 Apr 2024 10:59:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A7=E5=88=B6=E9=9D=A2=E6=9D=BF=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=B0=B8=E4=B8=8D=E8=BF=9B=E5=85=A5=E5=B1=8F=E4=BF=9D?= =?UTF-8?q?=E4=B8=80=E5=88=86=E9=92=9F=E5=90=8E=20=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=80=8F=E6=98=8E=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/configuration.cpp | 10 +++++++++- src/configuration.h | 1 + src/fullbackgroundwidget.cpp | 3 ++- src/ukui-screensaver-dialog.cpp | 6 ++++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/configuration.cpp b/src/configuration.cpp index c8fa335..c053b71 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -32,6 +32,7 @@ #define KEY_THEMES "themes" #define KEY_IDLE_ACTIVATION_ENABLED "idle-activation-enabled" #define KEY_LOCK_ENABLED "lock-enabled" +#define KEY_IDLE_DELAY "idle-delay" #define KEY_IMAGE_TRANSITION_EFFECT "image-transition-effect" #define KEY_IMAGE_SWITCH_INTERVAL "image-switch-interval" #define KEY_BACKGROUND "background" @@ -51,6 +52,7 @@ Configuration::Configuration(QObject *parent) : QObject(parent) themes = gsettings->get(KEY_THEMES).toStringList(); idleActivationEnabled = gsettings->get( KEY_IDLE_ACTIVATION_ENABLED).toBool(); + idleDelay = gsettings->get(KEY_IDLE_DELAY).toInt(); lockEnabled = gsettings->get(KEY_LOCK_ENABLED).toBool(); imageSwitchInterval = gsettings->get(KEY_IMAGE_SWITCH_INTERVAL).toInt(); imageTSEffect = gsettings->get(KEY_IMAGE_TRANSITION_EFFECT).toInt(); @@ -115,6 +117,9 @@ void Configuration::onConfigurationChanged(QString key) imageTSEffect = gsettings->get(KEY_IMAGE_TRANSITION_EFFECT).toInt(); else if(key == KEY_IMAGE_SWITCH_INTERVAL) imageSwitchInterval = gsettings->get(KEY_IMAGE_SWITCH_INTERVAL).toInt(); + else if (key == KEY_IDLE_DELAY) { + idleDelay = gsettings->get(KEY_IDLE_DELAY).toInt(); + } } /* @@ -204,7 +209,10 @@ QString Configuration::getBackground() bool Configuration::xscreensaverActivatedWhenIdle() { - return idleActivationEnabled; + if (idleDelay <= 0) + return false; + else + return idleActivationEnabled; } bool Configuration::lockWhenXScreensaverActivated() diff --git a/src/configuration.h b/src/configuration.h index d70e8cf..eb7149f 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -56,6 +56,7 @@ private: QString background; bool idleActivationEnabled; bool lockEnabled; + int idleDelay; int imageTSEffect; int imageSwitchInterval; static Configuration *instance_; diff --git a/src/fullbackgroundwidget.cpp b/src/fullbackgroundwidget.cpp index de67b68..49b3fc3 100644 --- a/src/fullbackgroundwidget.cpp +++ b/src/fullbackgroundwidget.cpp @@ -680,7 +680,7 @@ int FullBackgroundWidget::onSessionStatusChanged(uint status) showScreensaver(); #else if(configuration->xscreensaverActivatedWhenIdle() && - configuration->lockWhenXScreensaverActivated()) + configuration->lockWhenXScreensaverActivated() && idleDelay != -1) { //显示锁屏和屏保 showLockWidget(); @@ -929,6 +929,7 @@ void FullBackgroundWidget::onConfigurationDelayChanged(QString key) { if(key == KEY_IDLE_DELAY){ idleDelay = settings_delay->get("idle-delay").toInt(); + qDebug()<<"idleDelay="<onSessionStatusChanged(SESSION_IDLE) == -1) - return 0; + if(window->onSessionStatusChanged(SESSION_IDLE) == -1) { + window->close(); + return 0; + } } if(parser.isSet(lscreensaverOption))