author | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
commit | 2b64a84d39eeed5681d0ee5068c7d11a01527750 (patch) (unidiff) | |
tree | c8693340dbc5ef5e2f9afa90b690829ddff2c4bd /noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.cpp | |
parent | 61fa699140c5efbb6ba0bf2a62f7e8fbf62976be (diff) | |
download | opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.zip opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.gz opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.bz2 |
other keymapping tool - not working this moment, I have to check it out
- the reason is that the config file is somewhat easier to understand than
from zkbapplet and has a nice config tool.
Please don't put it into any repositories this moment.
Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.cpp b/noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.cpp new file mode 100644 index 0000000..b7134d9 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.cpp | |||
@@ -0,0 +1,90 @@ | |||
1 | #include "KHUtil.h" | ||
2 | #include <qwindowsystem_qws.h> | ||
3 | |||
4 | int KHUtil::hex2int(const QString& hexstr, bool* ok) | ||
5 | { | ||
6 | int val; | ||
7 | bool success; | ||
8 | if(hexstr.find("0x") == 0){ | ||
9 | val = hexstr.mid(2).toInt(&success, 16); | ||
10 | } else { | ||
11 | val = hexstr.toInt(&success, 16); | ||
12 | } | ||
13 | if(!success){ | ||
14 | val = 0; | ||
15 | } | ||
16 | if(ok){ | ||
17 | *ok = success; | ||
18 | } | ||
19 | return(val); | ||
20 | } | ||
21 | |||
22 | const QStringList KHUtil::parseArgs(const QString& arguments) | ||
23 | { | ||
24 | QString str; | ||
25 | QStringList args; | ||
26 | char quote = 0; | ||
27 | char c; | ||
28 | for(unsigned int i=0; i<arguments.length(); i++){ | ||
29 | c = arguments[i]; | ||
30 | switch(c){ | ||
31 | case '\"': | ||
32 | if(quote == 0){ | ||
33 | quote = c; | ||
34 | } else if(quote == '\"'){ | ||
35 | if(str.length() > 0){ | ||
36 | args.append(str); | ||
37 | } | ||
38 | str = ""; | ||
39 | quote = 0; | ||
40 | } else { | ||
41 | str += c; | ||
42 | } | ||
43 | break; | ||
44 | case '\'': | ||
45 | if(quote == 0){ | ||
46 | quote = c; | ||
47 | } else if(quote == '\''){ | ||
48 | if(str.length() > 0){ | ||
49 | args.append(str); | ||
50 | } | ||
51 | str = ""; | ||
52 | quote = 0; | ||
53 | } else { | ||
54 | str += c; | ||
55 | } | ||
56 | break; | ||
57 | case ' ': | ||
58 | if(quote == 0){ | ||
59 | if(str.length() > 0){ | ||
60 | args.append(str); | ||
61 | str = ""; | ||
62 | } | ||
63 | } else { | ||
64 | str += c; | ||
65 | } | ||
66 | break; | ||
67 | default: | ||
68 | str += c; | ||
69 | break; | ||
70 | } | ||
71 | } | ||
72 | if(str.length() > 0){ | ||
73 | args.append(str); | ||
74 | } | ||
75 | return(args); | ||
76 | } | ||
77 | |||
78 | const QString KHUtil::currentApp() | ||
79 | { | ||
80 | QString app; | ||
81 | const QList<QWSWindow>& list = qwsServer->clientWindows(); | ||
82 | QWSWindow* w; | ||
83 | for(QListIterator<QWSWindow> it(list); (w=it.current()); ++it){ | ||
84 | if(w->isVisible() && w->client()->identity() != QString::null){ | ||
85 | app = w->client()->identity(); | ||
86 | break; | ||
87 | } | ||
88 | } | ||
89 | return app; | ||
90 | } | ||