summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/hardware.cpp5
-rw-r--r--src/tdepowersave.cpp32
-rw-r--r--src/tdepowersave.h2
3 files changed, 36 insertions, 3 deletions
diff --git a/src/hardware.cpp b/src/hardware.cpp
index c0aded6..cf1cdd9 100644
--- a/src/hardware.cpp
+++ b/src/hardware.cpp
@@ -39,6 +39,8 @@
#include "tdepowersave_debug.h"
#include "privileges.h"
+// #define USE_EVENT_DEVICES_DIRECTLY 1
+
/*! The default constructor of the class HardwareInfo */
HardwareInfo::HardwareInfo() {
kdDebugFuncIn(trace);
@@ -55,7 +57,10 @@ HardwareInfo::HardwareInfo() {
// initialize connection to the TDE hardware library
m_hwdevices = TDEGlobal::hardwareDevices();
connect(m_hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(processHardwareChangedEvent(TDEGenericDevice*)));
+
+#ifdef USE_EVENT_DEVICES_DIRECTLY
connect(m_hwdevices, TQT_SIGNAL(eventDeviceKeyPressed(unsigned int, TDEEventDevice*)), this, TQT_SLOT(processKeyPressEvent(unsigned int, TDEEventDevice*)));
+#endif
// update everything the first time
update_info_ac_changed = true;
diff --git a/src/tdepowersave.cpp b/src/tdepowersave.cpp
index c1086e4..2958d72 100644
--- a/src/tdepowersave.cpp
+++ b/src/tdepowersave.cpp
@@ -30,6 +30,7 @@
#include <knotifydialog.h>
#include <kpassivepopup.h>
#include <tdepopupmenu.h>
+#include <kglobalaccel.h>
// other TQt headers:
#include <tqcursor.h>
@@ -114,6 +115,17 @@ tdepowersave::tdepowersave( bool force_acpi_check, bool trace_func ) : KSystemTr
connect(autoDimm, TQT_SIGNAL(inactivityTimeExpired()), this, TQT_SLOT(do_downDimm()));
connect(autoDimm, TQT_SIGNAL(UserIsActiveAgain()), this, TQT_SLOT(do_upDimm()));
+ // connect to hotkeys
+ m_globalAccel = new TDEGlobalAccel( TQT_TQOBJECT(this) );
+ m_globalAccel->insert( "Power button", i18n( "Execute configured power button action"), TQString(),
+ TDEShortcut(TQString("XF86PowerOff")), TDEShortcut(TQString("XF86PowerOff")), TQT_TQOBJECT(this), TQT_SLOT( handlePowerButtonEvent() ) );
+ m_globalAccel->insert( "Sleep button", i18n( "Sleep configured power button action"), TQString(),
+ TDEShortcut(TQString("XF86Sleep")), TDEShortcut(TQString("XF86Sleep")), TQT_TQOBJECT(this), TQT_SLOT( handleSleepButtonEvent() ) );
+ m_globalAccel->insert( "Hibernate button", i18n( "Hibernate configured power button action"), TQString(),
+ TDEShortcut(TQString("XF86Suspend")), TDEShortcut(TQString("XF86Suspend")), TQT_TQOBJECT(this), TQT_SLOT( handleS2DiskButtonEvent() ) );
+ m_globalAccel->readSettings();
+ m_globalAccel->updateConnections();
+
config->sync();
config_dialog_shown = false;
@@ -1982,7 +1994,7 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
if (hwinfo->currentSessionIsActive()) {
switch (action) {
case GO_SHUTDOWN:
- // to be shure if we really need the shutdown
+ // confirm that we really need/want to shutdown
if ((checkAC && !hwinfo->getAcAdapter()) || !checkAC ) {
DCOPRef shutdown = DCOPRef( "ksmserver", "ksmserver" );
shutdown.send("logout", 0, 2, 2);
@@ -1990,8 +2002,22 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
break;
case LOGOUT_DIALOG:
{
- DCOPRef shutdown = DCOPRef( "ksmserver", "ksmserver" );
- shutdown.send("logout", 1, 2, 2);
+ // Do not display the logout dialog if the screen saver/lock system is active
+ bool saving = true;
+ TQString _method;
+ DCOPRef dcop_ref = DCOPRef( "kdesktop", "KScreensaverIface" );
+ _method = "isBlanked()";
+ DCOPReply reply = dcop_ref.call(_method.latin1());
+ if ( reply.isValid() ) {
+ if (!reply.get(saving)) {
+ saving = false;
+ }
+ }
+
+ if (!saving) {
+ DCOPRef shutdown = DCOPRef( "ksmserver", "ksmserver" );
+ shutdown.send("logout", 1, 2, 2);
+ }
}
break;
case GO_SUSPEND2RAM:
diff --git a/src/tdepowersave.h b/src/tdepowersave.h
index 0531561..e7f198d 100644
--- a/src/tdepowersave.h
+++ b/src/tdepowersave.h
@@ -52,6 +52,7 @@
#include "screen.h"
#include "settings.h"
+class TDEGlobalAccel;
/*!
* \file tdepowersave.h
@@ -98,6 +99,7 @@ private:
//! instance of \ref countDownDialog
countDownDialog *countdown;
+ TDEGlobalAccel *m_globalAccel;
//! struct wth information about suspend states and permissions
SuspendStates suspend;