[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/powerdevil
From: Dario Freddi <drf () kde ! org>
Date: 2011-01-24 10:11:54
Message-ID: 20110124101154.B845FAC8B9 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1216705 by dafre:
Move handling of button events config to the same format of suspendsession's one. \
This greatly facilitates code sharing and allows to remove quite a lot of redundant \
code. Bad news for beta/RC users willing to upgrade though: this might break your \
profiles' button actions.
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
--- trunk/KDE/kdebase/workspace/powerdevil/daemon/actions/bundled/handlebuttonevents.cpp \
#1216704:1216705 @@ -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)
{
--- trunk/KDE/kdebase/workspace/powerdevil/daemon/actions/bundled/handlebuttoneventsconfig.cpp \
#1216704:1216705 @@ -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); }
}
--- trunk/KDE/kdebase/workspace/powerdevil/daemon/actions/bundled/suspendsession.h \
#1216704:1216705 @@ -41,7 +41,8 @@
SuspendHybridMode = 4,
ShutdownMode = 8,
LogoutDialogMode = 16,
- LockScreenMode = 32
+ LockScreenMode = 32,
+ TurnOffScreenMode = 64
};
explicit SuspendSession(QObject *parent);
--- trunk/KDE/kdebase/workspace/powerdevil/daemon/powerdevilaction.cpp \
#1216704:1216705 @@ -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
--- trunk/KDE/kdebase/workspace/powerdevil/kcmodule/global/GeneralPage.cpp \
#1216704:1216705 @@ -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"));
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic