Add support for assigning global shortcuts for suspend actions

The corresponding shortcuts have been added as part of the KDesktop shortucts, to complement similar options (logout, shutdown, reboot).

The shortcuts are only shown for the options that KSMServer reports via DCOP as valid.

In order to do be able to make a DCOP call from kdesktopbindings.cpp, the <dcopref.h> include had to be added to several files of the shortcuts TDECM.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
(cherry picked from commit 95837cc844)
r14.1.x
Mavridis Philippe 5 months ago
parent db3f842c54
commit eb1c3eedba

@ -26,6 +26,7 @@
#include <kdebug.h>
#include <tdelocale.h>
#include <ksimpleconfig.h>
#include <dcopref.h>
#include "commandShortcuts.h"
#include "main.h"

@ -41,6 +41,7 @@
#include <tdeshortcutlist.h>
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
#include <dcopref.h>
ShortcutsModule::ShortcutsModule( TQWidget *parent, const char *name )
: TQWidget( parent, name )

@ -113,7 +113,7 @@ bool KRootWidget::eventFilter ( TQObject *, TQEvent * e )
else if ( e->type() == TQEvent::Drop )
{
TQDropEvent* de = static_cast<TQDropEvent*>( e );
if ( KColorDrag::canDecode( de ) )
if ( KColorDrag::canDecode( de ) )
emit colorDropEvent( de );
else if ( TQImageDrag::canDecode( de ) )
emit imageDropEvent( de );
@ -215,7 +215,7 @@ KDesktop::initRoot()
Display *dpy = tqt_xdisplay();
Window root = RootWindow(dpy, kdesktop_screen_number);
XDefineCursor(dpy, root, cursor().handle());
m_bDesktopEnabled = KDesktopSettings::desktopEnabled();
if ( !m_bDesktopEnabled && !m_pRootWidget )
{
@ -1064,6 +1064,30 @@ void KDesktop::slotRebootNoCnf()
TDEApplication::ShutdownTypeReboot );
}
void KDesktop::slotFreeze()
{
DCOPRef r("ksmserver", "ksmserver");
r.send("suspend", 1);
}
void KDesktop::slotSuspend()
{
DCOPRef r("ksmserver", "ksmserver");
r.send("suspend", 3);
}
void KDesktop::slotHibernate()
{
DCOPRef r("ksmserver", "ksmserver");
r.send("suspend", 4);
}
void KDesktop::slotHybridSuspend()
{
DCOPRef r("ksmserver", "ksmserver");
r.send("suspend", 5);
}
void KDesktop::setVRoot( bool enable )
{
if ( enable == set_vroot )

@ -135,6 +135,10 @@ private slots:
void slotLogoutNoCnf();
void slotHaltNoCnf();
void slotRebootNoCnf();
void slotFreeze();
void slotSuspend();
void slotHibernate();
void slotHybridSuspend();
/** Connected to KSycoca */
void slotDatabaseChanged();

@ -49,6 +49,27 @@
}
#endif
// Only add these options if supported by ksmserver
DCOPRef ksmref("ksmserver", "ksmserver");
DCOPReply reply = ksmref.call("suspendOptions");
TQStringList suspendOptions;
if (reply.isValid()) {
reply.get(suspendOptions);
}
if (suspendOptions.contains("freeze"))
DEF( I18N_NOOP("Freeze"), TDEShortcut(), TDEShortcut(), slotFreeze() );
if (suspendOptions.contains("suspend"))
DEF( I18N_NOOP("Suspend"), TDEShortcut(TQString("XF86Sleep")), TDEShortcut(TQString("XF86Sleep")), slotSuspend() );
if (suspendOptions.contains("hibernate"))
DEF( I18N_NOOP("Hibernate"), TDEShortcut(), TDEShortcut(), slotHibernate() );
if (suspendOptions.contains("hybridSuspend"))
DEF( I18N_NOOP("Hybrid Suspend"), TDEShortcut(), TDEShortcut(), slotHybridSuspend() );
#undef DEF
#undef DEF2
#undef WIN

Loading…
Cancel
Save