blob: b7134d9a64842bb0afe2cd527d0063dc94341041 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#include "KHUtil.h"
#include <qwindowsystem_qws.h>
int KHUtil::hex2int(const QString& hexstr, bool* ok)
{
int val;
bool success;
if(hexstr.find("0x") == 0){
val = hexstr.mid(2).toInt(&success, 16);
} else {
val = hexstr.toInt(&success, 16);
}
if(!success){
val = 0;
}
if(ok){
*ok = success;
}
return(val);
}
const QStringList KHUtil::parseArgs(const QString& arguments)
{
QString str;
QStringList args;
char quote = 0;
char c;
for(unsigned int i=0; i<arguments.length(); i++){
c = arguments[i];
switch(c){
case '\"':
if(quote == 0){
quote = c;
} else if(quote == '\"'){
if(str.length() > 0){
args.append(str);
}
str = "";
quote = 0;
} else {
str += c;
}
break;
case '\'':
if(quote == 0){
quote = c;
} else if(quote == '\''){
if(str.length() > 0){
args.append(str);
}
str = "";
quote = 0;
} else {
str += c;
}
break;
case ' ':
if(quote == 0){
if(str.length() > 0){
args.append(str);
str = "";
}
} else {
str += c;
}
break;
default:
str += c;
break;
}
}
if(str.length() > 0){
args.append(str);
}
return(args);
}
const QString KHUtil::currentApp()
{
QString app;
const QList<QWSWindow>& list = qwsServer->clientWindows();
QWSWindow* w;
for(QListIterator<QWSWindow> it(list); (w=it.current()); ++it){
if(w->isVisible() && w->client()->identity() != QString::null){
app = w->client()->identity();
break;
}
}
return app;
}
|