[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    KDE/kdebase/workspace/plasma/applets/kickoff
From:       Sebastian Kügler <sebas () kde ! org>
Date:       2008-09-27 16:55:05
Message-ID: 1222534505.159147.16704.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 865464 by sebas:

Fix suspend and hibernate from kickoff launcher.

The problem here is that you need to use a KJob, as the actions
in Solid::PowerManager don't create one themselves.
This patch makes kickoff run these methods through powerdevil
if the DBus service is available when the action is triggered,
otherwise it uses the Solid API directly (no intervention from
powerdevil possible in that case). It does switch at runtime,
however -- so we should be fine in both cases.

As discussed with Kevin.

CCMAIL:plasma-devel@kde.org


 M  +33 -4     core/itemhandlers.cpp  
 M  +1 -0      ui/brandingbutton.cpp  


--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/core/itemhandlers.cpp #865463:865464
@@ -1,4 +1,4 @@
-/*  
+/*
     Copyright 2007 Robert Knight <robertknight@gmail.com>
 
     This library is free software; you can redistribute it and/or
@@ -25,6 +25,7 @@
 
 // KDE
 #include <KDebug>
+#include <KJob>
 #include <KService>
 #include <KToolInvocation>
 #include <KUrl>
@@ -65,10 +66,38 @@
     m_logoutAction = url.path().remove('/');
 
     if (m_logoutAction == "sleep") {
-        Solid::Control::PowerManager::suspend(Solid::Control::PowerManager::ToRam);
+        // Check if powerdevil is running, and use its methods to suspend if available
+        // otherwise go through Solid directly
+        QStringList modules;
+        QDBusInterface kdedInterface("org.kde.kded", "/kded", "org.kde.kded");
+        QDBusReply<QStringList> reply = kdedInterface.call("loadedModules");
+        if (reply.isValid() && reply.value().contains("powerdevil")) {
+            kDebug() << "Using powerdevil to suspend";
+            QDBusConnection dbus( QDBusConnection::sessionBus() );
+            QDBusInterface iface( "org.kde.kded", "/modules/powerdevil", "org.kde.PowerDevil", dbus );
+            iface.call( "suspend", Solid::Control::PowerManager::ToRam );
+        } else {
+            kDebug() << "Powerdevil not available, using solid to suspend";
+            KJob * job = Solid::Control::PowerManager::suspend(Solid::Control::PowerManager::ToRam);
+            job->start();
+        }
         return true;
     } else if (m_logoutAction == "hibernate") {
-        Solid::Control::PowerManager::suspend(Solid::Control::PowerManager::ToDisk);
+        // Check if powerdevil is running, and use its methods to hibernate if available
+        // otherwise go through Solid directly
+        QStringList modules;
+        QDBusInterface kdedInterface("org.kde.kded", "/kded", "org.kde.kded");
+        QDBusReply<QStringList> reply = kdedInterface.call("loadedModules");
+        if (reply.isValid() && reply.value().contains("powerdevil")) {
+            kDebug() << "Using powerdevil to hibernate";
+            QDBusConnection dbus( QDBusConnection::sessionBus() );
+            QDBusInterface iface( "org.kde.kded", "/modules/powerdevil", "org.kde.PowerDevil", dbus );
+            iface.call( "suspend", Solid::Control::PowerManager::ToDisk );
+        } else {
+            kDebug() << "Powerdevil not available, using solid to hibernate";
+            KJob * job = Solid::Control::PowerManager::suspend(Solid::Control::PowerManager::ToDisk);
+            job->start();
+        }
         return true;
     } else if (m_logoutAction == "lock") {
         // decouple dbus call, otherwise we'll run into a dead-lock
@@ -96,7 +125,7 @@
     if (m_logoutAction == "logout") {
         type = KWorkSpace::ShutdownTypeNone;
     } else if (m_logoutAction == "lock") {
-        kDebug() << "Locking screen"; 
+        kDebug() << "Locking screen";
     } else if (m_logoutAction == "switch") {
         kDebug() << "Switching user";
     } else if (m_logoutAction == "restart") {
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/ui/brandingbutton.cpp #865463:865464
@@ -53,6 +53,7 @@
 
 void BrandingButton::paintEvent(QPaintEvent *event)
 {
+    Q_UNUSED( event );
     if (!m_svg->isValid()) {
         kDebug() << "bad branding svg!";
         return;
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic