summaryrefslogtreecommitdiff
path: root/noncore/applets/keyhelper/keyhelperapplet/extension/KeyLauncher.cpp
Unidiff
Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/extension/KeyLauncher.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/keyhelper/keyhelperapplet/extension/KeyLauncher.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/KeyLauncher.cpp b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyLauncher.cpp
new file mode 100644
index 0000000..7a0b88c
--- a/dev/null
+++ b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyLauncher.cpp
@@ -0,0 +1,57 @@
1#include "KeyLauncher.h"
2#include "KHUtil.h"
3
4KeyLauncher::KeyLauncher(const QString& kind) : m_kind(kind)
5{
6 qDebug("KeyLauncher::KeyLauncher()");
7}
8
9KeyLauncher::~KeyLauncher()
10{
11 qDebug("KeyLauncher::~KeyLauncher()");
12}
13
14bool KeyLauncher::onKeyPress(int keycode)
15{
16 QString key;
17 QStringList args;
18 ConfigEx& cfg = ConfigEx::getInstance("keyhelper");
19
20 key = KeyNames::getName(keycode);
21 if(key == QString::null){
22 return(false);
23 }
24
25 QString group = kind();
26 group[0] = group[0].upper();
27
28 /* read application launcher */
29 QString app = KHUtil::currentApp();
30 if(!app.isEmpty()){
31 cfg.setGroup(group + "_" + app);
32 /* read config */
33 args = cfg.readListEntry(key, '\t');
34 }
35
36 /* read default launcher */
37 if(args.isEmpty()){
38 cfg.setGroup(group);
39
40 /* read config */
41 args = cfg.readListEntry(key, '\t');
42 }
43
44 if(args.isEmpty()){
45 return(false);
46 }
47
48 /* launch application */
49 LnkWrapper lnk(args);
50 if(lnk.isValid()){
51 //args.remove(args.begin());
52 lnk.instance().execute();
53 }
54
55 return(true);
56}
57