From c78d50fb5ca351d6281aab8f73cbe58c50164127 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sat, 16 Oct 2021 14:13:54 +0300 Subject: [PATCH] Expose sleep and hibernate actions in the lock screen kscreenlocker implements sleep and hibernate requests, but they aren't wired anywhere in. Besides that, it can be useful to have a quick way to suspend or hibernate computer from lockscreen. --- lookandfeel/contents/lockscreen/LockScreen.qml | 10 +++++++++- lookandfeel/contents/lockscreen/LockScreenUi.qml | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lookandfeel/contents/lockscreen/LockScreen.qml b/lookandfeel/contents/lockscreen/LockScreen.qml index 229397c9a..7603ed8d1 100644 --- a/lookandfeel/contents/lockscreen/LockScreen.qml +++ b/lookandfeel/contents/lockscreen/LockScreen.qml @@ -12,12 +12,20 @@ import "../components" Item { id: root - property bool viewVisible: false property bool debug: false property string notification property int interfaceVersion: org_kde_plasma_screenlocker_greeter_interfaceVersion ? org_kde_plasma_screenlocker_greeter_interfaceVersion : 0 signal clearPassword() + // These are magical properties that kscreenlocker looks for + property bool viewVisible: false + property bool suspendToRamSupported: false + property bool suspendToDiskSupported: false + + // These are magical signals that kscreenlocker looks for + signal suspendToDisk() + signal suspendToRam() + LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true diff --git a/lookandfeel/contents/lockscreen/LockScreenUi.qml b/lookandfeel/contents/lockscreen/LockScreenUi.qml index e4df24732..eecaa56a5 100644 --- a/lookandfeel/contents/lockscreen/LockScreenUi.qml +++ b/lookandfeel/contents/lockscreen/LockScreenUi.qml @@ -255,6 +255,20 @@ PlasmaCore.ColorScope { } actionItems: [ + ActionButton { + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Sleep") + iconSource: "system-suspend" + onClicked: root.suspendToRam() + visible: root.suspendToRamSupported + anchors.verticalCenter: parent.top + }, + ActionButton { + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Hibernate") + iconSource: "system-suspend-hibernate" + onClicked: root.suspendToDisk() + visible: root.suspendToDiskSupported + anchors.verticalCenter: parent.top + }, ActionButton { text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Switch User") iconSource: "system-switch-user"