OSDN Git Service

ksmserver: handle all currently supported power sleep methods
authorIvailo Monev <xakepa10@gmail.com>
Tue, 29 Nov 2022 23:54:45 +0000 (01:54 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 29 Nov 2022 23:54:45 +0000 (01:54 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
ksmserver/shutdowndlg.cpp
ksmserver/themes/contour/main.qml
ksmserver/themes/default/main.qml

index f7e33d7..98f3108 100644 (file)
@@ -235,12 +235,17 @@ void KSMShutdownDlg::slotSuspend(int spdMethod)
 {
     switch (spdMethod) {
         case Solid::PowerManagement::StandbyState:
+            Solid::PowerManagement::requestSleep(Solid::PowerManagement::StandbyState, 0, 0);
+            break;
         case Solid::PowerManagement::SuspendState:
             Solid::PowerManagement::requestSleep(Solid::PowerManagement::SuspendState, 0, 0);
             break;
         case Solid::PowerManagement::HibernateState:
             Solid::PowerManagement::requestSleep(Solid::PowerManagement::HibernateState, 0, 0);
             break;
+        case Solid::PowerManagement::HybridSuspendState:
+            Solid::PowerManagement::requestSleep(Solid::PowerManagement::HybridSuspendState, 0, 0);
+            break;
     }
     reject();
 }
index 1c18f00..a2a06d8 100644 (file)
@@ -123,7 +123,11 @@ PlasmaCore.FrameSvgItem {
                 onClicked: {
                     //console.log("contour.qml: sleep requested")
                     timer.running = false
-                    if (spdMethods.SuspendState) {
+                    if (spdMethods.HybridSuspendState) {
+                        suspendRequested(8); // Solid::PowerManagement::HybridSuspendState
+                    } else if (spdMethods.HibernateState) {
+                        suspendRequested(4); // Solid::PowerManagement::HibernateState
+                    } else if (spdMethods.SuspendState) {
                         suspendRequested(2); // Solid::PowerManagement::SuspendState
                     } else if (spdMethods.StandbyState) {
                         suspendRequested(1); // Solid::PowerManagement::StandbyState
index 55766bc..d034765 100644 (file)
@@ -264,7 +264,7 @@ PlasmaCore.FrameSvgItem {
                     iconSource: "system-shutdown"
                     anchors.right: parent.right
                     visible: (choose || sdtype == ShutdownType.ShutdownTypeHalt)
-                    menu: spdMethods.StandbyState | spdMethods.SuspendState | spdMethods.HibernateState
+                    menu: spdMethods.StandbyState | spdMethods.SuspendState | spdMethods.HibernateState | spdMethods.HybridSuspendState
                     tabStopNext: rebootButton
                     tabStopBack: logoutButton
 
@@ -291,6 +291,10 @@ PlasmaCore.FrameSvgItem {
                                 // 4 == Solid::PowerManagement::HibernateState
                                 contextMenu.append({itemIndex: 4, itemText: i18n("Suspend to &Disk"), itemSubMenu: null, itemAllowAmpersand: false})
                             }
+                            if (spdMethods.HybridSuspendState) {
+                                // 8 == Solid::PowerManagement::HybridSuspendState
+                                contextMenu.append({itemIndex: 8, itemText: i18n("&Hybrid Suspend"), itemSubMenu: null, itemAllowAmpersand: false})
+                            }
                             contextMenu.clicked.connect(shutdownUi.suspendRequested)
                         }
                         contextMenu.open()