summaryrefslogtreecommitdiff
path: root/noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.cpp
authoralwin <alwin>2005-02-28 09:40:30 (UTC)
committer alwin <alwin>2005-02-28 09:40:30 (UTC)
commit2b64a84d39eeed5681d0ee5068c7d11a01527750 (patch) (side-by-side diff)
treec8693340dbc5ef5e2f9afa90b690829ddff2c4bd /noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.cpp
parent61fa699140c5efbb6ba0bf2a62f7e8fbf62976be (diff)
downloadopie-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.cpp90
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 @@
+#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;
+}