#include <KConfigDialog>
#include <KSaveFile>
#include <KWindowSystem>
+#include <Solid/PowerManagement>
#include <QTextStream>
-#include <QtXml/qdom.h>
+#include <QDomElement>
#include <QApplication>
#include <QClipboard>
#include <QAbstractItemView>
#ifdef HAVE_KWORKSPACE
-# include <QDBusConnection>
-# include <QDBusInterface>
-# include <QDBusPendingCall>
# include <kworkspace/kworkspace.h>
#endif
case KGet::Shutdown:
notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("The computer will now turn off, as all downloads have completed."), "system-shutdown", i18nc("Shutting down computer", "Shutdown"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
break;
+#endif
case KGet::Hibernate:
notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("The computer will now suspend to disk, as all downloads have completed."), "system-suspend-hibernate", i18nc("Hibernating computer", "Hibernating"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
break;
case KGet::Suspend:
notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("The computer will now suspend to RAM, as all downloads have completed."), "system-suspend", i18nc("Suspending computer", "Suspending"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
break;
-#endif
default:
break;
}
void GenericObserver::slotAfterFinishAction()
{
switch (Settings::afterFinishAction()) {
- case KGet::Quit:
+ case KGet::Quit: {
kDebug() << "Quit Kget.";
QTimer::singleShot(0, KGet::m_mainWindow, SLOT(slotQuit()));
break;
+ }
#ifdef HAVE_KWORKSPACE
- case KGet::Shutdown:
+ case KGet::Shutdown: {
QTimer::singleShot(0, KGet::m_mainWindow, SLOT(slotQuit()));
KWorkSpace::requestShutDown(KWorkSpace::ShutdownConfirmNo,
KWorkSpace::ShutdownTypeHalt,
KWorkSpace::ShutdownModeForceNow);
break;
+ }
+#endif
case KGet::Hibernate: {
- QDBusMessage call = QDBusMessage::createMethodCall(
- "org.freedesktop.PowerManagement",
- "/org/freedesktop/PowerManagement",
- "org.freedesktop.PowerManagement",
- "Hibernate"
- );
- QDBusConnection::sessionBus().asyncCall(call);
+ Solid::PowerManagement::requestSleep(Solid::PowerManagement::HibernateState);
break;
}
case KGet::Suspend: {
- QDBusMessage call = QDBusMessage::createMethodCall(
- "org.freedesktop.PowerManagement",
- "/org/freedesktop/PowerManagement",
- "org.freedesktop.PowerManagement",
- "Suspend"
- );
- QDBusConnection::sessionBus().asyncCall(call);
+ Solid::PowerManagement::requestSleep(Solid::PowerManagement::SuspendState);
break;
}
-#endif
default: {
break;
}
#include "presentationwidget.h"
-// qt/kde includes
-#include <QtDBus/QDBusConnection>
-#include <QtDBus/QDBusInterface>
-#include <QtDBus/QDBusMessage>
-#include <QtDBus/QDBusReply>
-
+// Katie/kde includes
#include <qevent.h>
#include <qfontmetrics.h>
#include <kicon.h>
#include <qvalidator.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
+#include <qtoolbar.h>
#include <kcursor.h>
#include <krandom.h>
-#include <qtoolbar.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <klineedit.h>
#include <kselectaction.h>
#include <kshortcut.h>
#include <kdialog.h>
+#include <solid/powermanagement.h>
// system includes
#include <stdlib.h>
// Inhibit screen and sleep
// Note: beginSuppressingScreenPowerManagement inhibits DPMS, automatic brightness change and screensaver
- QDBusInterface screensaveriface(
- "org.freedesktop.ScreenSaver",
- "/ScreenSaver",
- "org.freedesktop.ScreenSaver",
- QDBusConnection::sessionBus()
- );
- QDBusReply<uint> reply = screensaveriface.call("Inhibit", QString::fromLatin1("okular"), reason);
- m_screenInhibitCookie = reply.value();
-
- QDBusInterface powermanageriface(
- "org.freedesktop.PowerManagement.Inhibit",
- "/org/freedesktop/PowerManagement/Inhibit",
- "org.freedesktop.PowerManagement.Inhibit",
- QDBusConnection::sessionBus()
- );
- reply = powermanageriface.call("Inhibit", QString::fromLatin1("okular"), reason);
- m_sleepInhibitCookie = reply.value();
+ m_screenInhibitCookie = Solid::PowerManagement::beginSuppressingScreenPowerManagement(reason);
+
+ m_sleepInhibitCookie = Solid::PowerManagement::beginSuppressingSleep(reason);
}
void PresentationWidget::allowPowerManagement()
{
// Remove cookies
- QDBusInterface screensaveriface(
- "org.freedesktop.ScreenSaver",
- "/ScreenSaver",
- "org.freedesktop.ScreenSaver",
- QDBusConnection::sessionBus()
- );
- screensaveriface.asyncCall("UnInhibit", m_screenInhibitCookie);
-
- QDBusInterface powermanageriface(
- "org.freedesktop.PowerManagement.Inhibit",
- "/org/freedesktop/PowerManagement/Inhibit",
- "org.freedesktop.PowerManagement.Inhibit",
- QDBusConnection::sessionBus()
- );
- powermanageriface.asyncCall("UnInhibit", m_sleepInhibitCookie);
+ if (m_screenInhibitCookie) {
+ Solid::PowerManagement::stopSuppressingScreenPowerManagement(m_screenInhibitCookie);
+ }
+
+ if (m_sleepInhibitCookie) {
+ Solid::PowerManagement::stopSuppressingSleep(m_sleepInhibitCookie);
+ }
}
void PresentationWidget::showTopBar( bool show )