branches/KDE/4.6/kdebase/workspace/powerdevil

Dario Freddi drf at kde.org
Mon Jan 24 11:17:17 CET 2011


SVN commit 1216708 by dafre:

CCMAIL: Dirk Mueller <mueller at kde.org>
CCMAIL: release-team at kde.org

Backporting r1216705

This commit is critical and needs to be released in 4.6.0; otherwise it needs to be reverted. Please add it to the tag or this issue might cause troubles in the future.


 M  +6 -40     daemon/actions/bundled/handlebuttonevents.cpp  
 M  +9 -7      daemon/actions/bundled/handlebuttoneventsconfig.cpp  
 M  +2 -1      daemon/actions/bundled/suspendsession.h  
 M  +1 -1      daemon/powerdevilaction.cpp  
 M  +1 -1      kcmodule/global/GeneralPage.cpp  


--- branches/KDE/4.6/kdebase/workspace/powerdevil/daemon/actions/bundled/handlebuttonevents.cpp #1216707:1216708
@@ -19,6 +19,8 @@
 
 #include "handlebuttonevents.h"
 
+#include "suspendsession.h"
+
 #include <powerdevilactionpool.h>
 
 #include <KConfigGroup>
@@ -87,33 +89,13 @@
 void HandleButtonEvents::processAction(uint action)
 {
     // Basically, we simply trigger other actions :)
-    switch (action) {
-        case 1:
-            // Sleep
-            triggerAction("SuspendSession", qVariantFromValue< uint >(1));
-            break;
-        case 2:
-            // Hibernate
-            triggerAction("SuspendSession", qVariantFromValue< uint >(2));
-            break;
-        case 3:
-            // Turn off PC
-            triggerAction("SuspendSession", qVariantFromValue< uint >(8));
-            break;
-        case 4:
-            // Lock
-            triggerAction("SuspendSession", qVariantFromValue< uint >(32));
-            break;
-        case 5:
-            // Shutdown dialog
-            triggerAction("SuspendSession", qVariantFromValue< uint >(16));
-            break;
-        case 6:
+    switch ((SuspendSession::Mode)action) {
+        case SuspendSession::TurnOffScreenMode:
             // Turn off screen
             triggerAction("DPMSControl", qVariantFromValue< QString >("TurnOff"));
             break;
         default:
-            // Do nothing
+            triggerAction("SuspendSession", qVariantFromValue< uint >(action));
             break;
     }
 }
@@ -134,25 +116,9 @@
 {
     // For now, let's just accept the phantomatic "32" button.
     if (args["Button"].toInt() == 32) {
-        switch (args["Button"].toUInt()) {
-        case 1:
-            // Sleep
-            triggerAction("SuspendSession", qVariantFromValue< uint >(1)); // To RAM
-            break;
-        case 2:
-            // Hibernate
-            triggerAction("SuspendSession", qVariantFromValue< uint >(2)); // To disk
-            break;
-        case 3:
-            // Turn off PC
-            triggerAction("SuspendSession", qVariantFromValue< uint >(8)); // Shutdown
-            break;
-        default:
-            // Do nothing
-            break;
+        triggerAction("SuspendSession", args["Button"]);
         }
     }
-}
 
 bool HandleButtonEvents::loadAction(const KConfigGroup& config)
 {
--- branches/KDE/4.6/kdebase/workspace/powerdevil/daemon/actions/bundled/handlebuttoneventsconfig.cpp #1216707:1216708
@@ -19,6 +19,8 @@
 
 #include "handlebuttoneventsconfig.h"
 
+#include "suspendsession.h"
+
 #include <Solid/PowerManagement>
 
 #include <KLocalizedString>
@@ -72,19 +74,19 @@
         QSet< Solid::PowerManagement::SleepState > methods = Solid::PowerManagement::supportedSleepStates();
 
         foreach (KComboBox *box, boxes) {
-            box->addItem(KIcon("dialog-cancel"), i18n("Do nothing"), (uint)0);
+            box->addItem(KIcon("dialog-cancel"), i18n("Do nothing"), (uint)SuspendSession::None);
             if (methods.contains(Solid::PowerManagement::SuspendState)) {
-                box->addItem(KIcon("system-suspend"), i18n("Sleep"), (uint)1);
+                box->addItem(KIcon("system-suspend"), i18n("Sleep"), (uint)SuspendSession::ToRamMode);
             }
             if (methods.contains(Solid::PowerManagement::HibernateState)) {
-                box->addItem(KIcon("system-suspend-hibernate"), i18n("Hibernate"), (uint)2);
+                box->addItem(KIcon("system-suspend-hibernate"), i18n("Hibernate"), (uint)SuspendSession::ToDiskMode);
             }
-            box->addItem(KIcon("system-shutdown"), i18n("Shutdown"), (uint)3);
-            box->addItem(KIcon("system-lock-screen"), i18n("Lock screen"), (uint)4);
+            box->addItem(KIcon("system-shutdown"), i18n("Shutdown"), (uint)SuspendSession::ShutdownMode);
+            box->addItem(KIcon("system-lock-screen"), i18n("Lock screen"), (uint)SuspendSession::LockScreenMode);
             if (box != m_lidCloseCombo) {
-                box->addItem(KIcon("system-log-out"), i18n("Prompt log out dialog"), (uint)5);
+                box->addItem(KIcon("system-log-out"), i18n("Prompt log out dialog"), (uint)SuspendSession::LogoutDialogMode);
             }
-            box->addItem(KIcon("preferences-desktop-screensaver"), i18n("Turn off screen"), (uint)6);
+            box->addItem(KIcon("preferences-desktop-screensaver"), i18n("Turn off screen"), (uint)SuspendSession::TurnOffScreenMode);
         }
     }
 
--- branches/KDE/4.6/kdebase/workspace/powerdevil/daemon/actions/bundled/suspendsession.h #1216707:1216708
@@ -41,7 +41,8 @@
         SuspendHybridMode = 4,
         ShutdownMode = 8,
         LogoutDialogMode = 16,
-        LockScreenMode = 32
+        LockScreenMode = 32,
+        TurnOffScreenMode = 64
     };
 
     explicit SuspendSession(QObject *parent);
--- branches/KDE/4.6/kdebase/workspace/powerdevil/daemon/powerdevilaction.cpp #1216707:1216708
@@ -85,7 +85,7 @@
 void Action::trigger(const QVariantMap& args)
 {
     if (args.contains("Explicit") && args["Explicit"].toBool()) {
-        // The action was explicitely triggered by the user, hence any policy check is bypassed.
+        // The action was explicitly triggered by the user, hence any policy check is bypassed.
         triggerImpl(args);
     } else {
         // The action was taken automatically: let's check if we have the rights to do that
--- branches/KDE/4.6/kdebase/workspace/powerdevil/kcmodule/global/GeneralPage.cpp #1216707:1216708
@@ -105,7 +105,7 @@
     if (methods.contains(Solid::PowerManagement::HibernateState)) {
         BatteryCriticalCombo->addItem(KIcon("system-suspend-hibernate"), i18n("Hibernate"), 2);
     }
-    BatteryCriticalCombo->addItem(KIcon("system-shutdown"), i18n("Shutdown"), 3);
+    BatteryCriticalCombo->addItem(KIcon("system-shutdown"), i18n("Shutdown"), 8);
 
     notificationsButton->setIcon(KIcon("preferences-desktop-notification"));
 


More information about the release-team mailing list