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

List:       kde-commits
Subject:    KDE/kdebase/runtime/kglobalaccel
From:       Kelvie Wong <kelvie () ieee ! org>
Date:       2010-04-16 1:37:40
Message-ID: 20100416013740.3519FAC898 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1115342 by kelvie:

KGlobalAccel: Add an invokeShortcut call to the KGlobalAccel components.

This will make it possible to interface _any_ KDE application with global
shortcuts via DBUS.  For example (this was my motivation for doing this, as
well):

qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut ShowDesktopGrid
qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut snow
qdbus org.kde.kglobalaccel /component/amarok org.kde.kglobalaccel.Component.invokeShortcut play_pause

A list of all the shortcut names are given by (e.g. for kwin):

qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.shortcutNames

 M  +5 -0      component.cpp  
 M  +2 -0      component.h  


--- trunk/KDE/kdebase/runtime/kglobalaccel/component.cpp #1115341:1115342
@@ -261,6 +261,11 @@
             timestamp);
     }
 
+void Component::invokeShortcut(const QString &shortcutName, const QString &context)
+    {
+        GlobalShortcut *shortcut = getShortcutByName(shortcutName, context);
+        if (shortcut) emitGlobalShortcutPressed(*shortcut);
+    }
 
 QString Component::friendlyName() const
     {
--- trunk/KDE/kdebase/runtime/kglobalaccel/component.h #1115341:1115342
@@ -158,6 +158,8 @@
 
     void emitGlobalShortcutPressed(const GlobalShortcut &shortcut);
 
+    Q_SCRIPTABLE void invokeShortcut(const QString &shortcutName, const QString &context = "default");
+
 Q_SIGNALS:
 
     //! Signals that a action for this component was triggered
[prev in list] [next in list] [prev in thread] [next in thread] 

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