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 | |
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.
84 files changed, 8165 insertions, 0 deletions
diff --git a/noncore/applets/keyhelper/config.in b/noncore/applets/keyhelper/config.in new file mode 100644 index 0000000..5bba19a --- a/dev/null +++ b/noncore/applets/keyhelper/config.in | |||
@@ -0,0 +1,4 @@ | |||
1 | config KEYHELPER | ||
2 | boolean "keyhelper applet (Config keyboard layout on the fly)" | ||
3 | default "n" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE | ||
diff --git a/noncore/applets/keyhelper/keyhelper.pro b/noncore/applets/keyhelper/keyhelper.pro new file mode 100644 index 0000000..483845d --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelper.pro | |||
@@ -0,0 +1,2 @@ | |||
1 | TEMPLATE = subdirs | ||
2 | SUBDIRS = keyhelperapplet keyhelperconf | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp new file mode 100644 index 0000000..3c2298e --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.cpp | |||
@@ -0,0 +1,94 @@ | |||
1 | #include "AnyLnk.h" | ||
2 | #include "KHUtil.h" | ||
3 | |||
4 | void AnyLnk::loadPixmap() | ||
5 | { | ||
6 | if(m_params.count() >= 3){ | ||
7 | QString& str = m_params[2]; | ||
8 | QImage image = Resource::loadImage(str); | ||
9 | if(image.isNull() == false){ | ||
10 | const QSize& size = AppLnkManager::getIconSize(); | ||
11 | m_pixmap.convertFromImage( | ||
12 | image.smoothScale(size.width(), size.height()) ); | ||
13 | } | ||
14 | } | ||
15 | } | ||
16 | |||
17 | void AnyLnk::parseText() | ||
18 | { | ||
19 | if(m_params.count() >= 2){ | ||
20 | QString& str = m_params[1]; | ||
21 | if(str != QString::null && str.length() > 0){ | ||
22 | replaceKeyword(str); | ||
23 | replaceDate(str); | ||
24 | } | ||
25 | } | ||
26 | } | ||
27 | |||
28 | void AnyLnk::replaceText(QString& str, const QString& s1, const QString& s2) | ||
29 | { | ||
30 | int index = 0; | ||
31 | int idx; | ||
32 | int len = s1.length(); | ||
33 | idx = str.find(s1, index); | ||
34 | for(;;){ | ||
35 | idx = str.find(s1, index); | ||
36 | if(idx < 0) break; | ||
37 | str.replace(idx, len, s2); | ||
38 | index = idx; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | void AnyLnk::replaceDate(QString& str) | ||
43 | { | ||
44 | time_t t; | ||
45 | struct tm lct; | ||
46 | char buf[4096]; | ||
47 | int nLen; | ||
48 | QString group; | ||
49 | |||
50 | t = ::time(NULL); | ||
51 | ::localtime_r(&t, &lct); | ||
52 | |||
53 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
54 | group = cfg.getGroup(); | ||
55 | cfg.setGroup("Global"); | ||
56 | QString charset = cfg.readEntry("SystemCharSet", "eucJP"); | ||
57 | if(charset.length() == 0){ | ||
58 | charset = "eucJP"; | ||
59 | } | ||
60 | cfg.setGroup(group); | ||
61 | |||
62 | QTextCodec* codec = QTextCodec::codecForName(charset); | ||
63 | if(codec == NULL){ | ||
64 | codec = QTextCodec::codecForLocale(); | ||
65 | } | ||
66 | QTextDecoder* decoder = codec->makeDecoder(); | ||
67 | QTextEncoder* encoder = codec->makeEncoder(); | ||
68 | nLen = str.length(); | ||
69 | QCString localeString = encoder->fromUnicode(str, nLen); | ||
70 | |||
71 | memset(buf, '\0', sizeof(buf)); | ||
72 | int n = ::strftime(buf, sizeof(buf), localeString, &lct); | ||
73 | if(n > 0){ | ||
74 | str = decoder->toUnicode(buf, n); | ||
75 | } | ||
76 | delete decoder; | ||
77 | delete encoder; | ||
78 | } | ||
79 | |||
80 | void AnyLnk::replaceKeyword(QString& str) | ||
81 | { | ||
82 | QString txt; | ||
83 | /* clipboard text */ | ||
84 | QClipboard* cb = QApplication::clipboard(); | ||
85 | if(cb == NULL){ | ||
86 | txt == ""; | ||
87 | } else { | ||
88 | txt = cb->text(); | ||
89 | } | ||
90 | replaceText(str, "%clipboard%", txt); | ||
91 | /* current app */ | ||
92 | txt = KHUtil::currentApp(); | ||
93 | replaceText(str, "%currentapp%", txt); | ||
94 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h new file mode 100644 index 0000000..9853942 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AnyLnk.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef _ANYLNK_H_ | ||
2 | #define _ANYLNK_H_ | ||
3 | |||
4 | #include <time.h> | ||
5 | |||
6 | #include <qstring.h> | ||
7 | #include <qstringlist.h> | ||
8 | #include <qpixmap.h> | ||
9 | #include <qimage.h> | ||
10 | #include <qclipboard.h> | ||
11 | #include <qtextcodec.h> | ||
12 | |||
13 | #include <qpe/qpeapplication.h> | ||
14 | #include <qpe/resource.h> | ||
15 | |||
16 | #include "AppLnkManager.h" | ||
17 | #include "ConfigEx.h" | ||
18 | |||
19 | class AnyLnk | ||
20 | { | ||
21 | public: | ||
22 | AnyLnk(){} | ||
23 | AnyLnk(const QStringList& params){ | ||
24 | m_params = params; | ||
25 | loadPixmap(); | ||
26 | } | ||
27 | virtual ~AnyLnk(){ | ||
28 | } | ||
29 | virtual bool isValid() = 0; | ||
30 | virtual void execute() = 0; | ||
31 | virtual QString name() = 0; | ||
32 | virtual const QPixmap& pixmap() = 0; | ||
33 | |||
34 | protected: | ||
35 | QStringList m_params; | ||
36 | QPixmap m_pixmap; | ||
37 | |||
38 | virtual void loadPixmap(); | ||
39 | virtual void parseText(); | ||
40 | virtual void replaceText(QString& str, const QString& s1, const QString& s2); | ||
41 | virtual void replaceDate(QString& str); | ||
42 | virtual void replaceKeyword(QString& str); | ||
43 | }; | ||
44 | |||
45 | #endif /* _ANYLNK_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkManager.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkManager.cpp new file mode 100644 index 0000000..5e244a4 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkManager.cpp | |||
@@ -0,0 +1,5 @@ | |||
1 | #include "AppLnkManager.h" | ||
2 | |||
3 | AppLnkSet* AppLnkManager::m_pLnkSet = NULL; | ||
4 | QSize AppLnkManager::m_oIconSize; | ||
5 | bool AppLnkManager::m_notfound = true; | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkManager.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkManager.h new file mode 100644 index 0000000..8446578 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkManager.h | |||
@@ -0,0 +1,56 @@ | |||
1 | #ifndef _APPLNK_MANAGER_H_ | ||
2 | #define _APPLNK_MANAGER_H_ | ||
3 | |||
4 | #include <qsize.h> | ||
5 | |||
6 | #include <qpe/applnk.h> | ||
7 | #include <qpe/mimetype.h> | ||
8 | |||
9 | class AppLnkManager | ||
10 | { | ||
11 | public: | ||
12 | AppLnkManager(){ | ||
13 | } | ||
14 | ~AppLnkManager(){ | ||
15 | if(m_pLnkSet) delete m_pLnkSet; | ||
16 | } | ||
17 | static void init(bool force=false){ | ||
18 | if(m_notfound || force){ | ||
19 | if(m_pLnkSet){ | ||
20 | delete m_pLnkSet; | ||
21 | } | ||
22 | qDebug("AppLnkManager::init()"); | ||
23 | m_pLnkSet = new AppLnkSet(MimeType::appsFolderName()); | ||
24 | m_notfound = false; | ||
25 | } | ||
26 | } | ||
27 | static AppLnkSet* getInstance(){ | ||
28 | if(m_pLnkSet == NULL){ | ||
29 | init(true); | ||
30 | } | ||
31 | return(m_pLnkSet); | ||
32 | } | ||
33 | static const QSize& getIconSize(){ | ||
34 | if(m_oIconSize.isValid()){ | ||
35 | return(m_oIconSize); | ||
36 | } | ||
37 | const QList<AppLnk>& lnkList = getInstance()->children(); | ||
38 | QListIterator<AppLnk> it(lnkList); | ||
39 | for(; it.current(); ++it){ | ||
40 | if((*it)->pixmap().isNull() == false){ | ||
41 | m_oIconSize = (*it)->pixmap().size(); | ||
42 | break; | ||
43 | } | ||
44 | } | ||
45 | return(m_oIconSize); | ||
46 | } | ||
47 | static void notfound(){ | ||
48 | m_notfound = true; | ||
49 | } | ||
50 | private: | ||
51 | static bool m_notfound; | ||
52 | static AppLnkSet* m_pLnkSet; | ||
53 | static QSize m_oIconSize; | ||
54 | }; | ||
55 | |||
56 | #endif /* _APPLNK_MANAGER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp new file mode 100644 index 0000000..1c3dbfe --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.cpp | |||
@@ -0,0 +1,43 @@ | |||
1 | #ifndef _APPLNK_WRAPPER_H_ | ||
2 | #define _APPLNK_WRAPPER_H_ | ||
3 | |||
4 | #include <qpe/qpeapplication.h> | ||
5 | #include <qpe/applnk.h> | ||
6 | #include "AnyLnk.h" | ||
7 | |||
8 | class AppLnkWrapper : public AnyLnk | ||
9 | { | ||
10 | public: | ||
11 | AppLnkWrapper(){} | ||
12 | AppLnkWrapper(const QStringList& params) | ||
13 | : AnyLnk(params) | ||
14 | { | ||
15 | m_pLnk = new AppLnk(QPEApplication::qpeDir() | ||
16 | + "apps/" + m_params[0] + ".desktop"); | ||
17 | } | ||
18 | virtual ~AppLnkWrapper(){ | ||
19 | delete m_pLnk; | ||
20 | } | ||
21 | |||
22 | virtual bool isValid() { | ||
23 | return(m_pLnk->isValid()); | ||
24 | } | ||
25 | virtual void execute(){ | ||
26 | parseText(); | ||
27 | m_pLnk->execute(m_params[1]); | ||
28 | } | ||
29 | virtual QString name() { | ||
30 | return(m_pLnk->name()); | ||
31 | } | ||
32 | virtual const QPixmap& pixmap(){ | ||
33 | if(m_pixmap.isNull()){ | ||
34 | return(m_pLnk->pixmap()); | ||
35 | } else { | ||
36 | return(m_pixmap); | ||
37 | } | ||
38 | } | ||
39 | protected: | ||
40 | AppLnk* m_pLnk; | ||
41 | }; | ||
42 | |||
43 | #endif /* _APPLNK_WRAPPER_H_ */ \ No newline at end of file | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.h new file mode 100644 index 0000000..6907dbe --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkWrapper.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef _APPLNK_WRAPPER_H_ | ||
2 | #define _APPLNK_WRAPPER_H_ | ||
3 | |||
4 | #include <qpe/qpeapplication.h> | ||
5 | #include <qpe/applnk.h> | ||
6 | #include "AnyLnk.h" | ||
7 | |||
8 | class AppLnkWrapper : public AnyLnk | ||
9 | { | ||
10 | public: | ||
11 | AppLnkWrapper(){} | ||
12 | AppLnkWrapper(const QStringList& params) | ||
13 | : AnyLnk(params) | ||
14 | { | ||
15 | m_pLnk = new AppLnk(QPEApplication::qpeDir() | ||
16 | + "apps/" + m_params[0] + ".desktop"); | ||
17 | } | ||
18 | virtual ~AppLnkWrapper(){ | ||
19 | delete m_pLnk; | ||
20 | } | ||
21 | |||
22 | virtual bool isValid() { | ||
23 | return(m_pLnk->isValid()); | ||
24 | } | ||
25 | virtual void execute(){ | ||
26 | parseText(); | ||
27 | m_pLnk->execute(m_params[1]); | ||
28 | } | ||
29 | virtual QString name() { | ||
30 | return(m_pLnk->name()); | ||
31 | } | ||
32 | virtual const QPixmap& pixmap(){ | ||
33 | if(m_pixmap.isNull()){ | ||
34 | return(m_pLnk->pixmap()); | ||
35 | } else { | ||
36 | return(m_pixmap); | ||
37 | } | ||
38 | } | ||
39 | protected: | ||
40 | AppLnk* m_pLnk; | ||
41 | }; | ||
42 | |||
43 | #endif /* _APPLNK_WRAPPER_H_ */ | ||
44 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/DocLnkWrapper.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/DocLnkWrapper.h new file mode 100644 index 0000000..d6f2be5 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/DocLnkWrapper.h | |||
@@ -0,0 +1,47 @@ | |||
1 | #ifndef _DOCLNK_WRAPPER_H_ | ||
2 | #define _DOCLNK_WRAPPER_H_ | ||
3 | |||
4 | #include <qpe/applnk.h> | ||
5 | #include "AnyLnk.h" | ||
6 | |||
7 | class DocLnkWrapper : public AnyLnk | ||
8 | { | ||
9 | public: | ||
10 | DocLnkWrapper(){} | ||
11 | DocLnkWrapper(const QStringList& params) | ||
12 | : AnyLnk(params) | ||
13 | { | ||
14 | m_pLnk = new DocLnk(m_params[0], false); | ||
15 | } | ||
16 | virtual ~DocLnkWrapper(){ | ||
17 | delete m_pLnk; | ||
18 | } | ||
19 | |||
20 | virtual bool isValid() { | ||
21 | if(m_pLnk->exec().length() > 0){ | ||
22 | return(true); | ||
23 | } else { | ||
24 | return(false); | ||
25 | } | ||
26 | } | ||
27 | virtual void execute(){ | ||
28 | parseText(); | ||
29 | m_pLnk->execute(m_params[1]); | ||
30 | } | ||
31 | virtual QString name() { | ||
32 | return(m_pLnk->name()); | ||
33 | } | ||
34 | virtual const QPixmap& pixmap(){ | ||
35 | if(m_pixmap.isNull()){ | ||
36 | return(m_pLnk->pixmap()); | ||
37 | } else { | ||
38 | return(m_pixmap); | ||
39 | } | ||
40 | } | ||
41 | protected: | ||
42 | DocLnk* m_pLnk; | ||
43 | }; | ||
44 | |||
45 | #endif /* _DOCLNK_WRAPPER_H_ */ | ||
46 | |||
47 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/ExecLnk.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ExecLnk.h new file mode 100644 index 0000000..7e595df --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ExecLnk.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef _EXECLNK_H_ | ||
2 | #define _EXECLNK_H_ | ||
3 | |||
4 | #include <qpe/qpeapplication.h> | ||
5 | |||
6 | #include "AnyLnk.h" | ||
7 | #include "ProcessInvoker.h" | ||
8 | |||
9 | class ExecLnk : public AnyLnk | ||
10 | { | ||
11 | public: | ||
12 | ExecLnk(){} | ||
13 | ExecLnk(const QStringList& params) | ||
14 | : AnyLnk(params){} | ||
15 | virtual ~ExecLnk() { | ||
16 | } | ||
17 | |||
18 | virtual bool isValid() { | ||
19 | return(true); | ||
20 | } | ||
21 | virtual void execute() { | ||
22 | parseText(); | ||
23 | ProcessInvoker& pi = ProcessInvoker::getInstance(); | ||
24 | pi.setArguments(m_params[1]); | ||
25 | pi.setNotify(); | ||
26 | pi.run(); | ||
27 | } | ||
28 | virtual QString name() { | ||
29 | return("exec"); | ||
30 | } | ||
31 | virtual const QPixmap& pixmap() { | ||
32 | return(m_pixmap); | ||
33 | } | ||
34 | protected: | ||
35 | }; | ||
36 | |||
37 | #endif /* _EXECLNK_H_ */ | ||
38 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/LnkWrapper.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/LnkWrapper.cpp new file mode 100644 index 0000000..39806e5 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/LnkWrapper.cpp | |||
@@ -0,0 +1,32 @@ | |||
1 | #include "LnkWrapper.h" | ||
2 | |||
3 | LnkWrapper::LnkWrapper(const QStringList& params) | ||
4 | { | ||
5 | if(params[0][0] == '/'){ | ||
6 | qDebug("create DocLnk instance"); | ||
7 | m_pLnk = new DocLnkWrapper(params); | ||
8 | } else if(params[0] == "@exec"){ | ||
9 | qDebug("create ExecLnk instance"); | ||
10 | m_pLnk = new ExecLnk(params); | ||
11 | } else if(params[0] == "@qcop"){ | ||
12 | qDebug("create QCopLnk instance"); | ||
13 | m_pLnk = new QCopLnk(params); | ||
14 | } else if(params[0] == "@text"){ | ||
15 | qDebug("create TextLnk instance"); | ||
16 | m_pLnk = new TextLnk(params); | ||
17 | } else if(params[0] == "@menu"){ | ||
18 | qDebug("create MenuLnk instance"); | ||
19 | m_pLnk = new MenuLnk(params); | ||
20 | } else { | ||
21 | qDebug("create AppLnk instance"); | ||
22 | m_pLnk = new AppLnkWrapper(params); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | LnkWrapper::~LnkWrapper() | ||
27 | { | ||
28 | if(m_pLnk){ | ||
29 | delete m_pLnk; | ||
30 | } | ||
31 | } | ||
32 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/LnkWrapper.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/LnkWrapper.h new file mode 100644 index 0000000..6b9536b --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/LnkWrapper.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #ifndef _LNK_WRAPPER_H_ | ||
2 | #define _LNK_WRAPPER_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | |||
7 | #include <qpe/applnk.h> | ||
8 | |||
9 | #include "AppLnkWrapper.h" | ||
10 | #include "DocLnkWrapper.h" | ||
11 | #include "ExecLnk.h" | ||
12 | #include "QCopLnk.h" | ||
13 | #include "TextLnk.h" | ||
14 | #include "MenuLnk.h" | ||
15 | |||
16 | class LnkWrapper | ||
17 | { | ||
18 | public: | ||
19 | LnkWrapper(const QStringList& params); | ||
20 | virtual ~LnkWrapper(); | ||
21 | |||
22 | bool isValid(){ | ||
23 | return(m_pLnk && m_pLnk->isValid()); | ||
24 | } | ||
25 | AnyLnk& instance(){ | ||
26 | return(*m_pLnk); | ||
27 | } | ||
28 | private: | ||
29 | AnyLnk* m_pLnk; | ||
30 | }; | ||
31 | |||
32 | #endif /* _LNK_WRAPPER_H_ */ | ||
33 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/MenuLnk.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/MenuLnk.h new file mode 100644 index 0000000..19f75d6 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/MenuLnk.h | |||
@@ -0,0 +1,41 @@ | |||
1 | #ifndef _MENULNK_H_ | ||
2 | #define _MENULNK_H_ | ||
3 | |||
4 | #include <qpe/qpeapplication.h> | ||
5 | |||
6 | #include "AnyLnk.h" | ||
7 | #include "ConfigEx.h" | ||
8 | |||
9 | class MenuLnk : public AnyLnk | ||
10 | { | ||
11 | public: | ||
12 | MenuLnk(){} | ||
13 | MenuLnk(const QStringList& params) | ||
14 | : AnyLnk(params){} | ||
15 | virtual ~MenuLnk() { | ||
16 | } | ||
17 | |||
18 | virtual bool isValid() { | ||
19 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
20 | QString group = cfg.getGroup(); | ||
21 | cfg.setGroup(name()); | ||
22 | bool valid = (cfg.getKeys().isEmpty() == false); | ||
23 | cfg.setGroup(group); | ||
24 | return(valid); | ||
25 | } | ||
26 | virtual void execute() { | ||
27 | } | ||
28 | virtual QString name() { | ||
29 | QString group; | ||
30 | group = m_params[1]; | ||
31 | group[0] = group[0].upper(); | ||
32 | return(group); | ||
33 | } | ||
34 | virtual const QPixmap& pixmap() { | ||
35 | return(m_pixmap); | ||
36 | } | ||
37 | protected: | ||
38 | }; | ||
39 | |||
40 | #endif /* _MENULNK_H_ */ | ||
41 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.cpp new file mode 100644 index 0000000..09605bd --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.cpp | |||
@@ -0,0 +1,424 @@ | |||
1 | #include "ProcessInvoker.h" | ||
2 | |||
3 | static ProcessInvoker* g_this; | ||
4 | /* ------------------------------------------------------------------------ */ | ||
5 | /* static functions */ | ||
6 | /* ------------------------------------------------------------------------ */ | ||
7 | |||
8 | static Sigfunc* setSignalHandler(int signo, Sigfunc* handler) | ||
9 | { | ||
10 | struct sigaction act,oact; | ||
11 | |||
12 | act.sa_handler = handler; | ||
13 | ::sigemptyset(&act.sa_mask); | ||
14 | act.sa_flags = 0; | ||
15 | #ifdefSA_RESTART | ||
16 | act.sa_flags |= SA_RESTART; | ||
17 | #endif | ||
18 | if(::sigaction(signo, &act, &oact) < 0){ | ||
19 | return(NULL); | ||
20 | } | ||
21 | return(oact.sa_handler); | ||
22 | } | ||
23 | |||
24 | static void childHandler(int /*signo*/) | ||
25 | { | ||
26 | pid_t pid; | ||
27 | int status; | ||
28 | while((pid = ::waitpid(-1, &status, WNOHANG)) > 0){ | ||
29 | if(pid == g_this->m_child){ | ||
30 | g_this->notifyFinish(status); | ||
31 | } | ||
32 | } | ||
33 | } | ||
34 | |||
35 | /* ------------------------------------------------------------------------ */ | ||
36 | /* ProcessInvoker Class : parent process */ | ||
37 | /* ------------------------------------------------------------------------ */ | ||
38 | ProcessInvoker::ProcessInvoker() | ||
39 | { | ||
40 | g_this = this; | ||
41 | m_isRunning = false; | ||
42 | m_child = 0; | ||
43 | m_defChildHandler = SIG_DFL; | ||
44 | m_pTimer = new QTimer(this); | ||
45 | m_stdfd[0] = m_stdfd[1] = -1; | ||
46 | m_errfd[0] = m_errfd[1] = -1; | ||
47 | connect(m_pTimer, SIGNAL(timeout()), | ||
48 | this, SLOT(readOutputs())); | ||
49 | } | ||
50 | |||
51 | ProcessInvoker::~ProcessInvoker() | ||
52 | { | ||
53 | qDebug("ProcessInvoker::~ProcessInvoker()"); | ||
54 | } | ||
55 | |||
56 | bool ProcessInvoker::openPipe() | ||
57 | { | ||
58 | if(m_stdfd[0] >= 0) closePipe(m_stdfd, 0); | ||
59 | if(m_stdfd[1] >= 0) closePipe(m_stdfd, 1); | ||
60 | if(::pipe(m_stdfd) < 0){ | ||
61 | return(false); | ||
62 | } | ||
63 | if(m_errfd[0] >= 0) closePipe(m_errfd, 0); | ||
64 | if(m_errfd[1] >= 0) closePipe(m_errfd, 1); | ||
65 | if(::pipe(m_errfd) < 0){ | ||
66 | closePipe(m_stdfd); | ||
67 | return(false); | ||
68 | } | ||
69 | m_maxfdp1 = m_stdfd[0]; | ||
70 | if(m_errfd[0] > m_maxfdp1){ | ||
71 | m_maxfdp1 = m_errfd[0]; | ||
72 | } | ||
73 | m_maxfdp1++; | ||
74 | return(true); | ||
75 | } | ||
76 | |||
77 | void ProcessInvoker::closePipe(int fd[], int n) | ||
78 | { | ||
79 | if(fd == NULL){ | ||
80 | closePipe(m_stdfd, n); | ||
81 | closePipe(m_errfd, n); | ||
82 | } else { | ||
83 | if(n != 1 && fd[0] >= 0){ | ||
84 | ::close(fd[0]); | ||
85 | fd[0] = -1; | ||
86 | } | ||
87 | if(n != 0 && fd[1] >= 0){ | ||
88 | ::close(fd[1]); | ||
89 | fd[1] = -1; | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | void ProcessInvoker::setRunning(int pid) | ||
95 | { | ||
96 | m_child = pid; | ||
97 | m_isRunning = true; | ||
98 | } | ||
99 | |||
100 | bool ProcessInvoker::run(const QString& args) | ||
101 | { | ||
102 | //setArguments(KHUtil::parseArgs(args)); | ||
103 | setArguments(StringParser::split(' ', args)); | ||
104 | return(run()); | ||
105 | } | ||
106 | |||
107 | bool ProcessInvoker::run() | ||
108 | { | ||
109 | if(m_isRunning){ | ||
110 | return(false); | ||
111 | } | ||
112 | m_isRunning = true; | ||
113 | if(m_arguments.isEmpty()){ | ||
114 | m_isRunning = false; | ||
115 | return(false); | ||
116 | } | ||
117 | if(m_arguments[0][0] != '/'){ | ||
118 | m_isRunning = false; | ||
119 | return(false); | ||
120 | } | ||
121 | |||
122 | for(QStringList::Iterator it=m_arguments.begin(); | ||
123 | it!=m_arguments.end(); ++it){ | ||
124 | qDebug("arguments[%s]", (*it).ascii()); | ||
125 | } | ||
126 | |||
127 | /* open pipe */ | ||
128 | if(openPipe() == false){ | ||
129 | m_isRunning = false; | ||
130 | return(false); | ||
131 | } | ||
132 | |||
133 | /* signal handler reset */ | ||
134 | m_defChildHandler = setSignalHandler(SIGCHLD, SIG_DFL); | ||
135 | |||
136 | m_child = ::fork(); | ||
137 | if(m_child < 0){ | ||
138 | /* fork error */ | ||
139 | closePipe(); | ||
140 | setSignalHandler(SIGCHLD, m_defChildHandler); | ||
141 | m_isRunning = false; | ||
142 | return(false); | ||
143 | } else if(m_child == 0){ | ||
144 | /* child process */ | ||
145 | qDebug("child process[%d]", ::getpid()); | ||
146 | m_child = ::getpid(); | ||
147 | //setSignalHandler(SIGCHLD, SIG_DFL); | ||
148 | workerProc(); | ||
149 | /* no return */ | ||
150 | } | ||
151 | /* close pipe(write) */ | ||
152 | closePipe(NULL, 1); | ||
153 | #if 0 | ||
154 | m_pTimer = new QTimer(this); | ||
155 | connect(m_pTimer, SIGNAL(timeout()), | ||
156 | this, SLOT(readOutputs())); | ||
157 | #endif | ||
158 | m_pTimer->start(500); | ||
159 | { | ||
160 | emit start(m_child, m_arguments); | ||
161 | QCopEnvelope e(SC_CHANNEL, "start(int,QStringList)"); | ||
162 | e << m_child << m_arguments; | ||
163 | if(m_isNotify){ | ||
164 | int idx = m_arguments[0].findRev('/'); | ||
165 | notifyStatus(m_arguments[0].mid(idx+1), m_child); | ||
166 | } | ||
167 | } | ||
168 | int status; | ||
169 | if(::waitpid(-1, &status, WNOHANG) > 0){ | ||
170 | qDebug("finish"); | ||
171 | notifyFinish(status); | ||
172 | } else { | ||
173 | /* signal handler set */ | ||
174 | setSignalHandler(SIGCHLD, childHandler); | ||
175 | } | ||
176 | return(true); | ||
177 | } | ||
178 | |||
179 | void ProcessInvoker::terminate() | ||
180 | { | ||
181 | if(m_isRunning && m_child > 0){ | ||
182 | terminate(m_child); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | void ProcessInvoker::terminate(pid_t pid) | ||
187 | { | ||
188 | ::kill(pid, SIGTERM); | ||
189 | } | ||
190 | |||
191 | void ProcessInvoker::kill() | ||
192 | { | ||
193 | if(m_isRunning && m_child > 0){ | ||
194 | kill(m_child); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | void ProcessInvoker::kill(pid_t pid) | ||
199 | { | ||
200 | ::kill(pid, SIGKILL); | ||
201 | } | ||
202 | |||
203 | #if 0 | ||
204 | const QStringList ProcessInvoker::parseArgs(const QString& arguments) | ||
205 | { | ||
206 | QString str; | ||
207 | QStringList args; | ||
208 | char quote = 0; | ||
209 | char c; | ||
210 | for(unsigned int i=0; i<arguments.length(); i++){ | ||
211 | c = arguments[i]; | ||
212 | switch(c){ | ||
213 | case '\"': | ||
214 | if(quote == 0){ | ||
215 | quote = c; | ||
216 | } else if(quote == '\"'){ | ||
217 | if(str.length() > 0){ | ||
218 | args.append(str); | ||
219 | } | ||
220 | str = ""; | ||
221 | quote = 0; | ||
222 | } else { | ||
223 | str += c; | ||
224 | } | ||
225 | break; | ||
226 | case '\'': | ||
227 | if(quote == 0){ | ||
228 | quote = c; | ||
229 | } else if(quote == '\''){ | ||
230 | if(str.length() > 0){ | ||
231 | args.append(str); | ||
232 | } | ||
233 | str = ""; | ||
234 | quote = 0; | ||
235 | } else { | ||
236 | str += c; | ||
237 | } | ||
238 | break; | ||
239 | case ' ': | ||
240 | if(quote == 0){ | ||
241 | if(str.length() > 0){ | ||
242 | args.append(str); | ||
243 | str = ""; | ||
244 | } | ||
245 | } else { | ||
246 | str += c; | ||
247 | } | ||
248 | break; | ||
249 | default: | ||
250 | str += c; | ||
251 | break; | ||
252 | } | ||
253 | } | ||
254 | if(str.length() > 0){ | ||
255 | args.append(str); | ||
256 | } | ||
257 | return(args); | ||
258 | } | ||
259 | #endif | ||
260 | |||
261 | void ProcessInvoker::readOutputs() | ||
262 | { | ||
263 | struct timeval tmval; | ||
264 | tmval.tv_sec = 0; | ||
265 | tmval.tv_usec = 0; | ||
266 | fd_set rset; | ||
267 | |||
268 | QByteArray stdBuf, errBuf, resBuf; | ||
269 | QDataStream stdStream(stdBuf, IO_WriteOnly); | ||
270 | QDataStream errStream(errBuf, IO_WriteOnly); | ||
271 | |||
272 | int iRet; | ||
273 | bool running; | ||
274 | char buf[PIPE_BUF+1]; | ||
275 | while(true){ | ||
276 | running = false; | ||
277 | FD_ZERO(&rset); | ||
278 | if(m_stdfd[0] >= 0){ | ||
279 | FD_SET(m_stdfd[0], &rset); | ||
280 | running = true; | ||
281 | } | ||
282 | if(m_errfd[0] >= 0){ | ||
283 | FD_SET(m_errfd[0], &rset); | ||
284 | running = true; | ||
285 | } | ||
286 | if(running == false){ | ||
287 | m_pTimer->stop(); | ||
288 | //delete m_pTimer; | ||
289 | break; | ||
290 | } | ||
291 | |||
292 | if((iRet = ::select(m_maxfdp1, &rset, NULL, NULL, &tmval)) <= 0){ | ||
293 | qDebug("select[%d]", iRet); | ||
294 | break; | ||
295 | } | ||
296 | |||
297 | if(m_stdfd[0] >= 0 && FD_ISSET(m_stdfd[0], &rset)){ | ||
298 | int n = ::read(m_stdfd[0], buf, PIPE_BUF); | ||
299 | if(n > 0){ | ||
300 | stdStream.writeRawBytes(buf, n); | ||
301 | } else { | ||
302 | qDebug("stdout close"); | ||
303 | closePipe(m_stdfd, 0); | ||
304 | } | ||
305 | } | ||
306 | if(m_errfd[0] >= 0 && FD_ISSET(m_errfd[0], &rset)){ | ||
307 | int n = ::read(m_errfd[0], buf, PIPE_BUF); | ||
308 | if(n > 0){ | ||
309 | errStream.writeRawBytes(buf, n); | ||
310 | } else { | ||
311 | qDebug("stderr close"); | ||
312 | closePipe(m_errfd, 0); | ||
313 | } | ||
314 | } | ||
315 | } | ||
316 | |||
317 | if(stdBuf.size() > 0){ | ||
318 | QCopEnvelope e(SC_CHANNEL, "stdout(int,QByteArray)"); | ||
319 | e << m_child << stdBuf; | ||
320 | } | ||
321 | if(errBuf.size() > 0){ | ||
322 | QCopEnvelope e(SC_CHANNEL, "stderr(int,QByteArray)"); | ||
323 | e << m_child << errBuf; | ||
324 | } | ||
325 | if(running == false){ | ||
326 | QCopEnvelope e(SC_CHANNEL, "close(int)"); | ||
327 | e << m_child; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | #if 0 | ||
332 | void ProcessInvoker::waitFinish() | ||
333 | { | ||
334 | int status; | ||
335 | if(::waitpid(m_child, &status, 0) > 0){ | ||
336 | notifyFinish(status); | ||
337 | } else { | ||
338 | notifyFinish(0, false); | ||
339 | } | ||
340 | } | ||
341 | #endif | ||
342 | |||
343 | void ProcessInvoker::notifyFinish(int status, bool success) | ||
344 | { | ||
345 | bool stopped = false; | ||
346 | QString result; | ||
347 | int code; | ||
348 | if(success){ | ||
349 | if(WIFEXITED(status)){ | ||
350 | code = WEXITSTATUS(status); | ||
351 | if(code == 127){ | ||
352 | result = "error"; | ||
353 | } else { | ||
354 | result = "exit"; | ||
355 | } | ||
356 | } else if(WIFSIGNALED(status)){ | ||
357 | result = "terminated"; | ||
358 | code = WTERMSIG(status); | ||
359 | } else if(WIFSTOPPED(status)){ | ||
360 | result = "stopped"; | ||
361 | code = WSTOPSIG(status); | ||
362 | stopped = true; | ||
363 | } else { | ||
364 | /* ¤³¤ì¤Ï̵¤¤¤Ï¤º? */ | ||
365 | result = "error"; | ||
366 | code = -2; | ||
367 | qWarning("ProcessInvoker: unknown status"); | ||
368 | } | ||
369 | } else { | ||
370 | result = "error"; | ||
371 | code = -1; | ||
372 | qWarning("ProcessInvoker: wait error"); | ||
373 | } | ||
374 | emit finish(result, code); | ||
375 | QCopEnvelope e(SC_CHANNEL, "finish(int,QString,int)"); | ||
376 | e << m_child << result << code; | ||
377 | if(m_isNotify){ | ||
378 | notifyStatus(result, code); | ||
379 | setNotify(false); | ||
380 | } | ||
381 | if(stopped == false){ | ||
382 | setSignalHandler(SIGCHLD, m_defChildHandler); | ||
383 | m_isRunning = false; | ||
384 | } | ||
385 | } | ||
386 | |||
387 | void ProcessInvoker::notifyStatus(const QString& result, int code) | ||
388 | { | ||
389 | QString message = QString::number(code); | ||
390 | message.append(":"); | ||
391 | message.append(result); | ||
392 | Global::statusMessage(message); | ||
393 | } | ||
394 | |||
395 | /* ------------------------------------------------------------------------ */ | ||
396 | /* ProcessInvoker Class : child process */ | ||
397 | /* ------------------------------------------------------------------------ */ | ||
398 | void ProcessInvoker::workerProc() | ||
399 | { | ||
400 | closePipe(m_stdfd, 0); | ||
401 | closePipe(m_errfd, 0); | ||
402 | if(m_stdfd[1] != STDOUT_FILENO){ | ||
403 | ::dup2(m_stdfd[1], STDOUT_FILENO); | ||
404 | closePipe(m_stdfd, 1); | ||
405 | } | ||
406 | if(m_errfd[1] != STDERR_FILENO){ | ||
407 | ::dup2(m_errfd[1], STDERR_FILENO); | ||
408 | closePipe(m_errfd, 1); | ||
409 | } | ||
410 | |||
411 | QCString* arglist = new QCString[m_arguments.count()+1]; | ||
412 | const char** argv = new const char*[m_arguments.count()+1]; | ||
413 | unsigned int i; | ||
414 | for(i=0; i<m_arguments.count(); i++){ | ||
415 | //arglist[i] = m_arguments[i].local8Bit(); | ||
416 | arglist[i] = m_arguments[i]; | ||
417 | argv[i] = arglist[i]; | ||
418 | } | ||
419 | argv[i] = 0; | ||
420 | ::execv(argv[0], (char*const*)argv); | ||
421 | delete[] arglist; | ||
422 | delete[] argv; | ||
423 | ::_exit(127); | ||
424 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.h new file mode 100644 index 0000000..1f53cd6 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.h | |||
@@ -0,0 +1,114 @@ | |||
1 | #ifndef _PROCESS_INVOKER_H_ | ||
2 | #define _PROCESS_INVOKER_H_ | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <sys/wait.h> | ||
6 | #include <sys/types.h> | ||
7 | #include <sys/time.h> | ||
8 | #include <signal.h> | ||
9 | #include <stdio.h> | ||
10 | #include <unistd.h> | ||
11 | #include <errno.h> | ||
12 | |||
13 | #include <qtimer.h> | ||
14 | #include <qdatastream.h> | ||
15 | #include <qcstring.h> | ||
16 | #include <qpe/qcopenvelope_qws.h> | ||
17 | #include <qpe/global.h> | ||
18 | //#include "KHUtil.h" | ||
19 | #include "StringParser.h" | ||
20 | |||
21 | typedef void Sigfunc(int); | ||
22 | |||
23 | #define SC_CHANNEL"QPE/ShellCommander" | ||
24 | |||
25 | /* Sigleton Object */ | ||
26 | class ProcessInvoker : public QObject | ||
27 | { | ||
28 | Q_OBJECT | ||
29 | public: | ||
30 | static ProcessInvoker& getInstance() | ||
31 | { | ||
32 | static ProcessInvoker instance; | ||
33 | return(instance); | ||
34 | } | ||
35 | |||
36 | bool run(); | ||
37 | bool run(const QString& args); | ||
38 | void terminate(); | ||
39 | void terminate(pid_t pid); | ||
40 | void kill(); | ||
41 | void kill(pid_t pid); | ||
42 | void setCommand(const QString& command){ | ||
43 | m_arguments.clear(); | ||
44 | addArgument(command); | ||
45 | } | ||
46 | void setArguments(const QStringList& arglist){ | ||
47 | m_arguments = arglist; | ||
48 | } | ||
49 | void setArguments(const QString& arguments){ | ||
50 | //setArguments(KHUtil::parseArgs(arguments)); | ||
51 | setArguments(StringParser::split(' ', arguments)); | ||
52 | } | ||
53 | void addArgument(const QString& argument){ | ||
54 | m_arguments.append(argument); | ||
55 | } | ||
56 | void addArguments(const QString& arguments){ | ||
57 | QStringList arglist; | ||
58 | //arglist = KHUtil::parseArgs(arguments); | ||
59 | arglist = StringParser::split(' ', arguments); | ||
60 | addArguments(arglist); | ||
61 | } | ||
62 | void addArguments(const QStringList& arglist){ | ||
63 | for(QStringList::ConstIterator it=arglist.begin(); | ||
64 | it!=arglist.end(); ++it){ | ||
65 | addArgument(*it); | ||
66 | } | ||
67 | } | ||
68 | //const QStringList parseArgs(const QString& arguments); | ||
69 | void setRunning(int pid); | ||
70 | void setNotify(bool enable=true){ | ||
71 | m_isNotify = enable; | ||
72 | } | ||
73 | |||
74 | bool isRunning(){ | ||
75 | return(m_isRunning); | ||
76 | } | ||
77 | void notifyFinish(int status, bool success=true); | ||
78 | |||
79 | pid_t m_child; | ||
80 | |||
81 | friend class Dummy; /* for compile warning */ | ||
82 | signals: | ||
83 | void start(int, QStringList); | ||
84 | void finish(QString,int); | ||
85 | private: | ||
86 | ProcessInvoker(); | ||
87 | ProcessInvoker(const ProcessInvoker&); | ||
88 | ProcessInvoker& operator=(const ProcessInvoker&); | ||
89 | ~ProcessInvoker(); | ||
90 | |||
91 | class Dummy{}; /* for compile warning */ | ||
92 | |||
93 | QTimer* m_pTimer; | ||
94 | QStringList m_arguments; | ||
95 | |||
96 | bool m_isRunning; | ||
97 | bool m_isNotify; | ||
98 | |||
99 | Sigfunc* m_defChildHandler; | ||
100 | |||
101 | int m_stdfd[2]; | ||
102 | int m_errfd[2]; | ||
103 | int m_maxfdp1; | ||
104 | |||
105 | bool openPipe(); | ||
106 | void closePipe(int fd[] = NULL, int n = 2); | ||
107 | void notifyStatus(const QString& result, int code); | ||
108 | |||
109 | void workerProc(); | ||
110 | private slots: | ||
111 | void readOutputs(); | ||
112 | }; | ||
113 | |||
114 | #endif /* _PROCESS_INVOKER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.cpp new file mode 100644 index 0000000..991bf87 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.cpp | |||
@@ -0,0 +1,63 @@ | |||
1 | #include "QCopLnk.h" | ||
2 | #include "StringParser.h" | ||
3 | |||
4 | void QCopLnk::execute() | ||
5 | { | ||
6 | parseText(); | ||
7 | //QStringList argList = KHUtil::parseArgs(m_params[1]); | ||
8 | QStringList argList = StringParser::split(' ', m_params[1]); | ||
9 | if(argList.count() < 2){ | ||
10 | return; | ||
11 | } | ||
12 | QStringList paramList = | ||
13 | QStringList::split(QRegExp("[(),]"), argList[1]); | ||
14 | if(argList.count() < paramList.count()+1){ | ||
15 | return; | ||
16 | } | ||
17 | paramList.remove(paramList.begin()); | ||
18 | if(paramList.count() == 0){ | ||
19 | /* send qcop message */ | ||
20 | QCopEnvelope env(argList[0].latin1(), argList[1].latin1()); | ||
21 | } else { | ||
22 | QCopEnvelope* e = NULL; | ||
23 | QStringList::Iterator it=paramList.end(); | ||
24 | for(unsigned int index = 2; index<argList.count(); index++){ | ||
25 | if(it == paramList.end()){ | ||
26 | if(argList.count() - index < paramList.count()){ | ||
27 | break; | ||
28 | } | ||
29 | /* initialize */ | ||
30 | it = paramList.begin(); | ||
31 | e = new QCopEnvelope( | ||
32 | argList[0].latin1(), argList[1].latin1()); | ||
33 | } | ||
34 | QString arg = argList[index]; | ||
35 | if(*it == "QString"){ | ||
36 | *e << arg; | ||
37 | } else if(*it == "int"){ | ||
38 | *e << arg.toInt(); | ||
39 | } else if(*it == "bool"){ | ||
40 | QString s = arg.lower(); | ||
41 | int on; | ||
42 | if(s == "true"){ | ||
43 | on = TRUE; | ||
44 | } else if(s == "false"){ | ||
45 | on = FALSE; | ||
46 | } else { | ||
47 | on = s.toInt(); | ||
48 | } | ||
49 | *e << on; | ||
50 | } | ||
51 | ++it; | ||
52 | if(it == paramList.end()){ | ||
53 | /* send qcop message */ | ||
54 | delete e; | ||
55 | if(argList.count() - index >= paramList.count()){ | ||
56 | e = new QCopEnvelope( | ||
57 | argList[0].latin1(), argList[1].latin1()); | ||
58 | it = paramList.begin(); | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.h new file mode 100644 index 0000000..f994149 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/QCopLnk.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef _QCOPLNK_H_ | ||
2 | #define _QCOPLNK_H_ | ||
3 | |||
4 | #include <qpe/qpeapplication.h> | ||
5 | #include <qpe/qcopenvelope_qws.h> | ||
6 | |||
7 | #include "AnyLnk.h" | ||
8 | #include "KHUtil.h" | ||
9 | |||
10 | class QCopLnk : public AnyLnk | ||
11 | { | ||
12 | public: | ||
13 | QCopLnk(){} | ||
14 | QCopLnk(const QStringList& params) | ||
15 | : AnyLnk(params){} | ||
16 | virtual ~QCopLnk() { | ||
17 | } | ||
18 | |||
19 | virtual bool isValid() { | ||
20 | return(true); | ||
21 | } | ||
22 | virtual QString name() { | ||
23 | return("qcop"); | ||
24 | } | ||
25 | virtual const QPixmap& pixmap() { | ||
26 | return(m_pixmap); | ||
27 | } | ||
28 | |||
29 | virtual void execute(); | ||
30 | protected: | ||
31 | }; | ||
32 | |||
33 | #endif /* _QCOPLNK_H_ */ | ||
34 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/TextLnk.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/TextLnk.cpp new file mode 100644 index 0000000..abb432c --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/TextLnk.cpp | |||
@@ -0,0 +1,34 @@ | |||
1 | #include "TextLnk.h" | ||
2 | |||
3 | void TextLnk::execute() | ||
4 | { | ||
5 | QClipboard* cb = QApplication::clipboard(); | ||
6 | parseText(); | ||
7 | cb->setText(m_params[1]); | ||
8 | QWSServer::sendKeyEvent('V'-'@',Qt::Key_V, Qt::ControlButton, | ||
9 | true, false); | ||
10 | QWSServer::sendKeyEvent('V'-'@',Qt::Key_V, Qt::ControlButton, | ||
11 | false, false); | ||
12 | } | ||
13 | |||
14 | void TextLnk::parse(QString& str) | ||
15 | { | ||
16 | replace(str, "\\\\", "\\"); | ||
17 | replace(str, "\\n", "\n"); | ||
18 | replace(str, "\\r", "\r"); | ||
19 | replace(str, "\\t", "\t"); | ||
20 | } | ||
21 | |||
22 | void TextLnk::replace(QString& str, const QString& s1, const QString& s2) | ||
23 | { | ||
24 | int index = 0; | ||
25 | int idx; | ||
26 | int len = s1.length(); | ||
27 | idx = str.find(s1, index); | ||
28 | for(;;){ | ||
29 | idx = str.find(s1, index); | ||
30 | if(idx < 0) break; | ||
31 | str.replace(idx, len, s2); | ||
32 | index = idx; | ||
33 | } | ||
34 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/TextLnk.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/TextLnk.h new file mode 100644 index 0000000..3ae13c5 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/TextLnk.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef _PASTELNK_H_ | ||
2 | #define _PASTELNK_H_ | ||
3 | |||
4 | #include <qwindowsystem_qws.h> | ||
5 | |||
6 | #include <qpe/qpeapplication.h> | ||
7 | #include <qclipboard.h> | ||
8 | #include <qregexp.h> | ||
9 | |||
10 | #include "AnyLnk.h" | ||
11 | |||
12 | class TextLnk : public AnyLnk | ||
13 | { | ||
14 | public: | ||
15 | TextLnk(){} | ||
16 | TextLnk(const QStringList& params) | ||
17 | : AnyLnk(params){} | ||
18 | virtual ~TextLnk() { | ||
19 | } | ||
20 | |||
21 | virtual bool isValid() { | ||
22 | return(true); | ||
23 | } | ||
24 | virtual QString name() { | ||
25 | return("text"); | ||
26 | } | ||
27 | virtual const QPixmap& pixmap() { | ||
28 | return(m_pixmap); | ||
29 | } | ||
30 | |||
31 | virtual void execute(); | ||
32 | protected: | ||
33 | virtual void parse(QString& str); | ||
34 | virtual void replace(QString& str, const QString& s1, const QString& s2); | ||
35 | }; | ||
36 | |||
37 | #endif /* _PASTELNK_H_ */ | ||
38 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp new file mode 100644 index 0000000..4afdc1f --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp | |||
@@ -0,0 +1,112 @@ | |||
1 | #include "KeyHelper.h" | ||
2 | #include <opie2/okeyfilter.h> | ||
3 | |||
4 | KeyHelper::KeyHelper() | ||
5 | { | ||
6 | qDebug("KeyHelper::KeyHelper()"); | ||
7 | load(); | ||
8 | |||
9 | m_oAction.setKeyModifiers(&m_oModifiers); | ||
10 | m_oAction.setKeyMappings(&m_oMappings); | ||
11 | m_oAction.setKeyExtensions(&m_oExtensions); | ||
12 | m_oAction.setKeyRepeater(&m_oRepeater); | ||
13 | m_oExtensions.setKeyModifiers(&m_oModifiers); | ||
14 | } | ||
15 | |||
16 | KeyHelper::~KeyHelper() | ||
17 | { | ||
18 | unset(); | ||
19 | qDebug("KeyHelper::~KeyHelper()"); | ||
20 | } | ||
21 | |||
22 | bool KeyHelper::filter(int unicode, int keycode, int modifiers, | ||
23 | bool isPress, bool autoRepeat) | ||
24 | { | ||
25 | m_oAction.setAction(unicode, keycode, modifiers, | ||
26 | isPress, autoRepeat); | ||
27 | return(m_oAction.doAction()); | ||
28 | } | ||
29 | |||
30 | void KeyHelper::unset() | ||
31 | { | ||
32 | Opie::Core::OKeyFilter::inst()->remHandler(this);; | ||
33 | } | ||
34 | |||
35 | void KeyHelper::set() | ||
36 | { | ||
37 | Opie::Core::OKeyFilter::inst()->addHandler(this); | ||
38 | m_oModifiers.resetStates(); | ||
39 | } | ||
40 | |||
41 | void KeyHelper::enable() | ||
42 | { | ||
43 | m_oAction.enable(); | ||
44 | } | ||
45 | |||
46 | void KeyHelper::disable() | ||
47 | { | ||
48 | m_oAction.disable(); | ||
49 | m_oRepeater.stop(); | ||
50 | } | ||
51 | |||
52 | bool KeyHelper::load(const QString& file) | ||
53 | { | ||
54 | KeycfgReader oReader; | ||
55 | oReader.setKeyModifiers(&m_oModifiers); | ||
56 | oReader.setKeyMappings(&m_oMappings); | ||
57 | oReader.setKeyExtensions(&m_oExtensions); | ||
58 | oReader.setKeyRepeater(&m_oRepeater); | ||
59 | |||
60 | bool success; | ||
61 | if(file.length() == 0){ | ||
62 | success = oReader.load(); | ||
63 | } else if(file[0] == '/'){ | ||
64 | success = oReader.load(file); | ||
65 | } else { | ||
66 | //QString filepath = QString(::getenv("HOME")) + "/Settings/" + file; | ||
67 | QString filepath = QDir::homeDirPath() + "/Settings/" + file; | ||
68 | success = oReader.load(filepath); | ||
69 | } | ||
70 | if(success == false){ | ||
71 | qDebug("config xml load error"); | ||
72 | setDefault(); | ||
73 | } | ||
74 | return(success); | ||
75 | } | ||
76 | |||
77 | bool KeyHelper::reload(const QString& file) | ||
78 | { | ||
79 | m_oModifiers.reset(); | ||
80 | m_oMappings.reset(); | ||
81 | m_oExtensions.reset(); | ||
82 | m_oRepeater.reset(); | ||
83 | |||
84 | return(load(file)); | ||
85 | } | ||
86 | |||
87 | void KeyHelper::setDefault() | ||
88 | { | ||
89 | /* default settings */ | ||
90 | m_oExtensions.assign("switch", Qt::Key_F12, | ||
91 | m_oModifiers.getMask("Shift"), KeyNames::getCode("Shift")); | ||
92 | m_oExtensions.assign("select", Qt::Key_F11, | ||
93 | m_oModifiers.getMask("Shift"), KeyNames::getCode("Shift")); | ||
94 | } | ||
95 | |||
96 | void KeyHelper::statistics() | ||
97 | { | ||
98 | m_oModifiers.statistics(); | ||
99 | m_oMappings.statistics(); | ||
100 | m_oExtensions.statistics(); | ||
101 | m_oRepeater.statistics(); | ||
102 | } | ||
103 | |||
104 | void KeyHelper::dumpkeymap() | ||
105 | { | ||
106 | const QWSServer::KeyMap* m = QWSServer::keyMap(); | ||
107 | qWarning("KeyHelper::dumpkeymap()"); | ||
108 | while(m->key_code != 0){ | ||
109 | qWarning(" [%04x][%04x][%04x][%04x]", m->key_code, m->unicode, m->shift_unicode, m->ctrl_unicode); | ||
110 | m++; | ||
111 | } | ||
112 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.h b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.h new file mode 100644 index 0000000..aabb6eb --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef _KEY_HELPER_H_ | ||
2 | #define _KEY_HELPER_H_ | ||
3 | |||
4 | #include <qdir.h> | ||
5 | #include <qwindowsystem_qws.h> | ||
6 | #include "KeyNames.h" | ||
7 | #include "KeyMappings.h" | ||
8 | #include "KeyModifiers.h" | ||
9 | #include "KeyExtensions.h" | ||
10 | #include "KeyRepeater.h" | ||
11 | #include "KeyAction.h" | ||
12 | #include "KeycfgReader.h" | ||
13 | |||
14 | class KeyHelper : public QWSServer::KeyboardFilter | ||
15 | { | ||
16 | public: | ||
17 | KeyHelper(); | ||
18 | virtual ~KeyHelper(); | ||
19 | bool filter(int unicode, int keycode, int modifiers, | ||
20 | bool isPress, bool autoRepeat); | ||
21 | |||
22 | void enable(); | ||
23 | void disable(); | ||
24 | void set(); | ||
25 | void unset(); | ||
26 | void statistics(); | ||
27 | void dumpkeymap(); | ||
28 | bool reload(const QString& file=QString::null); | ||
29 | private: | ||
30 | friend class KeyHelperWidget; | ||
31 | |||
32 | bool load(const QString& file=QString::null); | ||
33 | void setDefault(); | ||
34 | |||
35 | KeyAction m_oAction; | ||
36 | KeyMappings m_oMappings; | ||
37 | KeyModifiers m_oModifiers; | ||
38 | KeyExtensions m_oExtensions; | ||
39 | KeyRepeater m_oRepeater; | ||
40 | }; | ||
41 | |||
42 | #endif /* _KEY_HELPER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperApplet.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperApplet.cpp new file mode 100644 index 0000000..28304d7 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperApplet.cpp | |||
@@ -0,0 +1,65 @@ | |||
1 | #include "KeyHelperApplet.h" | ||
2 | #include "KeyHelperWidget.h" | ||
3 | |||
4 | #if 0 | ||
5 | KeyHelperApplet::KeyHelperApplet() | ||
6 | : widget(0), ref(0) | ||
7 | { | ||
8 | qDebug("KeyHelperApplet::KeyHelperApplet()"); | ||
9 | } | ||
10 | |||
11 | KeyHelperApplet::~KeyHelperApplet() | ||
12 | { | ||
13 | qDebug("KeyHelperApplet::~KeyHelperApplet()"); | ||
14 | delete widget; | ||
15 | } | ||
16 | |||
17 | QWidget* KeyHelperApplet::applet(QWidget* parent) | ||
18 | { | ||
19 | if(!widget){ | ||
20 | widget = new KeyHelperWidget(parent); | ||
21 | } | ||
22 | return(widget); | ||
23 | } | ||
24 | |||
25 | int KeyHelperApplet::position() const | ||
26 | { | ||
27 | return(6); | ||
28 | } | ||
29 | |||
30 | QRESULT KeyHelperApplet::queryInterface(const QUuid& uuid, | ||
31 | QUnknownInterface** iface) | ||
32 | { | ||
33 | *iface = 0; | ||
34 | |||
35 | if(QFile::exists("/tmp/disable-keyhelper") | ||
36 | || QFile::exists("/mnt/card/disable-keyhelper") | ||
37 | || QFile::exists("/mnt/cf/disable-keyhelper")){ | ||
38 | return QS_FALSE; | ||
39 | } | ||
40 | |||
41 | if(uuid == IID_QUnknown){ | ||
42 | *iface = this; | ||
43 | } else if(uuid == IID_TaskbarApplet){ | ||
44 | *iface = this; | ||
45 | } | ||
46 | |||
47 | if(*iface){ | ||
48 | (*iface)->addRef(); | ||
49 | } | ||
50 | return QS_OK; | ||
51 | } | ||
52 | |||
53 | Q_EXPORT_INTERFACE() | ||
54 | { | ||
55 | Q_CREATE_INSTANCE(KeyHelperApplet) | ||
56 | } | ||
57 | |||
58 | #else | ||
59 | #include <opie2/otaskbarapplet.h> | ||
60 | |||
61 | using namespace Opie::Ui; | ||
62 | |||
63 | EXPORT_OPIE_APPLET_v1( KeyHelperWidget ) | ||
64 | |||
65 | #endif | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperApplet.h b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperApplet.h new file mode 100644 index 0000000..ef164dc --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperApplet.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef _KEY_HELPER_APPLET_H_ | ||
2 | #define _KEY_HELPER_APPLET_H_ | ||
3 | |||
4 | #if 0 | ||
5 | #include <qpe/taskbarappletinterface.h> | ||
6 | #include "KeyHelperWidget.h" | ||
7 | |||
8 | class KeyHelperApplet : public TaskbarAppletInterface | ||
9 | { | ||
10 | public: | ||
11 | KeyHelperApplet(); | ||
12 | virtual ~KeyHelperApplet(); | ||
13 | |||
14 | QRESULT queryInterface(const QUuid&, QUnknownInterface**); | ||
15 | Q_REFCOUNT | ||
16 | |||
17 | virtual QWidget* applet(QWidget* parent); | ||
18 | virtual int position() const; | ||
19 | private: | ||
20 | KeyHelperWidget* widget; | ||
21 | ulong ref; | ||
22 | }; | ||
23 | |||
24 | #endif | ||
25 | |||
26 | #endif /* _KEY_HELPER_APPLET_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp new file mode 100644 index 0000000..7beb511 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.cpp | |||
@@ -0,0 +1,490 @@ | |||
1 | #include "KeyHelperWidget.h" | ||
2 | #include "QSafeDataStream.h" | ||
3 | #include "KHUtil.h" | ||
4 | |||
5 | QWidget* g_Widget = NULL; | ||
6 | int g_level = 0; | ||
7 | |||
8 | static const char* _version_ = "1.2.2"; | ||
9 | |||
10 | KeyHelperWidget::KeyHelperWidget(QWidget* parent, const char* name) | ||
11 | : QLabel(parent, name),disabled(Resource::loadPixmap("zkb-disabled")) | ||
12 | { | ||
13 | qDebug("KeyHelperWidget::KeyHelperWidget()"); | ||
14 | g_Widget = this; | ||
15 | m_defHandler = NULL; | ||
16 | //m_reset = false; | ||
17 | m_reset = true; | ||
18 | m_useFilter = false; | ||
19 | m_pHelper = NULL; | ||
20 | m_status = false; | ||
21 | |||
22 | //unset(); | ||
23 | initDebugLevel(); | ||
24 | |||
25 | m_pHelper = new KeyHelper(); | ||
26 | |||
27 | //qApp->installEventFilter(this); | ||
28 | |||
29 | connect(qwsServer, | ||
30 | SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), | ||
31 | this, | ||
32 | SLOT(windowEvent(QWSWindow*, QWSServer::WindowEvent))); | ||
33 | |||
34 | m_pChannel = new QCopChannel("QPE/KeyHelper", this); | ||
35 | connect(m_pChannel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
36 | this, SLOT(receiveMessage(const QCString&, const QByteArray&))); | ||
37 | m_pSysChannel = new QCopChannel("QPE/System", this); | ||
38 | connect(m_pSysChannel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
39 | this, SLOT(sysMessage(const QCString&, const QByteArray&))); | ||
40 | |||
41 | //AppLnkManager::init(); | ||
42 | setFixedWidth ( AppLnk::smallIconSize() ); | ||
43 | setFixedHeight ( AppLnk::smallIconSize() ); | ||
44 | setPixmap(disabled); | ||
45 | init(); | ||
46 | } | ||
47 | |||
48 | KeyHelperWidget::~KeyHelperWidget() | ||
49 | { | ||
50 | qDebug("KeyHelperWidget::~KeyHelperWidget()"); | ||
51 | disconnect(qwsServer, | ||
52 | SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)), | ||
53 | this, | ||
54 | SLOT(windowEvent(QWSWindow*, QWSServer::WindowEvent))); | ||
55 | disconnect(m_pChannel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
56 | this, SLOT(receiveMessage(const QCString&, const QByteArray&))); | ||
57 | unset(); | ||
58 | if (m_pHelper) delete m_pHelper; | ||
59 | if (m_pChannel) delete m_pChannel; | ||
60 | if (m_pSysChannel) delete m_pSysChannel; | ||
61 | m_pHelper = NULL; | ||
62 | setDebugLevel(0); | ||
63 | } | ||
64 | |||
65 | void KeyHelperWidget::mouseReleaseEvent(QMouseEvent*) | ||
66 | { | ||
67 | ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); | ||
68 | } | ||
69 | |||
70 | void KeyHelperWidget::receiveMessage( | ||
71 | const QCString& msg, const QByteArray& data) | ||
72 | { | ||
73 | if(m_pHelper == NULL){ | ||
74 | return; | ||
75 | } | ||
76 | QSafeDataStream stream(data, IO_ReadOnly); | ||
77 | if(msg == "event(int,int,int,int,int)"){ | ||
78 | int unicode; | ||
79 | int keycode; | ||
80 | int modifiers; | ||
81 | int isPress; | ||
82 | int autoRepeat; | ||
83 | stream >> unicode >> keycode >> modifiers >> isPress >> autoRepeat; | ||
84 | doEvent(unicode, keycode, modifiers, isPress, autoRepeat); | ||
85 | } else if(msg == "event(QString,int)"){ | ||
86 | QString key; | ||
87 | int isPress; | ||
88 | stream >> key >> isPress; | ||
89 | doEvent(key, isPress); | ||
90 | } else if(msg == "enable()"){ | ||
91 | enable(); | ||
92 | } else if(msg == "disable()"){ | ||
93 | disable(); | ||
94 | } else if(msg == "pause()"){ | ||
95 | pause(); | ||
96 | } else if(msg == "restart()"){ | ||
97 | restart(); | ||
98 | } else if(msg == "reload()"){ | ||
99 | m_xmlfile = QString::null; | ||
100 | doReload(); | ||
101 | } else if(msg == "reload(QString)"){ | ||
102 | stream >> m_xmlfile; | ||
103 | doReload(false); | ||
104 | } else if(msg == "version()"){ | ||
105 | version(); | ||
106 | } else if(msg == "repeater(int)"){ | ||
107 | int mode; | ||
108 | stream >> mode; | ||
109 | m_pHelper->m_oRepeater.setMode(mode); | ||
110 | } else if(msg == "hook(QString)"){ | ||
111 | QString s; | ||
112 | stream >> s; | ||
113 | m_pHelper->m_oAction.setHook(s.local8Bit()); | ||
114 | } else if(msg == "unhook()"){ | ||
115 | m_pHelper->m_oAction.setHook(""); | ||
116 | } else if(msg == "config()"){ | ||
117 | ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); | ||
118 | } else if(msg == "config(QString)"){ | ||
119 | QString name; | ||
120 | stream >> name; | ||
121 | if(name == QString::null){ | ||
122 | ConfigEx::getInstance("keyhelper").setConfig("keyhelper"); | ||
123 | } else { | ||
124 | ConfigEx::getInstance("keyhelper").setConfig(name); | ||
125 | } | ||
126 | } else if(msg == "capture(int)"){ | ||
127 | int enable; | ||
128 | stream >> enable; | ||
129 | m_pHelper->m_oAction.setCapture(enable); | ||
130 | } else if(msg == "statistics()"){ | ||
131 | int level = g_level; | ||
132 | if(level == 0){ | ||
133 | setDebugLevel(1); | ||
134 | } | ||
135 | m_pHelper->statistics(); | ||
136 | if(level == 0){ | ||
137 | setDebugLevel(0); | ||
138 | } | ||
139 | } else if(msg == "dumpkeymap()"){ | ||
140 | int level = g_level; | ||
141 | if(level == 0){ | ||
142 | setDebugLevel(1); | ||
143 | } | ||
144 | m_pHelper->dumpkeymap(); | ||
145 | if(level == 0){ | ||
146 | setDebugLevel(0); | ||
147 | } | ||
148 | } else if(msg == "debug(int)"){ | ||
149 | int level; | ||
150 | stream >> level; | ||
151 | setDebugLevel(level); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | void KeyHelperWidget::doReload(bool showstatus) | ||
156 | { | ||
157 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
158 | QString oldgroup = cfg.getGroup(); | ||
159 | cfg.setGroup("Global"); | ||
160 | m_status = false; | ||
161 | if(showstatus && (cfg.readNumEntry("ShowStatusOnReload", 1) == 1)){ | ||
162 | m_status = true; | ||
163 | version(); | ||
164 | QCopEnvelope("QPE/System", "busy()"); | ||
165 | } | ||
166 | cfg.setGroup(oldgroup); | ||
167 | QTimer::singleShot(0, this, SLOT(reload())); | ||
168 | } | ||
169 | |||
170 | void KeyHelperWidget::doEvent(int unicode, int keycode, int modifiers, int isPress, int autoRepeat) | ||
171 | { | ||
172 | if(isPress == 0 || isPress == 1){ | ||
173 | m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, isPress, autoRepeat); | ||
174 | m_pHelper->m_oAction.doAction(); | ||
175 | } else { | ||
176 | /* press & release */ | ||
177 | m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, 1, autoRepeat); | ||
178 | m_pHelper->m_oAction.doAction(); | ||
179 | m_pHelper->m_oAction.setAction(unicode, keycode, modifiers, 0, autoRepeat); | ||
180 | m_pHelper->m_oAction.doAction(); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | void KeyHelperWidget::doEvent(const QString& key, int isPress) | ||
185 | { | ||
186 | int unicode,keycode; | ||
187 | int modifiers = 0; | ||
188 | int pos; | ||
189 | QString keyname = key; | ||
190 | pos = keyname.find("+SHIFT", 0, FALSE); | ||
191 | if(pos > 0){ | ||
192 | modifiers |= Qt::ShiftButton; | ||
193 | keyname.remove(pos, 6); | ||
194 | } | ||
195 | pos = keyname.find("+CTRL", 0, FALSE); | ||
196 | if(pos > 0){ | ||
197 | modifiers |= Qt::ControlButton; | ||
198 | keyname.remove(pos, 5); | ||
199 | } | ||
200 | pos = keyname.find("+ALT", 0, FALSE); | ||
201 | if(pos > 0){ | ||
202 | modifiers |= Qt::AltButton; | ||
203 | keyname.remove(pos, 4); | ||
204 | } | ||
205 | if(keyname.length() > 1){ | ||
206 | unicode = 0xffff; | ||
207 | keycode = KeyNames::getCode(keyname); | ||
208 | /* get unicode */ | ||
209 | const QWSServer::KeyMap* m; | ||
210 | for(m=QWSServer::keyMap(); m->key_code != 0; m++){ | ||
211 | if(m->key_code == keycode){ | ||
212 | if(modifiers & Qt::ControlButton){ | ||
213 | unicode = m->ctrl_unicode; | ||
214 | } else if(modifiers & Qt::ShiftButton){ | ||
215 | unicode = m->shift_unicode; | ||
216 | } else { | ||
217 | unicode = m->unicode; | ||
218 | } | ||
219 | break; | ||
220 | } | ||
221 | } | ||
222 | } else { | ||
223 | const QWSServer::KeyMap* m; | ||
224 | keycode = 0; | ||
225 | unicode = keyname[0].unicode(); | ||
226 | /* check unicode */ | ||
227 | for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ | ||
228 | if(m->unicode == unicode){ | ||
229 | keycode = m->key_code; | ||
230 | break; | ||
231 | } | ||
232 | } | ||
233 | /* check shift_unicode */ | ||
234 | for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ | ||
235 | if(m->shift_unicode == unicode){ | ||
236 | keycode = m->key_code; | ||
237 | modifiers |= Qt::ShiftButton; | ||
238 | break; | ||
239 | } | ||
240 | } | ||
241 | /* check ctrl_unicode */ | ||
242 | for(m=QWSServer::keyMap(); keycode == 0 && m->key_code != 0; m++){ | ||
243 | if(m->ctrl_unicode == unicode){ | ||
244 | keycode = m->key_code; | ||
245 | modifiers |= Qt::ControlButton; | ||
246 | break; | ||
247 | } | ||
248 | } | ||
249 | } | ||
250 | doEvent(unicode, keycode, modifiers, isPress, 0); | ||
251 | } | ||
252 | |||
253 | void KeyHelperWidget::sysMessage( | ||
254 | const QCString& msg, const QByteArray& data) | ||
255 | { | ||
256 | QSafeDataStream stream(data, IO_ReadOnly); | ||
257 | if(msg == "linkChanged(QString)"){ | ||
258 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
259 | QString oldgroup = cfg.getGroup(); | ||
260 | if(cfg.readNumEntry("DetectLinkChange", 1) == 1){ | ||
261 | AppLnkManager::init(true); | ||
262 | reload(); | ||
263 | } | ||
264 | cfg.setGroup(oldgroup); | ||
265 | } | ||
266 | } | ||
267 | |||
268 | void MsgHandler(QtMsgType type, const char* msg) | ||
269 | { | ||
270 | switch(type){ | ||
271 | case QtDebugMsg: | ||
272 | if(g_level >= 2){ | ||
273 | syslog(LOG_LOCAL5|LOG_DEBUG, | ||
274 | "<2>%s", msg); | ||
275 | } | ||
276 | break; | ||
277 | case QtWarningMsg: | ||
278 | if(g_level >= 1){ | ||
279 | syslog(LOG_LOCAL5|LOG_DEBUG, | ||
280 | "<1>%s", msg); | ||
281 | } | ||
282 | break; | ||
283 | default: | ||
284 | break; | ||
285 | } | ||
286 | } | ||
287 | |||
288 | void KeyHelperWidget::initDebugLevel() | ||
289 | { | ||
290 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
291 | cfg.setGroup("Global"); | ||
292 | |||
293 | int level = cfg.readNumEntry("DebugLevel", 0); | ||
294 | setDebugLevel(level); | ||
295 | } | ||
296 | |||
297 | void KeyHelperWidget::setDebugLevel(int level) | ||
298 | { | ||
299 | #ifdef QT_QWS_EBX | ||
300 | static bool noDebug = true; | ||
301 | g_level = level; | ||
302 | if(g_level > 0){ | ||
303 | if(noDebug){ | ||
304 | m_defHandler = qInstallMsgHandler(MsgHandler); | ||
305 | noDebug = false; | ||
306 | } | ||
307 | } else { | ||
308 | qInstallMsgHandler(m_defHandler); | ||
309 | noDebug = true; | ||
310 | } | ||
311 | #endif | ||
312 | } | ||
313 | |||
314 | void KeyHelperWidget::enable() | ||
315 | { | ||
316 | m_enable = true; | ||
317 | m_pHelper->enable(); | ||
318 | //set(); | ||
319 | QTimer::singleShot(0, this, SLOT(set())); | ||
320 | } | ||
321 | |||
322 | void KeyHelperWidget::disable() | ||
323 | { | ||
324 | m_enable = false; | ||
325 | m_pHelper->disable(); | ||
326 | unset(); | ||
327 | } | ||
328 | |||
329 | void KeyHelperWidget::pause() | ||
330 | { | ||
331 | m_saved = m_enable; | ||
332 | disable(); | ||
333 | } | ||
334 | |||
335 | void KeyHelperWidget::restart() | ||
336 | { | ||
337 | if(m_saved){ | ||
338 | enable(); | ||
339 | } | ||
340 | } | ||
341 | |||
342 | void KeyHelperWidget::reload() | ||
343 | { | ||
344 | disable(); | ||
345 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
346 | cfg.reload(); | ||
347 | if(m_pHelper->reload(m_xmlfile) == false){ | ||
348 | if(m_status){ | ||
349 | Global::statusMessage("KeyHelper: Load Error"); | ||
350 | } | ||
351 | } | ||
352 | init(); | ||
353 | if(m_status){ | ||
354 | QCopEnvelope e("QPE/System", "notBusy(QString)"); | ||
355 | const QString app = KHUtil::currentApp(); | ||
356 | e << app; | ||
357 | m_status = false; | ||
358 | } | ||
359 | } | ||
360 | |||
361 | void KeyHelperWidget::version() | ||
362 | { | ||
363 | QString ver = "KeyHelper "; | ||
364 | ver.append(_version_); | ||
365 | Global::statusMessage(ver); | ||
366 | } | ||
367 | |||
368 | void KeyHelperWidget::init() | ||
369 | { | ||
370 | AppLnkManager::init(); | ||
371 | #if 0 | ||
372 | if(m_pHelper == NULL){ | ||
373 | m_pHelper = new KeyHelper(); | ||
374 | } | ||
375 | #endif | ||
376 | loadUseFilterApps(); | ||
377 | enable(); | ||
378 | } | ||
379 | |||
380 | void KeyHelperWidget::set() | ||
381 | { | ||
382 | if(m_pHelper != NULL && m_enable == true && m_useFilter == false){ | ||
383 | qWarning("KeyHelperWidget::set()"); | ||
384 | m_pHelper->set(); | ||
385 | } | ||
386 | } | ||
387 | |||
388 | void KeyHelperWidget::unset() | ||
389 | { | ||
390 | m_pHelper->unset(); | ||
391 | } | ||
392 | |||
393 | void KeyHelperWidget::loadUseFilterApps() | ||
394 | { | ||
395 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
396 | |||
397 | cfg.setGroup("Global"); | ||
398 | m_apps = cfg.readListEntry("UseFilterApps", ','); | ||
399 | |||
400 | if(m_apps.isEmpty()){ | ||
401 | /* default */ | ||
402 | m_apps.append("CRIM"); | ||
403 | m_apps.append("Jpn50Pad"); | ||
404 | m_apps.append("JpnKtnPad"); | ||
405 | m_apps.append("JpnNumPad"); | ||
406 | m_apps.append("JpnSymPad"); | ||
407 | m_apps.append("Keyboard"); | ||
408 | m_apps.append("IMWidget"); /* IMKit */ | ||
409 | m_apps.append("POBox"); /* QPOBox */ | ||
410 | } | ||
411 | } | ||
412 | |||
413 | #if 0 | ||
414 | void KeyHelperWidget::windowEvent(QWSWindow* w, QWSServer::WindowEvent e) | ||
415 | { | ||
416 | if(m_apps.contains(w->name())){ | ||
417 | switch(e){ | ||
418 | case QWSServer::Hide: | ||
419 | case QWSServer::Destroy: | ||
420 | m_useFilter = false; | ||
421 | //m_reset = true; | ||
422 | QTimer::singleShot(0, this, SLOT(set())); | ||
423 | break; | ||
424 | case QWSServer::Create: | ||
425 | case QWSServer::Raise: | ||
426 | case QWSServer::Show: | ||
427 | m_useFilter = true; | ||
428 | //m_reset = false; | ||
429 | m_reset = true; | ||
430 | break; | ||
431 | default: | ||
432 | break; | ||
433 | } | ||
434 | } else if(w->client()->identity() != NULL && w->name() != NULL){ | ||
435 | switch(e){ | ||
436 | #if 0 | ||
437 | case QWSServer::Create: | ||
438 | case QWSServer::Hide: | ||
439 | if(m_useFilter == false && m_reset){ | ||
440 | m_reset = false; | ||
441 | set(); | ||
442 | //QTimer::singleShot(0, this, SLOT(set())); | ||
443 | } | ||
444 | break; | ||
445 | #else | ||
446 | case QWSServer::Hide: | ||
447 | case QWSServer::Destroy: | ||
448 | //if(m_useFilter == false && m_reset){ | ||
449 | if(m_reset){ | ||
450 | m_reset = false; | ||
451 | set(); | ||
452 | //QTimer::singleShot(0, this, SLOT(set())); | ||
453 | } | ||
454 | break; | ||
455 | case QWSServer::Create: | ||
456 | case QWSServer::Raise: | ||
457 | case QWSServer::Show: | ||
458 | m_reset = true; | ||
459 | break; | ||
460 | #endif | ||
461 | default: | ||
462 | #if 0 | ||
463 | if(m_reset == true){ | ||
464 | m_reset = false; | ||
465 | set(); | ||
466 | } | ||
467 | #endif | ||
468 | break; | ||
469 | } | ||
470 | } | ||
471 | if(w->name() != NULL){ | ||
472 | qWarning("[%s][%s][%x][%s]", | ||
473 | w->name().latin1(), | ||
474 | w->caption().latin1(), | ||
475 | e, | ||
476 | w->client()->identity().latin1()); | ||
477 | } | ||
478 | } | ||
479 | |||
480 | #endif | ||
481 | |||
482 | bool KeyHelperWidget::eventFilter(QObject* o, QEvent* e) | ||
483 | { | ||
484 | return QWidget::eventFilter(o, e); | ||
485 | } | ||
486 | |||
487 | int KeyHelperWidget::position() | ||
488 | { | ||
489 | return 3; | ||
490 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h new file mode 100644 index 0000000..4798c5c --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelperWidget.h | |||
@@ -0,0 +1,75 @@ | |||
1 | #ifndef _KEY_HELPER_WIDGET_H_ | ||
2 | #define _KEY_HELPER_WIDGET_H_ | ||
3 | |||
4 | #include <qwidget.h> | ||
5 | #include <qlabel.h> | ||
6 | #include <qpixmap.h> | ||
7 | #include <qtimer.h> | ||
8 | #include <qaccel.h> | ||
9 | #include <opie2/otaskbarapplet.h> | ||
10 | #include <opie2/okeyfilter.h> | ||
11 | |||
12 | #include <qpe/qcopenvelope_qws.h> | ||
13 | #include <qpe/qpeapplication.h> | ||
14 | #include <qpe/global.h> | ||
15 | #include <qpe/resource.h> | ||
16 | #include "KeyHelper.h" | ||
17 | #include "AppLnkManager.h" | ||
18 | #include "ConfigEx.h" | ||
19 | |||
20 | #include <syslog.h> | ||
21 | |||
22 | Q_EXPORT void MsgHandler(QtMsgType type, const char* msg); | ||
23 | |||
24 | class KeyHelperWidget : public QLabel | ||
25 | { | ||
26 | Q_OBJECT | ||
27 | public: | ||
28 | KeyHelperWidget(QWidget* parent = 0, const char* name=0); | ||
29 | ~KeyHelperWidget(); | ||
30 | static int position(); | ||
31 | |||
32 | virtual bool eventFilter(QObject* o, QEvent* e); | ||
33 | |||
34 | public slots: | ||
35 | //void windowEvent(QWSWindow* w, QWSServer::WindowEvent e); | ||
36 | protected: | ||
37 | QCopChannel* m_pChannel; | ||
38 | QCopChannel* m_pSysChannel; | ||
39 | QPixmap disabled; | ||
40 | |||
41 | protected slots: | ||
42 | void receiveMessage(const QCString& msg, const QByteArray& data); | ||
43 | void sysMessage(const QCString& msg, const QByteArray& data); | ||
44 | void reload(); | ||
45 | void set(); | ||
46 | void unset(); | ||
47 | void init(); | ||
48 | void mouseReleaseEvent(QMouseEvent*); | ||
49 | |||
50 | private: | ||
51 | void loadUseFilterApps(); | ||
52 | void enable(); | ||
53 | void disable(); | ||
54 | void pause(); | ||
55 | void restart(); | ||
56 | void version(); | ||
57 | void setDebugLevel(int level); | ||
58 | void initDebugLevel(); | ||
59 | |||
60 | bool m_reset; | ||
61 | bool m_useFilter; | ||
62 | bool m_status; | ||
63 | QString m_xmlfile; | ||
64 | msg_handler m_defHandler; | ||
65 | bool m_enable; | ||
66 | bool m_saved; | ||
67 | QStringList m_apps; | ||
68 | KeyHelper* m_pHelper; | ||
69 | private slots: | ||
70 | void doReload(bool showstatus=true); | ||
71 | void doEvent(int,int,int,int,int); | ||
72 | void doEvent(const QString&, int); | ||
73 | }; | ||
74 | |||
75 | #endif /* _KEY_HELPER_WIDGET_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/QSafeDataStream.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/QSafeDataStream.cpp new file mode 100644 index 0000000..69ba562 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/QSafeDataStream.cpp | |||
@@ -0,0 +1,203 @@ | |||
1 | #include "QSafeDataStream.h" | ||
2 | |||
3 | #include <qstring.h> | ||
4 | #include <qstringlist.h> | ||
5 | #include <qdatetime.h> | ||
6 | |||
7 | QSafeDataStream &QSafeDataStream::operator>>( Q_INT8 &i ) | ||
8 | { | ||
9 | if(atEnd()){ | ||
10 | i = 0; | ||
11 | return *this; | ||
12 | } else { | ||
13 | return (QSafeDataStream&)QDataStream::operator>>(i); | ||
14 | } | ||
15 | } | ||
16 | |||
17 | QSafeDataStream &QSafeDataStream::operator>>( Q_UINT8 &i ) | ||
18 | { | ||
19 | if(atEnd()){ | ||
20 | i = 0; | ||
21 | return *this; | ||
22 | } else { | ||
23 | return (QSafeDataStream&)QDataStream::operator>>(i); | ||
24 | } | ||
25 | } | ||
26 | |||
27 | QSafeDataStream &QSafeDataStream::operator>>( Q_INT16 &i ) | ||
28 | { | ||
29 | if(atEnd()){ | ||
30 | i = 0; | ||
31 | return *this; | ||
32 | } else { | ||
33 | return (QSafeDataStream&)QDataStream::operator>>(i); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | QSafeDataStream &QSafeDataStream::operator>>( Q_UINT16 &i ) | ||
38 | { | ||
39 | if(atEnd()){ | ||
40 | i = 0; | ||
41 | return *this; | ||
42 | } else { | ||
43 | return (QSafeDataStream&)QDataStream::operator>>(i); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | QSafeDataStream &QSafeDataStream::operator>>( Q_INT32 &i ) | ||
48 | { | ||
49 | if(atEnd()){ | ||
50 | i = 0; | ||
51 | return *this; | ||
52 | } else { | ||
53 | return (QSafeDataStream&)QDataStream::operator>>(i); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | QSafeDataStream &QSafeDataStream::operator>>( Q_UINT32 &i ) | ||
58 | { | ||
59 | if(atEnd()){ | ||
60 | i = 0; | ||
61 | return *this; | ||
62 | } else { | ||
63 | return (QSafeDataStream&)QDataStream::operator>>(i); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | QSafeDataStream &QSafeDataStream::operator>>( Q_INT64 &i ) | ||
68 | { | ||
69 | if(atEnd()){ | ||
70 | i = 0; | ||
71 | return *this; | ||
72 | } else { | ||
73 | return (QSafeDataStream&)QDataStream::operator>>(i); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | QSafeDataStream &QSafeDataStream::operator>>( Q_UINT64 &i ) | ||
78 | { | ||
79 | if(atEnd()){ | ||
80 | i = 0; | ||
81 | return *this; | ||
82 | } else { | ||
83 | return (QSafeDataStream&)QDataStream::operator>>(i); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | |||
88 | QSafeDataStream &QSafeDataStream::operator>>( float &f ) | ||
89 | { | ||
90 | if(atEnd()){ | ||
91 | f = 0; | ||
92 | return *this; | ||
93 | } else { | ||
94 | return (QSafeDataStream&)QDataStream::operator>>(f); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | QSafeDataStream &QSafeDataStream::operator>>( double &f ) | ||
99 | { | ||
100 | if(atEnd()){ | ||
101 | f = 0; | ||
102 | return *this; | ||
103 | } else { | ||
104 | return (QSafeDataStream&)QDataStream::operator>>(f); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | QSafeDataStream &QSafeDataStream::operator>>( char *&str ) | ||
109 | { | ||
110 | if(atEnd()){ | ||
111 | str = 0; | ||
112 | return *this; | ||
113 | } else { | ||
114 | return (QSafeDataStream&)QDataStream::operator>>(str); | ||
115 | } | ||
116 | } | ||
117 | |||
118 | QSafeDataStream &QSafeDataStream::readBytes( char *&s, uint &len ) | ||
119 | { | ||
120 | if(atEnd()){ | ||
121 | s = 0; | ||
122 | len = 0; | ||
123 | return *this; | ||
124 | } else { | ||
125 | return (QSafeDataStream&)QDataStream::readBytes(s, len); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | QSafeDataStream &QSafeDataStream::readRawBytes( char *s, uint len ) | ||
130 | { | ||
131 | if(atEnd()){ | ||
132 | return *this; | ||
133 | } else { | ||
134 | return (QSafeDataStream&)QDataStream::readRawBytes(s, len); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | QSafeDataStream &QSafeDataStream::operator>>( QString& s ) | ||
139 | { | ||
140 | if(atEnd()){ | ||
141 | s = QString::null; | ||
142 | return *this; | ||
143 | } else { | ||
144 | return (QSafeDataStream&)(*((QDataStream*)this) >> s); | ||
145 | } | ||
146 | } | ||
147 | |||
148 | QSafeDataStream &QSafeDataStream::operator>>( QStringList& list ) | ||
149 | { | ||
150 | if(atEnd()){ | ||
151 | list.clear(); | ||
152 | return *this; | ||
153 | } else { | ||
154 | return (QSafeDataStream&)(*((QDataStream*)this) >> list); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | QSafeDataStream &QSafeDataStream::operator>>( QByteArray& a ) | ||
159 | { | ||
160 | if(atEnd()){ | ||
161 | a.resize(0); | ||
162 | return *this; | ||
163 | } else { | ||
164 | return (QSafeDataStream&)(*((QDataStream*)this) >> a); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | QSafeDataStream &QSafeDataStream::operator>>( QCString& s ) | ||
169 | { | ||
170 | if(atEnd()){ | ||
171 | s.resize(0); | ||
172 | return *this; | ||
173 | } else { | ||
174 | return (QSafeDataStream&)(*((QDataStream*)this) >> s); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | QSafeDataStream &QSafeDataStream::operator>>( QDate& d ) | ||
179 | { | ||
180 | if(atEnd()){ | ||
181 | return *this; | ||
182 | } else { | ||
183 | return (QSafeDataStream&)(*((QDataStream*)this) >> d); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | QSafeDataStream &QSafeDataStream::operator>>( QTime& t ) | ||
188 | { | ||
189 | if(atEnd()){ | ||
190 | return *this; | ||
191 | } else { | ||
192 | return (QSafeDataStream&)(*((QDataStream*)this) >> t); | ||
193 | } | ||
194 | } | ||
195 | |||
196 | QSafeDataStream &QSafeDataStream::operator>>( QDateTime& dt ) | ||
197 | { | ||
198 | if(atEnd()){ | ||
199 | return *this; | ||
200 | } else { | ||
201 | return (QSafeDataStream&)(*((QDataStream*)this) >> dt); | ||
202 | } | ||
203 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/QSafeDataStream.h b/noncore/applets/keyhelper/keyhelperapplet/applet/QSafeDataStream.h new file mode 100644 index 0000000..2152b23 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/QSafeDataStream.h | |||
@@ -0,0 +1,51 @@ | |||
1 | #ifndef _QSAFEDATASTREAM_H_ | ||
2 | #define _QSAFEDATASTREAM_H_ | ||
3 | |||
4 | #include <qdatastream.h> | ||
5 | |||
6 | class QString; | ||
7 | class QStringList; | ||
8 | class QCString; | ||
9 | class QDate; | ||
10 | class QTime; | ||
11 | class QDateTime; | ||
12 | |||
13 | class QSafeDataStream : public QDataStream | ||
14 | { | ||
15 | public: | ||
16 | /* constructors */ | ||
17 | QSafeDataStream() | ||
18 | : QDataStream() {} | ||
19 | QSafeDataStream(QIODevice* d) | ||
20 | : QDataStream(d) {} | ||
21 | QSafeDataStream(QByteArray a, int mode) | ||
22 | : QDataStream(a, mode) {} | ||
23 | |||
24 | /* read functions */ | ||
25 | QSafeDataStream &operator>>( Q_INT8 &i ); | ||
26 | QSafeDataStream &operator>>( Q_UINT8 &i ); | ||
27 | QSafeDataStream &operator>>( Q_INT16 &i ); | ||
28 | QSafeDataStream &operator>>( Q_UINT16 &i ); | ||
29 | QSafeDataStream &operator>>( Q_INT32 &i ); | ||
30 | QSafeDataStream &operator>>( Q_UINT32 &i ); | ||
31 | QSafeDataStream &operator>>( Q_INT64 &i ); | ||
32 | QSafeDataStream &operator>>( Q_UINT64 &i ); | ||
33 | |||
34 | QSafeDataStream &operator>>( float &f ); | ||
35 | QSafeDataStream &operator>>( double &f ); | ||
36 | QSafeDataStream &operator>>( char *&str ); | ||
37 | |||
38 | QSafeDataStream &readBytes( char *&, uint &len ); | ||
39 | QSafeDataStream &readRawBytes( char *, uint len ); | ||
40 | |||
41 | QSafeDataStream &operator>>( QString& s ); | ||
42 | QSafeDataStream &operator>>( QStringList& list ); | ||
43 | QSafeDataStream &operator>>( QByteArray& a ); | ||
44 | QSafeDataStream &operator>>( QCString& s ); | ||
45 | QSafeDataStream &operator>>( QDate& d ); | ||
46 | QSafeDataStream &operator>>( QTime& t ); | ||
47 | QSafeDataStream &operator>>( QDateTime& dt ); | ||
48 | |||
49 | }; | ||
50 | |||
51 | #endif /* _QSAFEDATASTREAM_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/ExtensionsHandler.cpp b/noncore/applets/keyhelper/keyhelperapplet/config/ExtensionsHandler.cpp new file mode 100644 index 0000000..84bb375 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/ExtensionsHandler.cpp | |||
@@ -0,0 +1,80 @@ | |||
1 | #include "ExtensionsHandler.h" | ||
2 | |||
3 | void ExtensionsHandler::dispose(QXmlReader* parser, QXmlContentHandler* parent) | ||
4 | { | ||
5 | m_parser = parser; | ||
6 | m_parent = parent; | ||
7 | m_parser->setContentHandler(this); | ||
8 | } | ||
9 | |||
10 | bool ExtensionsHandler::startElement(const QString& /* namespaceURI */, | ||
11 | const QString& localName, | ||
12 | const QString& /* qName */, | ||
13 | const QXmlAttributes& attr) | ||
14 | { | ||
15 | if(localName == "define"){ | ||
16 | /* ÊÑ¿ô½é´ü²½ */ | ||
17 | m_kind = QString::null; | ||
18 | m_code = -1; | ||
19 | //m_mask = 0; | ||
20 | m_modlist.clear(); | ||
21 | for(int i=0; i<attr.length(); i++){ | ||
22 | if(attr.localName(i).lower() == "key"){ | ||
23 | /* keyname */ | ||
24 | if(attr.value(i) == "All"){ | ||
25 | m_code = 0; | ||
26 | } else { | ||
27 | m_code = KeyNames::getCode(attr.value(i)); | ||
28 | } | ||
29 | } else if(attr.localName(i).lower() == "code"){ | ||
30 | /* keycode */ | ||
31 | m_code = KHUtil::hex2int(attr.value(i).lower()); | ||
32 | } else if(attr.localName(i).lower() == "kind"){ | ||
33 | /* extension kind */ | ||
34 | m_kind = attr.value(i); | ||
35 | } | ||
36 | } | ||
37 | } else if(localName == "modifier"){ | ||
38 | /* modifier keys */ | ||
39 | for(int i=0; i<attr.length(); i++){ | ||
40 | if(attr.value(i).lower() == "on"){ | ||
41 | m_modlist.append(attr.localName(i)); | ||
42 | //m_mask |= m_pModifiers->getMask(attr.localName(i)); | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | return(true); | ||
47 | } | ||
48 | |||
49 | bool ExtensionsHandler::endElement(const QString& /* namespaceURI */, | ||
50 | const QString& localName, | ||
51 | const QString& /* qName */) | ||
52 | { | ||
53 | if(localName == "define"){ | ||
54 | #if 0 | ||
55 | if(m_kind != QString::null | ||
56 | && (m_code > 0 || m_modlist.isEmpty() == false)){ | ||
57 | #else | ||
58 | if(m_kind != QString::null && m_code >= 0){ | ||
59 | #endif | ||
60 | /* assign extension */ | ||
61 | int keymask = 0; | ||
62 | QValueList<int> modcodes; | ||
63 | for(QStringList::Iterator it=m_modlist.begin(); | ||
64 | it!=m_modlist.end(); ++it){ | ||
65 | keymask |= m_pModifiers->getMask(*it); | ||
66 | qDebug("mask[%s][%x][%s]", m_kind.latin1(), keymask, (*it).latin1()); | ||
67 | int code = KeyNames::getCode(*it); | ||
68 | if(code > 0){ | ||
69 | modcodes.append(code); | ||
70 | } | ||
71 | } | ||
72 | m_pExtensions->assign(m_kind, m_code, keymask, modcodes); | ||
73 | } | ||
74 | } else if(localName == "extensions"){ | ||
75 | m_pExtensions->init(); | ||
76 | /* return parent */ | ||
77 | m_parser->setContentHandler(m_parent); | ||
78 | } | ||
79 | return(true); | ||
80 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/ExtensionsHandler.h b/noncore/applets/keyhelper/keyhelperapplet/config/ExtensionsHandler.h new file mode 100644 index 0000000..cc2422b --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/ExtensionsHandler.h | |||
@@ -0,0 +1,48 @@ | |||
1 | #ifndef _EXTENSIONS_HANDLER_H_ | ||
2 | #define _EXTENSIONS_HANDLER_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qxml.h> | ||
8 | #include "KeyModifiers.h" | ||
9 | #include "KeyExtensions.h" | ||
10 | #include "KeyNames.h" | ||
11 | #include "KHUtil.h" | ||
12 | |||
13 | class ExtensionsHandler : public QXmlDefaultHandler | ||
14 | { | ||
15 | public: | ||
16 | void dispose(QXmlReader* parser, QXmlContentHandler* parent); | ||
17 | |||
18 | void setKeyModifiers(KeyModifiers* mod) | ||
19 | { | ||
20 | m_pModifiers = mod; | ||
21 | } | ||
22 | void setKeyExtensions(KeyExtensions* ext) | ||
23 | { | ||
24 | m_pExtensions = ext; | ||
25 | } | ||
26 | |||
27 | bool startElement(const QString& namespaceURI, | ||
28 | const QString& localName, | ||
29 | const QString& qName, | ||
30 | const QXmlAttributes& atts); | ||
31 | bool endElement(const QString& namespaceURI, | ||
32 | const QString& localName, | ||
33 | const QString& qName); | ||
34 | private: | ||
35 | QXmlContentHandler* m_parent; | ||
36 | QXmlReader* m_parser; | ||
37 | |||
38 | KeyModifiers* m_pModifiers; | ||
39 | KeyExtensions* m_pExtensions; | ||
40 | |||
41 | QString m_kind; | ||
42 | int m_code; | ||
43 | QStringList m_modlist; | ||
44 | //int m_mask; | ||
45 | |||
46 | }; | ||
47 | |||
48 | #endif /* _EXTENSIONS_HANDLER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgErrorHandler.cpp b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgErrorHandler.cpp new file mode 100644 index 0000000..e1faf18 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgErrorHandler.cpp | |||
@@ -0,0 +1,38 @@ | |||
1 | #include "KeycfgErrorHandler.h" | ||
2 | |||
3 | void KeycfgErrorHandler::setErrorString(const QString& header, | ||
4 | const QXmlParseException& exception) | ||
5 | { | ||
6 | m_errstr = header; | ||
7 | m_errstr.append(": "); | ||
8 | m_errstr.append(exception.message()); | ||
9 | m_errstr.append(" ["); | ||
10 | m_errstr.append(QString::number(exception.lineNumber())); | ||
11 | m_errstr.append(", "); | ||
12 | m_errstr.append(QString::number(exception.columnNumber())); | ||
13 | m_errstr.append("]"); | ||
14 | qWarning(m_errstr.latin1()); | ||
15 | } | ||
16 | |||
17 | bool KeycfgErrorHandler::warning(const QXmlParseException& exception) | ||
18 | { | ||
19 | setErrorString("warning", exception); | ||
20 | return(true); | ||
21 | } | ||
22 | |||
23 | bool KeycfgErrorHandler::error(const QXmlParseException& exception) | ||
24 | { | ||
25 | setErrorString("error", exception); | ||
26 | return(false); | ||
27 | } | ||
28 | |||
29 | bool KeycfgErrorHandler::fatalError(const QXmlParseException& exception) | ||
30 | { | ||
31 | setErrorString("fatal", exception); | ||
32 | return(false); | ||
33 | } | ||
34 | |||
35 | QString KeycfgErrorHandler::errorString() | ||
36 | { | ||
37 | return(m_errstr); | ||
38 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgErrorHandler.h b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgErrorHandler.h new file mode 100644 index 0000000..61e7e70 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgErrorHandler.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef _KEYCFG_ERROR_HANDLER_H_ | ||
2 | #define _KEYCFG_ERROR_HANDLER_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qxml.h> | ||
6 | |||
7 | class KeycfgErrorHandler : public QXmlErrorHandler | ||
8 | { | ||
9 | public: | ||
10 | KeycfgErrorHandler(){} | ||
11 | virtual ~KeycfgErrorHandler(){} | ||
12 | |||
13 | bool warning(const QXmlParseException& exception); | ||
14 | bool error(const QXmlParseException& exception); | ||
15 | bool fatalError(const QXmlParseException& exception); | ||
16 | QString errorString(); | ||
17 | private: | ||
18 | void setErrorString(const QString& header, | ||
19 | const QXmlParseException& exception); | ||
20 | QString m_errstr; | ||
21 | }; | ||
22 | |||
23 | #endif /* _KEYCFG_ERROR_HANDLER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgHandler.cpp b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgHandler.cpp new file mode 100644 index 0000000..a342e36 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgHandler.cpp | |||
@@ -0,0 +1,43 @@ | |||
1 | #include "KeycfgHandler.h" | ||
2 | |||
3 | KeycfgHandler::KeycfgHandler(QXmlReader* parser) | ||
4 | : QXmlDefaultHandler() | ||
5 | { | ||
6 | m_parser = parser; | ||
7 | m_pModHandler = new ModifiersHandler(); | ||
8 | m_pMapHandler = new MappingsHandler(); | ||
9 | m_pExtHandler = new ExtensionsHandler(); | ||
10 | m_pRepHandler = new RepeaterHandler(); | ||
11 | } | ||
12 | |||
13 | KeycfgHandler::~KeycfgHandler() | ||
14 | { | ||
15 | delete m_pModHandler; | ||
16 | delete m_pMapHandler; | ||
17 | delete m_pExtHandler; | ||
18 | delete m_pRepHandler; | ||
19 | } | ||
20 | |||
21 | bool KeycfgHandler::startElement(const QString& /* namespaceURI */, | ||
22 | const QString& localName, | ||
23 | const QString& /* qName */, | ||
24 | const QXmlAttributes& /* attr */) | ||
25 | { | ||
26 | if(localName == "modifiers"){ | ||
27 | m_pModHandler->setKeyModifiers(m_pModifiers); | ||
28 | m_pModHandler->setKeyMappings(m_pMappings); | ||
29 | m_pModHandler->dispose(m_parser, this); | ||
30 | } else if(localName == "mappings"){ | ||
31 | m_pMapHandler->setKeyModifiers(m_pModifiers); | ||
32 | m_pMapHandler->setKeyMappings(m_pMappings); | ||
33 | m_pMapHandler->dispose(m_parser, this); | ||
34 | } else if(localName == "extensions"){ | ||
35 | m_pExtHandler->setKeyModifiers(m_pModifiers); | ||
36 | m_pExtHandler->setKeyExtensions(m_pExtensions); | ||
37 | m_pExtHandler->dispose(m_parser, this); | ||
38 | } else if(localName == "repeater"){ | ||
39 | m_pRepHandler->setKeyRepeater(m_pRepeater); | ||
40 | m_pRepHandler->dispose(m_parser, this); | ||
41 | } | ||
42 | return(true); | ||
43 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgHandler.h b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgHandler.h new file mode 100644 index 0000000..9ddded3 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgHandler.h | |||
@@ -0,0 +1,56 @@ | |||
1 | #ifndef _KEYCFG_HANDLER_H_ | ||
2 | #define _KEYCFG_HANDLER_H_ | ||
3 | |||
4 | #include <qxml.h> | ||
5 | #include <qstring.h> | ||
6 | #include "ModifiersHandler.h" | ||
7 | #include "MappingsHandler.h" | ||
8 | #include "ExtensionsHandler.h" | ||
9 | #include "RepeaterHandler.h" | ||
10 | |||
11 | class KeycfgHandler : public QXmlDefaultHandler | ||
12 | { | ||
13 | public: | ||
14 | KeycfgHandler(QXmlReader* parser); | ||
15 | ~KeycfgHandler(); | ||
16 | |||
17 | void dispose(QXmlReader* parser, QXmlContentHandler* parent); | ||
18 | |||
19 | void setKeyModifiers(KeyModifiers* mod) | ||
20 | { | ||
21 | m_pModifiers = mod; | ||
22 | } | ||
23 | void setKeyMappings(KeyMappings* map) | ||
24 | { | ||
25 | m_pMappings = map; | ||
26 | } | ||
27 | void setKeyExtensions(KeyExtensions* ext) | ||
28 | { | ||
29 | m_pExtensions = ext; | ||
30 | } | ||
31 | void setKeyRepeater(KeyRepeater* rep) | ||
32 | { | ||
33 | m_pRepeater = rep; | ||
34 | } | ||
35 | |||
36 | |||
37 | bool startElement(const QString& namespaceURI, | ||
38 | const QString& localName, | ||
39 | const QString& qName, | ||
40 | const QXmlAttributes& atts); | ||
41 | private: | ||
42 | QXmlContentHandler* m_parent; | ||
43 | QXmlReader* m_parser; | ||
44 | |||
45 | ModifiersHandler* m_pModHandler; | ||
46 | MappingsHandler* m_pMapHandler; | ||
47 | ExtensionsHandler* m_pExtHandler; | ||
48 | RepeaterHandler* m_pRepHandler; | ||
49 | |||
50 | KeyModifiers* m_pModifiers; | ||
51 | KeyMappings* m_pMappings; | ||
52 | KeyExtensions* m_pExtensions; | ||
53 | KeyRepeater* m_pRepeater; | ||
54 | }; | ||
55 | |||
56 | #endif /* _KEYCFG_HANDLER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp new file mode 100644 index 0000000..44b4b2f --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp | |||
@@ -0,0 +1,70 @@ | |||
1 | #include "KeycfgReader.h" | ||
2 | |||
3 | KeycfgReader::KeycfgReader() | ||
4 | { | ||
5 | qDebug("KeycfgReader::KeycfgReader()"); | ||
6 | } | ||
7 | |||
8 | KeycfgReader::~KeycfgReader() | ||
9 | { | ||
10 | qDebug("KeycfgReader::~KeycfgReader()"); | ||
11 | } | ||
12 | |||
13 | bool KeycfgReader::load() | ||
14 | { | ||
15 | QString file; | ||
16 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
17 | |||
18 | cfg.setGroup("Global"); | ||
19 | |||
20 | file = cfg.readEntry("XmlFile"); | ||
21 | if(file.length() == 0 || !QFile::exists(file)){ | ||
22 | /* default */ | ||
23 | file = QDir::homeDirPath() + "/Settings/keyhelper.xml"; | ||
24 | } | ||
25 | return(load(file)); | ||
26 | } | ||
27 | |||
28 | bool KeycfgReader::load(const QString& path) | ||
29 | { | ||
30 | bool success = false; | ||
31 | |||
32 | KeyNames::reset(); | ||
33 | |||
34 | QXmlSimpleReader parser; | ||
35 | KeycfgHandler handler(&parser); | ||
36 | KeycfgErrorHandler errhandler; | ||
37 | QFile file(path); | ||
38 | |||
39 | qWarning("KeycfgReader::load()[%s]", path.latin1()); | ||
40 | |||
41 | if(file.exists()){ | ||
42 | QXmlInputSource source(file); | ||
43 | |||
44 | handler.setKeyModifiers(m_pModifiers); | ||
45 | handler.setKeyMappings(m_pMappings); | ||
46 | handler.setKeyExtensions(m_pExtensions); | ||
47 | handler.setKeyRepeater(m_pRepeater); | ||
48 | |||
49 | parser.setContentHandler(&handler); | ||
50 | parser.setErrorHandler(&errhandler); | ||
51 | success = parser.parse(source); | ||
52 | |||
53 | file.close(); | ||
54 | } | ||
55 | |||
56 | if(success){ | ||
57 | m_pModifiers->statistics(); | ||
58 | m_pMappings->statistics(); | ||
59 | m_pExtensions->statistics(); | ||
60 | m_pRepeater->statistics(); | ||
61 | } else { | ||
62 | m_pModifiers->reset(); | ||
63 | m_pMappings->reset(); | ||
64 | m_pExtensions->reset(); | ||
65 | m_pRepeater->reset(); | ||
66 | } | ||
67 | KeyNames::clearCode(); | ||
68 | |||
69 | return(success); | ||
70 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.h b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.h new file mode 100644 index 0000000..8624a01 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.h | |||
@@ -0,0 +1,46 @@ | |||
1 | #ifndef _KEYCFG_READER_H_ | ||
2 | #define _KEYCFG_READER_H_ | ||
3 | |||
4 | #include <stdlib.h> | ||
5 | #include <qxml.h> | ||
6 | #include <qstring.h> | ||
7 | #include <qdir.h> | ||
8 | #include "KeycfgHandler.h" | ||
9 | #include "KeycfgErrorHandler.h" | ||
10 | #include "KeyNames.h" | ||
11 | #include "ConfigEx.h" | ||
12 | |||
13 | class KeycfgReader | ||
14 | { | ||
15 | public: | ||
16 | KeycfgReader(); | ||
17 | ~KeycfgReader(); | ||
18 | |||
19 | bool load(); | ||
20 | bool load(const QString& path); | ||
21 | |||
22 | inline void setKeyModifiers(KeyModifiers* mod) | ||
23 | { | ||
24 | m_pModifiers = mod; | ||
25 | } | ||
26 | inline void setKeyMappings(KeyMappings* map) | ||
27 | { | ||
28 | m_pMappings = map; | ||
29 | } | ||
30 | inline void setKeyExtensions(KeyExtensions* ext) | ||
31 | { | ||
32 | m_pExtensions = ext; | ||
33 | } | ||
34 | inline void setKeyRepeater(KeyRepeater* rep) | ||
35 | { | ||
36 | m_pRepeater = rep; | ||
37 | } | ||
38 | |||
39 | private: | ||
40 | KeyModifiers* m_pModifiers; | ||
41 | KeyMappings* m_pMappings; | ||
42 | KeyExtensions* m_pExtensions; | ||
43 | KeyRepeater* m_pRepeater; | ||
44 | }; | ||
45 | |||
46 | #endif /* _KEYCFG_READER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/MappingsHandler.cpp b/noncore/applets/keyhelper/keyhelperapplet/config/MappingsHandler.cpp new file mode 100644 index 0000000..3680fbf --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/MappingsHandler.cpp | |||
@@ -0,0 +1,102 @@ | |||
1 | #include "MappingsHandler.h" | ||
2 | |||
3 | void MappingsHandler::dispose(QXmlReader* parser, QXmlContentHandler* parent) | ||
4 | { | ||
5 | m_parser = parser; | ||
6 | m_parent = parent; | ||
7 | m_parser->setContentHandler(this); | ||
8 | } | ||
9 | |||
10 | bool MappingsHandler::startElement(const QString& /* namespaceURI */, | ||
11 | const QString& localName, | ||
12 | const QString& /* qName */, | ||
13 | const QXmlAttributes& attr) | ||
14 | { | ||
15 | if(localName == "define"){ | ||
16 | /* ÊÑ¿ô½é´ü²½ */ | ||
17 | m_code = 0; | ||
18 | m_mask = 0; | ||
19 | m_mapcode = 0; | ||
20 | m_unicode = 0; | ||
21 | m_mapmodifiers.clear(); | ||
22 | m_mapunicodes.clear(); | ||
23 | for(int i=0; i<attr.length(); i++){ | ||
24 | if(attr.localName(i).lower() == "key"){ | ||
25 | /* keyname */ | ||
26 | m_code = KeyNames::getCode(attr.value(i)); | ||
27 | } else if(attr.localName(i).lower() == "code"){ | ||
28 | /* keycode */ | ||
29 | m_code = KHUtil::hex2int(attr.value(i).lower()); | ||
30 | } | ||
31 | } | ||
32 | } else if(localName == "modifier"){ | ||
33 | /* modifier keys */ | ||
34 | for(int i=0; i<attr.length(); i++){ | ||
35 | if(attr.value(i).lower() == "on"){ | ||
36 | m_mask |= m_pModifiers->getMask(attr.localName(i)); | ||
37 | } | ||
38 | } | ||
39 | } else if(localName == "map"){ | ||
40 | /* mapping key */ | ||
41 | for(int i=0; i<attr.length(); i++){ | ||
42 | if(attr.localName(i).lower() == "key"){ | ||
43 | /* keyname */ | ||
44 | m_mapcode = KeyNames::getCode(attr.value(i)); | ||
45 | } else if(attr.localName(i).lower() == "code"){ | ||
46 | /* keycode */ | ||
47 | m_mapcode = KHUtil::hex2int(attr.value(i).lower()); | ||
48 | } | ||
49 | } | ||
50 | } else if(localName == "map_modifier"){ | ||
51 | /* mapping modifiers */ | ||
52 | for(int i=0; i<attr.length(); i++){ | ||
53 | m_mapmodifiers[attr.localName(i)] = attr.value(i); | ||
54 | } | ||
55 | } else if(localName == "map_unicode"){ | ||
56 | /* mapping unicodes */ | ||
57 | for(int i=0; i<attr.length(); i++){ | ||
58 | if(attr.localName(i).lower() == "char"){ | ||
59 | /* unicode char */ | ||
60 | m_unicode = attr.value(i)[0].unicode(); | ||
61 | } else if(attr.localName(i).lower() == "code"){ | ||
62 | /* unicode code */ | ||
63 | m_unicode = KHUtil::hex2int(attr.value(i).lower()); | ||
64 | } else { | ||
65 | m_mapunicodes[attr.localName(i)] = attr.value(i); | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | return(true); | ||
70 | } | ||
71 | |||
72 | bool MappingsHandler::endElement(const QString& /* namespaceURI */, | ||
73 | const QString& localName, | ||
74 | const QString& /* qName */) | ||
75 | { | ||
76 | if(localName == "define"){ | ||
77 | if(m_code > 0){ | ||
78 | /* assign mapping */ | ||
79 | m_pMappings->assign(m_code, m_mask, m_mapcode); | ||
80 | |||
81 | for(QMap<QString,QString>::Iterator it=m_mapmodifiers.begin(); | ||
82 | it!=m_mapmodifiers.end(); ++it){ | ||
83 | /* assign mapping modifier state */ | ||
84 | m_pMappings->assignModifier(it.key(), it.data()); | ||
85 | } | ||
86 | |||
87 | if(m_unicode > 0){ | ||
88 | m_pMappings->assignUnicode(m_unicode); | ||
89 | } else { | ||
90 | for(QMap<QString,QString>::Iterator it=m_mapunicodes.begin(); | ||
91 | it!=m_mapunicodes.end(); ++it){ | ||
92 | /* assign mapping unicode */ | ||
93 | m_pMappings->assignUnicode(it.key(), it.data()); | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | } else if(localName == "mappings"){ | ||
98 | /* return parent */ | ||
99 | m_parser->setContentHandler(m_parent); | ||
100 | } | ||
101 | return(true); | ||
102 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/MappingsHandler.h b/noncore/applets/keyhelper/keyhelperapplet/config/MappingsHandler.h new file mode 100644 index 0000000..d899ea2 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/MappingsHandler.h | |||
@@ -0,0 +1,48 @@ | |||
1 | #ifndef _MAPPINGS_HANDLER_H_ | ||
2 | #define _MAPPINGS_HANDLER_H_ | ||
3 | |||
4 | #include <qxml.h> | ||
5 | #include <qstring.h> | ||
6 | #include <qmap.h> | ||
7 | #include "KeyModifiers.h" | ||
8 | #include "KeyMappings.h" | ||
9 | #include "KeyNames.h" | ||
10 | #include "KHUtil.h" | ||
11 | |||
12 | class MappingsHandler : public QXmlDefaultHandler | ||
13 | { | ||
14 | public: | ||
15 | void dispose(QXmlReader* parser, QXmlContentHandler* parent); | ||
16 | |||
17 | void setKeyModifiers(KeyModifiers* mod) | ||
18 | { | ||
19 | m_pModifiers = mod; | ||
20 | } | ||
21 | void setKeyMappings(KeyMappings* map) | ||
22 | { | ||
23 | m_pMappings = map; | ||
24 | } | ||
25 | |||
26 | bool startElement(const QString& namespaceURI, | ||
27 | const QString& localName, | ||
28 | const QString& qName, | ||
29 | const QXmlAttributes& atts); | ||
30 | bool endElement(const QString& namespaceURI, | ||
31 | const QString& localName, | ||
32 | const QString& qName); | ||
33 | private: | ||
34 | QXmlContentHandler* m_parent; | ||
35 | QXmlReader* m_parser; | ||
36 | |||
37 | KeyModifiers* m_pModifiers; | ||
38 | KeyMappings* m_pMappings; | ||
39 | |||
40 | int m_code; | ||
41 | int m_mask; | ||
42 | int m_mapcode; | ||
43 | int m_unicode; | ||
44 | QMap<QString,QString> m_mapmodifiers; | ||
45 | QMap<QString,QString> m_mapunicodes; | ||
46 | }; | ||
47 | |||
48 | #endif /* _MAPPINGS_HANDLER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/ModifiersHandler.cpp b/noncore/applets/keyhelper/keyhelperapplet/config/ModifiersHandler.cpp new file mode 100644 index 0000000..b2cde92 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/ModifiersHandler.cpp | |||
@@ -0,0 +1,99 @@ | |||
1 | #include "ModifiersHandler.h" | ||
2 | |||
3 | void ModifiersHandler::dispose(QXmlReader* parser, QXmlContentHandler* parent) | ||
4 | { | ||
5 | m_parser = parser; | ||
6 | m_parent = parent; | ||
7 | m_parser->setContentHandler(this); | ||
8 | } | ||
9 | |||
10 | bool ModifiersHandler::startElement(const QString& /* namespaceURI */, | ||
11 | const QString& localName, | ||
12 | const QString& /* qName */, | ||
13 | const QXmlAttributes& attr) | ||
14 | { | ||
15 | if(localName == "define"){ | ||
16 | /* ÊÑ¿ô½é´ü²½ */ | ||
17 | m_type = QString::null; | ||
18 | m_code = 0; | ||
19 | m_mask = 0; | ||
20 | m_release.clear(); | ||
21 | m_toggle = false; | ||
22 | m_mapping = false; | ||
23 | for(int i=0; i<attr.length(); i++){ | ||
24 | if(attr.localName(i).lower() == "key"){ | ||
25 | /* keyname */ | ||
26 | m_code = KeyNames::getCode(attr.value(i)); | ||
27 | } else if(attr.localName(i).lower() == "code"){ | ||
28 | /* keycode */ | ||
29 | m_code = KHUtil::hex2int(attr.value(i).lower()); | ||
30 | } else if(attr.localName(i).lower() == "type"){ | ||
31 | /* modifier type */ | ||
32 | m_type = attr.value(i); | ||
33 | } else if(attr.localName(i).lower() == "mapping"){ | ||
34 | /* auto mapping */ | ||
35 | if(attr.value(i).lower() == "true"){ | ||
36 | m_mapping = true; | ||
37 | } | ||
38 | } else if(attr.localName(i).lower() == "toggle"){ | ||
39 | /* toggle mode */ | ||
40 | if(attr.value(i).lower() == "true"){ | ||
41 | m_toggle = true; | ||
42 | } | ||
43 | } | ||
44 | } | ||
45 | } else if(localName == "modifier"){ | ||
46 | /* modifier keys */ | ||
47 | for(int i=0; i<attr.length(); i++){ | ||
48 | if(attr.value(i).lower() == "on"){ | ||
49 | m_mask |= m_pModifiers->getMask(attr.localName(i)); | ||
50 | } | ||
51 | } | ||
52 | } else if(localName == "release"){ | ||
53 | /* release keys */ | ||
54 | int code = 0; | ||
55 | for(int i=0; i<attr.length(); i++){ | ||
56 | if(attr.localName(i) == "key"){ | ||
57 | /* keyname */ | ||
58 | code = KeyNames::getCode(attr.value(i)); | ||
59 | } else if(attr.localName(i) == "code"){ | ||
60 | /* keycode */ | ||
61 | code = KHUtil::hex2int(attr.value(i).lower()); | ||
62 | } | ||
63 | } | ||
64 | if(code > 0){ | ||
65 | m_release.append(code); | ||
66 | } | ||
67 | } | ||
68 | return(true); | ||
69 | } | ||
70 | |||
71 | bool ModifiersHandler::endElement(const QString& /* namespaceURI */, | ||
72 | const QString& localName, | ||
73 | const QString& /* qName */) | ||
74 | { | ||
75 | if(localName == "define"){ | ||
76 | if(m_type != QString::null && m_code > 0){ | ||
77 | /* assign modifier */ | ||
78 | m_pModifiers->assign(m_type, m_code, m_mask, m_toggle); | ||
79 | for(QValueList<int>::Iterator it=m_release.begin(); | ||
80 | it!=m_release.end(); ++it){ | ||
81 | /* assign modifier release keys */ | ||
82 | m_pModifiers->assignRelease(*it); | ||
83 | } | ||
84 | int code = KeyNames::getCode(m_type); | ||
85 | if(code <= 0){ | ||
86 | qDebug("setCode[%s][%x]", m_type.latin1(), m_code); | ||
87 | KeyNames::setCode(m_type, m_code); | ||
88 | } | ||
89 | if(m_mapping){ | ||
90 | /* auto mapping */ | ||
91 | m_pMappings->assign(m_code, m_mask, code, 0); | ||
92 | } | ||
93 | } | ||
94 | } else if(localName == "modifiers"){ | ||
95 | /* return parent */ | ||
96 | m_parser->setContentHandler(m_parent); | ||
97 | } | ||
98 | return(true); | ||
99 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/ModifiersHandler.h b/noncore/applets/keyhelper/keyhelperapplet/config/ModifiersHandler.h new file mode 100644 index 0000000..e2d8785 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/ModifiersHandler.h | |||
@@ -0,0 +1,48 @@ | |||
1 | #ifndef _MODIFIERS_HANDLER_H_ | ||
2 | #define _MODIFIERS_HANDLER_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qvaluelist.h> | ||
6 | #include <qxml.h> | ||
7 | #include "KeyModifiers.h" | ||
8 | #include "KeyMappings.h" | ||
9 | #include "KeyNames.h" | ||
10 | #include "KHUtil.h" | ||
11 | |||
12 | class ModifiersHandler : public QXmlDefaultHandler | ||
13 | { | ||
14 | public: | ||
15 | void dispose(QXmlReader* parser, QXmlContentHandler* parent); | ||
16 | |||
17 | void setKeyModifiers(KeyModifiers* mod) | ||
18 | { | ||
19 | m_pModifiers = mod; | ||
20 | } | ||
21 | void setKeyMappings(KeyMappings* map) | ||
22 | { | ||
23 | m_pMappings = map; | ||
24 | } | ||
25 | |||
26 | bool startElement(const QString& namespaceURI, | ||
27 | const QString& localName, | ||
28 | const QString& qName, | ||
29 | const QXmlAttributes& atts); | ||
30 | bool endElement(const QString& namespaceURI, | ||
31 | const QString& localName, | ||
32 | const QString& qName); | ||
33 | private: | ||
34 | QXmlContentHandler* m_parent; | ||
35 | QXmlReader* m_parser; | ||
36 | |||
37 | KeyModifiers* m_pModifiers; | ||
38 | KeyMappings* m_pMappings; | ||
39 | |||
40 | QString m_type; | ||
41 | int m_code; | ||
42 | int m_mask; | ||
43 | QValueList<int> m_release; | ||
44 | bool m_mapping; | ||
45 | bool m_toggle; | ||
46 | }; | ||
47 | |||
48 | #endif /* _MODIFIERS_HANDLER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/RepeaterHandler.cpp b/noncore/applets/keyhelper/keyhelperapplet/config/RepeaterHandler.cpp new file mode 100644 index 0000000..aeae761 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/RepeaterHandler.cpp | |||
@@ -0,0 +1,76 @@ | |||
1 | #include "RepeaterHandler.h" | ||
2 | |||
3 | void RepeaterHandler::dispose(QXmlReader* parser, QXmlContentHandler* parent) | ||
4 | { | ||
5 | m_parser = parser; | ||
6 | m_parent = parent; | ||
7 | m_parser->setContentHandler(this); | ||
8 | } | ||
9 | |||
10 | bool RepeaterHandler::startElement(const QString& /* namespaceURI */, | ||
11 | const QString& localName, | ||
12 | const QString& /* qName */, | ||
13 | const QXmlAttributes& attr) | ||
14 | { | ||
15 | if(localName == "repeat"){ | ||
16 | for(int i=0; i<attr.length(); i++){ | ||
17 | if(attr.localName(i).lower() == "delay"){ | ||
18 | bool ok; | ||
19 | int delay = attr.value(i).toInt(&ok); | ||
20 | if(ok){ | ||
21 | m_pRepeater->setDelay(delay); | ||
22 | } | ||
23 | } else if(attr.localName(i).lower() == "period"){ | ||
24 | bool ok; | ||
25 | int period = attr.value(i).toInt(&ok); | ||
26 | if(ok){ | ||
27 | m_pRepeater->setPeriod(period); | ||
28 | } | ||
29 | } else if(attr.localName(i).lower() == "mode"){ | ||
30 | /* default mode */ | ||
31 | bool ok; | ||
32 | int mode = attr.value(i).toInt(&ok); | ||
33 | if(ok){ | ||
34 | m_pRepeater->setMode(mode); | ||
35 | } | ||
36 | } | ||
37 | } | ||
38 | } else if(localName == "define"){ | ||
39 | /* ÊÑ¿ô½é´ü²½ */ | ||
40 | m_code = 0; | ||
41 | m_enable = true; | ||
42 | for(int i=0; i<attr.length(); i++){ | ||
43 | if(attr.localName(i).lower() == "key"){ | ||
44 | /* keyname */ | ||
45 | m_code = KeyNames::getCode(attr.value(i)); | ||
46 | } else if(attr.localName(i).lower() == "code"){ | ||
47 | /* keycode */ | ||
48 | m_code = KHUtil::hex2int(attr.value(i).lower()); | ||
49 | } else if(attr.localName(i).lower() == "enable"){ | ||
50 | /* enable/disable */ | ||
51 | if(attr.value(i).lower() == "false"){ | ||
52 | m_enable = false; | ||
53 | } else { | ||
54 | m_enable = true; | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | return(true); | ||
60 | } | ||
61 | |||
62 | bool RepeaterHandler::endElement(const QString& /* namespaceURI */, | ||
63 | const QString& localName, | ||
64 | const QString& /* qName */) | ||
65 | { | ||
66 | if(localName == "define"){ | ||
67 | if(m_code > 0){ | ||
68 | /* set repeat enable/disable */ | ||
69 | m_pRepeater->setRepeatable(m_code, m_enable); | ||
70 | } | ||
71 | } else if(localName == "repeater"){ | ||
72 | /* return parent */ | ||
73 | m_parser->setContentHandler(m_parent); | ||
74 | } | ||
75 | return(true); | ||
76 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/RepeaterHandler.h b/noncore/applets/keyhelper/keyhelperapplet/config/RepeaterHandler.h new file mode 100644 index 0000000..d25583b --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/config/RepeaterHandler.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef _REPEATER_HANDLER_H_ | ||
2 | #define _REPEATER_HANDLER_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qvaluelist.h> | ||
6 | #include <qxml.h> | ||
7 | #include "KeyRepeater.h" | ||
8 | #include "KeyNames.h" | ||
9 | #include "KHUtil.h" | ||
10 | |||
11 | class RepeaterHandler : public QXmlDefaultHandler | ||
12 | { | ||
13 | public: | ||
14 | void dispose(QXmlReader* parser, QXmlContentHandler* parent); | ||
15 | |||
16 | void setKeyRepeater(KeyRepeater* rep) | ||
17 | { | ||
18 | m_pRepeater = rep; | ||
19 | } | ||
20 | |||
21 | bool startElement(const QString& namespaceURI, | ||
22 | const QString& localName, | ||
23 | const QString& qName, | ||
24 | const QXmlAttributes& atts); | ||
25 | bool endElement(const QString& namespaceURI, | ||
26 | const QString& localName, | ||
27 | const QString& qName); | ||
28 | private: | ||
29 | QXmlContentHandler* m_parent; | ||
30 | QXmlReader* m_parser; | ||
31 | |||
32 | KeyRepeater* m_pRepeater; | ||
33 | |||
34 | int m_code; | ||
35 | bool m_enable; | ||
36 | |||
37 | }; | ||
38 | |||
39 | #endif /* _REPEATER_HANDLER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp b/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp new file mode 100644 index 0000000..00a43d1 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.cpp | |||
@@ -0,0 +1,110 @@ | |||
1 | #include "ExtensionFactory.h" | ||
2 | |||
3 | ExtensionFactory::ExtensionFactory() | ||
4 | { | ||
5 | qDebug("ExtensionFactory::ExtensionFactory()"); | ||
6 | m_pLoadList = NULL; | ||
7 | } | ||
8 | |||
9 | ExtensionFactory::~ExtensionFactory() | ||
10 | { | ||
11 | qDebug("ExtensionFactory::~ExtensionFactory()"); | ||
12 | } | ||
13 | |||
14 | ExtensionInterface* ExtensionFactory::createInstance(const QString& kind) | ||
15 | { | ||
16 | ExtensionInterface* ext; | ||
17 | QString kindstr = kind.lower(); | ||
18 | |||
19 | if(kindstr == "switch"){ | ||
20 | ext = new TaskSwitcher(kindstr); | ||
21 | } else if(kindstr == "select"){ | ||
22 | ext = new TaskSelector(kindstr); | ||
23 | } else if(kindstr.find("launch") == 0){ | ||
24 | ext = new KeyLauncher(kindstr); | ||
25 | } else if(kindstr.find("menu") == 0){ | ||
26 | ext = new MenuLauncher(kindstr); | ||
27 | } else { | ||
28 | return(NULL); | ||
29 | } | ||
30 | m_oExtList.append(ext); | ||
31 | return(ext); | ||
32 | } | ||
33 | |||
34 | ExtensionInterface* ExtensionFactory::createInstance(const QString& kind, | ||
35 | int keycode, int keymask) | ||
36 | { | ||
37 | ExtensionInterface* ext; | ||
38 | QString kindstr = kind.lower(); | ||
39 | |||
40 | ext = loadInstance(kindstr, keycode, keymask); | ||
41 | if(ext != NULL){ | ||
42 | return(ext); | ||
43 | } | ||
44 | |||
45 | if(kindstr == "switch"){ | ||
46 | ext = new TaskSwitcher(kindstr); | ||
47 | } else if(kindstr == "select"){ | ||
48 | ext = new TaskSelector(kindstr); | ||
49 | } else if(kindstr.find("launch") == 0){ | ||
50 | ext = new KeyLauncher(kindstr); | ||
51 | } else if(kindstr.find("menu") == 0){ | ||
52 | ext = new MenuLauncher(kindstr); | ||
53 | } else { | ||
54 | return(NULL); | ||
55 | } | ||
56 | ext->setKeycode(keycode); | ||
57 | ext->setKeymask(keymask); | ||
58 | |||
59 | m_oExtList.append(ext); | ||
60 | return(ext); | ||
61 | } | ||
62 | |||
63 | ExtensionInterface* ExtensionFactory::loadInstance(const QString& kindstr, | ||
64 | int keycode, int keymask) | ||
65 | { | ||
66 | if(m_pLoadList == NULL){ | ||
67 | return(NULL); | ||
68 | } | ||
69 | |||
70 | for(ExtensionList::Iterator it=m_pLoadList->begin(); | ||
71 | it!=m_pLoadList->end(); ++it){ | ||
72 | if((*it)->kind() == kindstr | ||
73 | && (*it)->getKeycode() == keycode | ||
74 | && (*it)->getKeymask() == keymask){ | ||
75 | m_oExtList.append(*it); | ||
76 | return(*it); | ||
77 | } | ||
78 | } | ||
79 | return(NULL); | ||
80 | } | ||
81 | |||
82 | void ExtensionFactory::clear() | ||
83 | { | ||
84 | for(ExtensionList::Iterator it=m_oExtList.begin(); | ||
85 | it!=m_oExtList.end(); ++it){ | ||
86 | delete *it; | ||
87 | } | ||
88 | m_oExtList.clear(); | ||
89 | } | ||
90 | |||
91 | void ExtensionFactory::reset() | ||
92 | { | ||
93 | m_pLoadList = new ExtensionList(m_oExtList); | ||
94 | m_oExtList.clear(); | ||
95 | } | ||
96 | |||
97 | void ExtensionFactory::sweep() | ||
98 | { | ||
99 | if(m_pLoadList == NULL){ | ||
100 | return; | ||
101 | } | ||
102 | for(ExtensionList::Iterator it=m_pLoadList->begin(); | ||
103 | it!=m_pLoadList->end(); ++it){ | ||
104 | if(m_oExtList.contains(*it) == false){ | ||
105 | delete *it; | ||
106 | } | ||
107 | } | ||
108 | delete m_pLoadList; | ||
109 | m_pLoadList = NULL; | ||
110 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.h b/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.h new file mode 100644 index 0000000..7fa6a5f --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionFactory.h | |||
@@ -0,0 +1,35 @@ | |||
1 | #ifndef _EXTENSION_FACTORY_H_ | ||
2 | #define _EXTENSION_FACTORY_H_ | ||
3 | |||
4 | #include "ExtensionInterface.h" | ||
5 | #include "TaskSwitcher.h" | ||
6 | #include "KeyLauncher.h" | ||
7 | #include "TaskSelector.h" | ||
8 | #include "MenuLauncher.h" | ||
9 | |||
10 | class ExtensionFactory | ||
11 | { | ||
12 | public: | ||
13 | ExtensionFactory(); | ||
14 | virtual ~ExtensionFactory(); | ||
15 | |||
16 | ExtensionInterface* createInstance(const QString& kind); | ||
17 | ExtensionInterface* createInstance(const QString& kind, | ||
18 | int keycode, int keymask); | ||
19 | ExtensionList& getList() | ||
20 | { | ||
21 | return(m_oExtList); | ||
22 | } | ||
23 | void clear(); | ||
24 | void reset(); | ||
25 | void sweep(); | ||
26 | private: | ||
27 | ExtensionList m_oExtList; | ||
28 | ExtensionList* m_pLoadList; | ||
29 | |||
30 | ExtensionInterface* loadInstance(const QString& kind, | ||
31 | int keycode, int keymask); | ||
32 | }; | ||
33 | |||
34 | #endif /* _EXTENSION_FACTORY_H_ */ | ||
35 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionInterface.h b/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionInterface.h new file mode 100644 index 0000000..1a81141 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/ExtensionInterface.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #ifndef _EXTENSION_INTERFACE_H_ | ||
2 | #define _EXTENSION_INTERFACE_H_ | ||
3 | |||
4 | #include <qvaluelist.h> | ||
5 | |||
6 | class ExtensionInterface | ||
7 | { | ||
8 | public: | ||
9 | //ExtensionInterface(); | ||
10 | virtual ~ExtensionInterface(){} | ||
11 | virtual bool onKeyPress(int keycode) = 0; | ||
12 | virtual bool onModRelease(int modcode) = 0; | ||
13 | virtual int getKeycode() = 0; | ||
14 | virtual int getKeymask() = 0; | ||
15 | virtual const QValueList<int>& getModcodes() = 0; | ||
16 | virtual void setKeycode(int keycode) = 0; | ||
17 | virtual void setKeymask(int keymask) = 0; | ||
18 | virtual void setModcodes(const QValueList<int>& modcodes) = 0; | ||
19 | virtual const QString& kind() = 0; | ||
20 | private: | ||
21 | }; | ||
22 | |||
23 | typedef QValueList<ExtensionInterface*> ExtensionList; | ||
24 | |||
25 | #endif /* _EXTENSION_INTERFACE_H_ */ | ||
26 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.cpp b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.cpp new file mode 100644 index 0000000..a61ea0a --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.cpp | |||
@@ -0,0 +1,111 @@ | |||
1 | #include "KeyExtensions.h" | ||
2 | |||
3 | KeyExtensions::KeyExtensions() | ||
4 | { | ||
5 | qDebug("KeyExtensions::KeyExtensions()"); | ||
6 | m_cancelcode = 0; | ||
7 | } | ||
8 | |||
9 | KeyExtensions::~KeyExtensions() | ||
10 | { | ||
11 | qDebug("KeyExtensions::~KeyExtensions()"); | ||
12 | clear(); | ||
13 | } | ||
14 | |||
15 | void KeyExtensions::assign(const QString& kind, int keycode, | ||
16 | int keymask, const QValueList<int>& modcodes) | ||
17 | { | ||
18 | ExtensionInterface* ext; | ||
19 | #if 0 | ||
20 | ext = m_oExtFactory.createInstance(kind); | ||
21 | if(ext != NULL){ | ||
22 | ext->setKeycode(keycode); | ||
23 | ext->setKeymask(keymask); | ||
24 | ext->setModcodes(modcodes); | ||
25 | } | ||
26 | #else | ||
27 | ext = m_oExtFactory.createInstance(kind, keycode, keymask); | ||
28 | if(ext != NULL){ | ||
29 | ext->setModcodes(modcodes); | ||
30 | } | ||
31 | #endif | ||
32 | } | ||
33 | |||
34 | void KeyExtensions::assign(const QString& kind, int keycode, | ||
35 | int keymask, int modcode) | ||
36 | { | ||
37 | QValueList<int> modcodes; | ||
38 | modcodes.append(modcode); | ||
39 | assign(kind, keycode, keymask, modcodes); | ||
40 | } | ||
41 | |||
42 | bool KeyExtensions::doKey(int keycode, int keymask, bool isPress) | ||
43 | { | ||
44 | bool fCancel = false; | ||
45 | ExtensionList& list = m_oExtFactory.getList(); | ||
46 | for(ExtensionList::Iterator it=list.begin(); | ||
47 | it!=list.end(); ++it){ | ||
48 | if(isPress){ | ||
49 | int code = (*it)->getKeycode(); | ||
50 | if((*it)->getKeymask() == keymask | ||
51 | && (code == 0 || code == keycode)){ | ||
52 | if((*it)->onKeyPress(keycode)){ | ||
53 | fCancel = true; | ||
54 | } | ||
55 | qWarning("ext:onKeyPress[%s][%x][%d]", | ||
56 | (*it)->kind().latin1(), | ||
57 | (*it)->getKeycode(), | ||
58 | fCancel); | ||
59 | } | ||
60 | } else { | ||
61 | if(keycode == m_cancelcode){ | ||
62 | fCancel = true; | ||
63 | } | ||
64 | const QValueList<int>& rlist = (*it)->getModcodes(); | ||
65 | if(rlist.contains(keycode)){ | ||
66 | if((*it)->onModRelease(keycode)){ | ||
67 | m_pModifiers->resetToggles(); | ||
68 | } | ||
69 | qWarning("ext:onModRelease[%s][%x]", | ||
70 | (*it)->kind().latin1(), | ||
71 | keycode); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | if(isPress && fCancel){ | ||
76 | m_cancelcode = keycode; | ||
77 | } else { | ||
78 | m_cancelcode = 0; | ||
79 | } | ||
80 | return(fCancel); | ||
81 | } | ||
82 | |||
83 | void KeyExtensions::clear() | ||
84 | { | ||
85 | m_oExtFactory.clear(); | ||
86 | } | ||
87 | |||
88 | void KeyExtensions::reset() | ||
89 | { | ||
90 | //clear(); | ||
91 | m_oExtFactory.reset(); | ||
92 | } | ||
93 | |||
94 | void KeyExtensions::init() | ||
95 | { | ||
96 | m_oExtFactory.sweep(); | ||
97 | } | ||
98 | |||
99 | void KeyExtensions::statistics() | ||
100 | { | ||
101 | qWarning("KeyExtensions::statistics()"); | ||
102 | ExtensionList& list = m_oExtFactory.getList(); | ||
103 | for(ExtensionList::Iterator it=list.begin(); | ||
104 | it!=list.end(); ++it){ | ||
105 | qWarning(" [%s][%x][%x]", | ||
106 | (*it)->kind().latin1(), | ||
107 | (*it)->getKeycode(), | ||
108 | (*it)->getKeymask()); | ||
109 | } | ||
110 | } | ||
111 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.h b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.h new file mode 100644 index 0000000..20ffc45 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.h | |||
@@ -0,0 +1,40 @@ | |||
1 | #ifndef _KEY_EXTENSIONS_H_ | ||
2 | #define _KEY_EXTENSIONS_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include "KeyNames.h" | ||
7 | #include "KeyModifiers.h" | ||
8 | #include "ExtensionFactory.h" | ||
9 | |||
10 | class KeyExtensions | ||
11 | { | ||
12 | public: | ||
13 | KeyExtensions(); | ||
14 | ~KeyExtensions(); | ||
15 | |||
16 | void setKeyModifiers(KeyModifiers* mod) | ||
17 | { | ||
18 | m_pModifiers = mod; | ||
19 | } | ||
20 | |||
21 | void assign(const QString& kind, int keycode, | ||
22 | int keymask, const QValueList<int>& modcodes); | ||
23 | void assign(const QString& kind, int keycode, | ||
24 | int keymask, int modcode); | ||
25 | bool doKey(int keycode, int keymask, bool isPress); | ||
26 | |||
27 | void statistics(); | ||
28 | |||
29 | void reset(); | ||
30 | void init(); | ||
31 | private: | ||
32 | KeyModifiers* m_pModifiers; | ||
33 | ExtensionFactory m_oExtFactory; | ||
34 | int m_cancelcode; | ||
35 | |||
36 | void clear(); | ||
37 | }; | ||
38 | |||
39 | #endif /* _KEY_EXTENSIONS_H_ */ | ||
40 | |||
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 | |||
4 | KeyLauncher::KeyLauncher(const QString& kind) : m_kind(kind) | ||
5 | { | ||
6 | qDebug("KeyLauncher::KeyLauncher()"); | ||
7 | } | ||
8 | |||
9 | KeyLauncher::~KeyLauncher() | ||
10 | { | ||
11 | qDebug("KeyLauncher::~KeyLauncher()"); | ||
12 | } | ||
13 | |||
14 | bool 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 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/KeyLauncher.h b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyLauncher.h new file mode 100644 index 0000000..fbad3da --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyLauncher.h | |||
@@ -0,0 +1,63 @@ | |||
1 | #ifndef _KEY_LAUNCHER_H_ | ||
2 | #define _KEY_LAUNCHER_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qvaluelist.h> | ||
7 | |||
8 | #include <qpe/qpeapplication.h> | ||
9 | #include <qpe/config.h> | ||
10 | #include <qpe/applnk.h> | ||
11 | #include <qpe/global.h> | ||
12 | #include <qpe/qcopenvelope_qws.h> | ||
13 | |||
14 | #include "ExtensionInterface.h" | ||
15 | #include "KeyNames.h" | ||
16 | #include "LnkWrapper.h" | ||
17 | #include "ConfigEx.h" | ||
18 | |||
19 | class KeyLauncher : public ExtensionInterface | ||
20 | { | ||
21 | public: | ||
22 | KeyLauncher(const QString& kind = "launch"); | ||
23 | virtual ~KeyLauncher(); | ||
24 | |||
25 | virtual bool onKeyPress(int keycode); | ||
26 | virtual bool onModRelease(int /*modcode*/){return(false);} | ||
27 | virtual int getKeycode() | ||
28 | { | ||
29 | return(m_keycode); | ||
30 | } | ||
31 | virtual int getKeymask() | ||
32 | { | ||
33 | return(m_keymask); | ||
34 | } | ||
35 | virtual const QValueList<int>& getModcodes() | ||
36 | { | ||
37 | return(m_modcodes); | ||
38 | } | ||
39 | virtual void setKeycode(int keycode) | ||
40 | { | ||
41 | m_keycode = keycode; | ||
42 | } | ||
43 | virtual void setKeymask(int keymask) | ||
44 | { | ||
45 | m_keymask = keymask; | ||
46 | } | ||
47 | virtual void setModcodes(const QValueList<int>& modcodes) | ||
48 | { | ||
49 | m_modcodes = modcodes; | ||
50 | } | ||
51 | virtual const QString& kind() | ||
52 | { | ||
53 | return(m_kind); | ||
54 | } | ||
55 | private: | ||
56 | int m_keycode; | ||
57 | int m_keymask; | ||
58 | QString m_kind; | ||
59 | QValueList<int> m_modcodes; | ||
60 | }; | ||
61 | |||
62 | #endif /* _KEY_LAUNCHER_H_ */ | ||
63 | |||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/MenuLauncher.cpp b/noncore/applets/keyhelper/keyhelperapplet/extension/MenuLauncher.cpp new file mode 100644 index 0000000..0595a3e --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/MenuLauncher.cpp | |||
@@ -0,0 +1,324 @@ | |||
1 | #include "MenuLauncher.h" | ||
2 | extern QWidget* g_Widget; | ||
3 | |||
4 | MenuLauncher::MenuLauncher(const QString& kind) : m_kind(kind) | ||
5 | { | ||
6 | qDebug("MenuLauncher::MenuLauncher()"); | ||
7 | m_pMenu = m_pTopMenu = NULL; | ||
8 | |||
9 | m_isShowing = false; | ||
10 | m_id = -1; | ||
11 | |||
12 | m_pTimer = new QTimer(this); | ||
13 | connect(m_pTimer, SIGNAL(timeout()), | ||
14 | this, SLOT(select())); | ||
15 | |||
16 | init(); | ||
17 | } | ||
18 | |||
19 | MenuLauncher::~MenuLauncher() | ||
20 | { | ||
21 | qDebug("MenuLauncher::~MenuLauncher()"); | ||
22 | delete m_pTopMenu; | ||
23 | delete m_pTimer; | ||
24 | } | ||
25 | |||
26 | void MenuLauncher::init() | ||
27 | { | ||
28 | buildMenu(); | ||
29 | } | ||
30 | |||
31 | QPopupMenu* MenuLauncher::initMenu(QWidget* parent, const QString& name) | ||
32 | { | ||
33 | QPopupMenu* pMenu; | ||
34 | pMenu = new QPopupMenuEx(parent, name); | ||
35 | pMenu->installEventFilter(this); | ||
36 | connect(pMenu, SIGNAL(activated(int)), this, SLOT(select(int))); | ||
37 | connect(pMenu, SIGNAL(highlighted(int)), this, SLOT(highlight(int))); | ||
38 | //connect(pMenu, SIGNAL(aboutToHide()), this, SLOT(execute())); | ||
39 | return(pMenu); | ||
40 | } | ||
41 | |||
42 | bool MenuLauncher::onKeyPress(int /*keycode*/) | ||
43 | { | ||
44 | if(m_isShowing){ | ||
45 | qDebug("showing ..."); | ||
46 | } else if(m_pMenu->isVisible()){ | ||
47 | next(); | ||
48 | } else { | ||
49 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
50 | cfg.setGroup("Global"); | ||
51 | int delay = cfg.readNumEntry("DelayPopup", 5); | ||
52 | QTimer::singleShot(delay, this, SLOT(show())); | ||
53 | m_isShowing = true; | ||
54 | } | ||
55 | return true; | ||
56 | } | ||
57 | |||
58 | bool MenuLauncher::onModRelease(int /*modcode*/) | ||
59 | { | ||
60 | if(m_pMenu->isVisible()){ | ||
61 | QTimer::singleShot(0, this, SLOT(select())); | ||
62 | return(true); | ||
63 | } else { | ||
64 | return(false); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | QString MenuLauncher::getMenuText(const QString& key, const QString& name) | ||
69 | { | ||
70 | QRegExp rx("^[0-9]+_"); | ||
71 | QString text; | ||
72 | QString ackey; | ||
73 | int len; | ||
74 | if(rx.match(key, 0, &len) == 0){ | ||
75 | ackey = key.mid(len); | ||
76 | } else { | ||
77 | ackey = key; | ||
78 | } | ||
79 | if(ackey.length() == 1){ | ||
80 | text = name; | ||
81 | text.append("(&"); | ||
82 | text.append(ackey); | ||
83 | text.append(")"); | ||
84 | } else { | ||
85 | text = ackey; | ||
86 | } | ||
87 | return(text); | ||
88 | } | ||
89 | |||
90 | int MenuLauncher::buildMenu(const QString& section, | ||
91 | QPopupMenu* pMenu, int& id) | ||
92 | { | ||
93 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
94 | |||
95 | if(m_oMenuList.contains(pMenu)){ | ||
96 | /* ̵¸Â¥ë¡¼¥×ËÉ»ß */ | ||
97 | return(0); | ||
98 | } | ||
99 | m_oMenuList.append(pMenu); | ||
100 | |||
101 | QString oldgroup = cfg.getGroup(); | ||
102 | |||
103 | QString group = section; | ||
104 | group[0] = group[0].upper(); | ||
105 | |||
106 | cfg.setGroup(group); | ||
107 | |||
108 | QStringList apps = cfg.getKeys(); | ||
109 | int cnt = 0; | ||
110 | if(apps.isEmpty() == false){ | ||
111 | for(QStringList::Iterator it=apps.begin(); | ||
112 | it!=apps.end(); ++it){ | ||
113 | QStringList args = cfg.readListEntry(*it, '\t'); | ||
114 | LnkWrapper lnk(args); | ||
115 | if(lnk.isValid()){ | ||
116 | cnt++; | ||
117 | QString text = getMenuText(*it, lnk.instance().name()); | ||
118 | if(args[0] == "@menu"){ | ||
119 | QPopupMenu* pSubMenu = initMenu(m_pTopMenu, args[1]); | ||
120 | pMenu->insertItem(lnk.instance().pixmap(), text, | ||
121 | pSubMenu, id); | ||
122 | m_oItemList.append(ItemInfo(section)); | ||
123 | id++; | ||
124 | buildMenu(args[1], pSubMenu, id); | ||
125 | } else { | ||
126 | pMenu->insertItem(lnk.instance().pixmap(), text, id); | ||
127 | m_oItemList.append(ItemInfo(section, *it)); | ||
128 | id++; | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | cfg.setGroup(oldgroup); | ||
134 | return(cnt); | ||
135 | } | ||
136 | |||
137 | void MenuLauncher::clearSubMenu() | ||
138 | { | ||
139 | for(QValueList<QPopupMenu*>::Iterator it=m_oMenuList.begin(); | ||
140 | it!=m_oMenuList.end(); ++it){ | ||
141 | if(*it != m_pTopMenu){ | ||
142 | delete *it; | ||
143 | } | ||
144 | } | ||
145 | m_oMenuList.clear(); | ||
146 | m_oItemList.clear(); | ||
147 | } | ||
148 | |||
149 | int MenuLauncher::buildMenu(bool force) | ||
150 | { | ||
151 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
152 | if(!force && m_lastmodify == cfg.lastRead()){ | ||
153 | return(m_pTopMenu->count()); | ||
154 | } | ||
155 | qDebug("buildMenu"); | ||
156 | |||
157 | QString oldgroup = cfg.getGroup(); | ||
158 | |||
159 | cfg.setGroup("Global"); | ||
160 | m_submenuTimeout = cfg.readNumEntry("SubMenuTimeout", 500); | ||
161 | |||
162 | if(m_pTopMenu){ | ||
163 | delete m_pTopMenu; | ||
164 | } | ||
165 | m_pMenu = m_pTopMenu = initMenu(g_Widget, kind()); | ||
166 | m_oLastId.clear(); | ||
167 | m_oMenuList.clear(); | ||
168 | m_oItemList.clear(); | ||
169 | |||
170 | MenuTitle* pTitle = new MenuTitle("MenuLauncher", | ||
171 | m_pTopMenu->font(), kind()); | ||
172 | m_pTopMenu->insertItem(pTitle); | ||
173 | |||
174 | int id = 0; | ||
175 | int cnt = buildMenu(kind(), m_pTopMenu, id); | ||
176 | if(cnt > 0){ | ||
177 | m_lastmodify = cfg.lastRead(); | ||
178 | } | ||
179 | |||
180 | cfg.setGroup(oldgroup); | ||
181 | return(cnt); | ||
182 | } | ||
183 | |||
184 | void MenuLauncher::show() | ||
185 | { | ||
186 | m_enablePopup = false; | ||
187 | int cnt = buildMenu(); | ||
188 | if(cnt > 0){ | ||
189 | m_pMenu = m_pTopMenu; | ||
190 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
191 | cfg.setGroup("Style"); | ||
192 | int x,y; | ||
193 | QString key = "Position_" + kind(); | ||
194 | if(cfg.hasKey(key)){ | ||
195 | const QStringList& list = cfg.readListEntry(key, ','); | ||
196 | x = list[0].toInt(); | ||
197 | y = list[1].toInt(); | ||
198 | } else { | ||
199 | x = (qt_screen->width() - m_pTopMenu->sizeHint().width()) / 2; | ||
200 | y = (qt_screen->height() - m_pTopMenu->sizeHint().height()) / 2; | ||
201 | } | ||
202 | QPoint pos(x, y); | ||
203 | m_pTopMenu->popup(pos); | ||
204 | m_pTopMenu->setActiveItem(1); | ||
205 | } | ||
206 | m_isShowing = false; | ||
207 | } | ||
208 | |||
209 | void MenuLauncher::next() | ||
210 | { | ||
211 | int index = m_pMenu->indexOf(m_id); | ||
212 | index++; | ||
213 | if(index >= (signed int)m_pMenu->count()){ | ||
214 | if(m_pMenu == m_pTopMenu){ | ||
215 | index = 1; | ||
216 | } else { | ||
217 | index = 0; | ||
218 | } | ||
219 | } | ||
220 | m_pMenu->setActiveItem(index); | ||
221 | m_id = m_pMenu->idAt(index); | ||
222 | } | ||
223 | |||
224 | void MenuLauncher::select() | ||
225 | { | ||
226 | if(m_pMenu->isVisible()){ | ||
227 | QMenuItem* item = m_pMenu->findItem(m_id); | ||
228 | int index = m_pMenu->indexOf(m_id); | ||
229 | QPopupMenu* p = m_pMenu; | ||
230 | //m_pMenu->activateItemAt(index); | ||
231 | if(item && item->popup()){ | ||
232 | m_pMenu = item->popup(); | ||
233 | } | ||
234 | p->activateItemAt(index); | ||
235 | } | ||
236 | } | ||
237 | |||
238 | void MenuLauncher::select(int id) | ||
239 | { | ||
240 | if(id >= 0 && m_oItemList[id].entry != QString::null){ | ||
241 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
242 | |||
243 | cfg.setGroup("Global"); | ||
244 | int delay = cfg.readNumEntry("DelayExec", 100); | ||
245 | |||
246 | QString group = m_oItemList[id].group; | ||
247 | group[0] = group[0].upper(); | ||
248 | cfg.setGroup(group); | ||
249 | |||
250 | //QStringList args = cfg.readListEntry(m_oItemList[id].entry, '\t'); | ||
251 | m_args = cfg.readListEntry(m_oItemList[id].entry, '\t'); | ||
252 | |||
253 | #if 0 | ||
254 | LnkWrapper lnk(args); | ||
255 | if(lnk.isValid()){ | ||
256 | lnk.instance().execute(); | ||
257 | } | ||
258 | #else | ||
259 | QTimer::singleShot(delay, this, SLOT(execute())); | ||
260 | #endif | ||
261 | } | ||
262 | m_pMenu = m_pTopMenu; | ||
263 | m_id = -1; | ||
264 | } | ||
265 | |||
266 | void MenuLauncher::execute() | ||
267 | { | ||
268 | LnkWrapper lnk(m_args); | ||
269 | if(lnk.isValid()){ | ||
270 | lnk.instance().execute(); | ||
271 | } | ||
272 | m_args.clear(); | ||
273 | } | ||
274 | |||
275 | void MenuLauncher::highlight(int id) | ||
276 | { | ||
277 | if(m_pMenu && m_pMenu->isVisible()){ | ||
278 | m_id = id; | ||
279 | if(m_enablePopup){ | ||
280 | QMenuItem* item = m_pMenu->findItem(m_id); | ||
281 | if(item && item->popup()){ | ||
282 | if(m_submenuTimeout > 0){ | ||
283 | m_pTimer->start(m_submenuTimeout, true); | ||
284 | } | ||
285 | } else { | ||
286 | m_pTimer->stop(); | ||
287 | } | ||
288 | } else { | ||
289 | /* ¥á¥Ë¥å¡¼É½¼¨Ä¾¸å¤Ï¥Ý¥Ã¥×¥¢¥Ã¥×¤·¤Ê¤¤ */ | ||
290 | m_enablePopup = true; | ||
291 | } | ||
292 | } | ||
293 | } | ||
294 | |||
295 | bool MenuLauncher::eventFilter(QObject* o, QEvent* e) | ||
296 | { | ||
297 | if(m_pTopMenu->isVisible()){ | ||
298 | QKeyEvent* ke = (QKeyEvent*)e; | ||
299 | switch(e->type()){ | ||
300 | case QEvent::Accel: | ||
301 | if(ke->key() == Qt::Key_Space | ||
302 | && ke->isAutoRepeat() == false){ | ||
303 | select(); | ||
304 | } | ||
305 | break; | ||
306 | case QEvent::FocusIn: | ||
307 | //qDebug("FocusIn[%p][%p]", o, m_pMenu); | ||
308 | m_pMenu = (QPopupMenu*)o; | ||
309 | if(m_oLastId.contains(o)){ | ||
310 | m_id = m_oLastId[o]; | ||
311 | } | ||
312 | m_pMenu->updateItem(m_id); | ||
313 | break; | ||
314 | case QEvent::FocusOut: | ||
315 | //qDebug("FocusOut[%p][%p]", o, m_pMenu); | ||
316 | m_oLastId[o] = m_id; | ||
317 | break; | ||
318 | default: | ||
319 | //qDebug(">>>>> [%p][%d] <<<<<", o, e->type()); | ||
320 | break; | ||
321 | } | ||
322 | } | ||
323 | return QObject::eventFilter(o, e); | ||
324 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/MenuLauncher.h b/noncore/applets/keyhelper/keyhelperapplet/extension/MenuLauncher.h new file mode 100644 index 0000000..5eebe78 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/MenuLauncher.h | |||
@@ -0,0 +1,110 @@ | |||
1 | #ifndef _MENU_LAUNCHER_H_ | ||
2 | #define _MENU_LAUNCHER_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qwindowsystem_qws.h> | ||
8 | #define INCLUDE_MENUITEM_DEF | ||
9 | #include <qpopupmenu.h> | ||
10 | #include <qpoint.h> | ||
11 | #include <qtimer.h> | ||
12 | #include <qgfx_qws.h> | ||
13 | |||
14 | #include <qpe/global.h> | ||
15 | #include <qpe/applnk.h> | ||
16 | #include <qpe/config.h> | ||
17 | #include <qpe/qpeapplication.h> | ||
18 | |||
19 | #include "ExtensionInterface.h" | ||
20 | #include "MenuTitle.h" | ||
21 | #include "KeyNames.h" | ||
22 | #include "ConfigEx.h" | ||
23 | #include "LnkWrapper.h" | ||
24 | #include "QPopupMenuEx.h" | ||
25 | |||
26 | struct ItemInfo{ | ||
27 | ItemInfo(QString g=QString::null, QString e=QString::null) | ||
28 | : group(g), entry(e){} | ||
29 | QString group; | ||
30 | QString entry; | ||
31 | }; | ||
32 | |||
33 | class MenuLauncher : public QObject, public ExtensionInterface | ||
34 | { | ||
35 | Q_OBJECT | ||
36 | public: | ||
37 | MenuLauncher(const QString& kind = "menu"); | ||
38 | virtual ~MenuLauncher(); | ||
39 | |||
40 | typedef QValueList<ItemInfo> ItemList; | ||
41 | |||
42 | virtual bool onKeyPress(int keycode); | ||
43 | virtual bool onModRelease(int modcode); | ||
44 | virtual int getKeycode() | ||
45 | { | ||
46 | return(m_keycode); | ||
47 | } | ||
48 | virtual int getKeymask() | ||
49 | { | ||
50 | return(m_keymask); | ||
51 | } | ||
52 | virtual const QValueList<int>& getModcodes() | ||
53 | { | ||
54 | return(m_modcodes); | ||
55 | } | ||
56 | virtual void setKeycode(int keycode) | ||
57 | { | ||
58 | m_keycode = keycode; | ||
59 | } | ||
60 | virtual void setKeymask(int keymask) | ||
61 | { | ||
62 | m_keymask = keymask; | ||
63 | } | ||
64 | virtual void setModcodes(const QValueList<int>& modcodes) | ||
65 | { | ||
66 | m_modcodes = modcodes; | ||
67 | } | ||
68 | virtual const QString& kind() | ||
69 | { | ||
70 | return(m_kind); | ||
71 | } | ||
72 | public slots: | ||
73 | void show(); | ||
74 | void select(); | ||
75 | void select(int id); | ||
76 | void highlight(int id); | ||
77 | private: | ||
78 | int m_keycode; | ||
79 | int m_keymask; | ||
80 | QString m_kind; | ||
81 | QValueList<int> m_modcodes; | ||
82 | |||
83 | int m_submenuTimeout; | ||
84 | bool m_isShowing; | ||
85 | bool m_enablePopup; | ||
86 | int m_id; | ||
87 | QPopupMenu* m_pMenu; | ||
88 | QPopupMenu* m_pTopMenu; | ||
89 | QDateTime m_lastmodify; | ||
90 | |||
91 | QMap<QObject*, int> m_oLastId; | ||
92 | QValueList<QPopupMenu*> m_oMenuList; | ||
93 | ItemList m_oItemList; | ||
94 | QTimer* m_pTimer; | ||
95 | |||
96 | QStringList m_args; | ||
97 | |||
98 | QString getMenuText(const QString& key, const QString& name); | ||
99 | QPopupMenu* initMenu(QWidget* parent, const QString& name); | ||
100 | int buildMenu(bool force=false); | ||
101 | int buildMenu(const QString& section, QPopupMenu* pMenu, int& id); | ||
102 | void clearSubMenu(); | ||
103 | void init(); | ||
104 | void next(); | ||
105 | private slots: | ||
106 | bool eventFilter(QObject* o, QEvent* e); | ||
107 | void execute(); | ||
108 | }; | ||
109 | |||
110 | #endif /* _MENU_LAUNCHER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/MenuTitle.cpp b/noncore/applets/keyhelper/keyhelperapplet/extension/MenuTitle.cpp new file mode 100644 index 0000000..d8fd2a3 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/MenuTitle.cpp | |||
@@ -0,0 +1,67 @@ | |||
1 | #include "MenuTitle.h" | ||
2 | |||
3 | MenuTitle::MenuTitle(const QString& s, const QFont& f, const QString& k) | ||
4 | { | ||
5 | font = f; | ||
6 | kind = k; | ||
7 | |||
8 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
9 | |||
10 | const QString curGroup = cfg.getGroup(); | ||
11 | cfg.setGroup("Style"); | ||
12 | |||
13 | caption = cfg.readEntry("Caption_" + k, s); | ||
14 | cfg.setGroup(curGroup); | ||
15 | } | ||
16 | |||
17 | bool MenuTitle::fullSpan() const | ||
18 | { | ||
19 | return(true); | ||
20 | } | ||
21 | |||
22 | bool MenuTitle::isSeparator() const | ||
23 | { | ||
24 | return(true); | ||
25 | } | ||
26 | |||
27 | void MenuTitle::paint(QPainter* p, const QColorGroup& cg, bool /*act*/, | ||
28 | bool /*enabled*/, int x, int y, int w, int h) | ||
29 | { | ||
30 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
31 | const QString& curGroup = cfg.getGroup(); | ||
32 | |||
33 | cfg.setGroup("Style"); | ||
34 | |||
35 | QString name; | ||
36 | QColor color; | ||
37 | |||
38 | p->setFont(font); | ||
39 | |||
40 | /* set fontcolor */ | ||
41 | name = cfg.readEntry("FontColor_" + kind, QString::null); | ||
42 | if(name != QString::null){ | ||
43 | color.setNamedColor(name); | ||
44 | if(color.isValid()){ | ||
45 | p->setPen(color); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | /* set bgcolor */ | ||
50 | name = cfg.readEntry("BgColor_" + kind, QString::null); | ||
51 | if(name != QString::null){ | ||
52 | color.setNamedColor(name); | ||
53 | if(color.isValid() == false){ | ||
54 | color = cg.mid(); | ||
55 | } | ||
56 | } else { | ||
57 | color = cg.mid(); | ||
58 | } | ||
59 | p->fillRect(x, y, w, h, QBrush(color)); | ||
60 | p->drawText(x, y, w, h, AlignCenter, caption); | ||
61 | cfg.setGroup(curGroup); | ||
62 | } | ||
63 | |||
64 | QSize MenuTitle::sizeHint() | ||
65 | { | ||
66 | return(QFontMetrics(font).size(AlignCenter, caption)); | ||
67 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/MenuTitle.h b/noncore/applets/keyhelper/keyhelperapplet/extension/MenuTitle.h new file mode 100644 index 0000000..77e46a5 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/MenuTitle.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef _MENU_TITLE_ITEM_H_ | ||
2 | #define _MENU_TITLE_ITEM_H_ | ||
3 | |||
4 | #include <qmenudata.h> | ||
5 | #include <qpainter.h> | ||
6 | #include <qbrush.h> | ||
7 | #include <qcolor.h> | ||
8 | #include <qpalette.h> | ||
9 | #include <qpe/config.h> | ||
10 | #include "ConfigEx.h" | ||
11 | |||
12 | class MenuTitle : public QCustomMenuItem | ||
13 | { | ||
14 | public: | ||
15 | MenuTitle(const QString& s, const QFont& f, const QString& k = "default"); | ||
16 | virtual ~MenuTitle(){} | ||
17 | |||
18 | bool fullSpan () const; | ||
19 | bool isSeparator() const; | ||
20 | void paint(QPainter* p, const QColorGroup& cg, bool act, | ||
21 | bool enabled, int x, int y, int w, int h); | ||
22 | QSize sizeHint(); | ||
23 | private: | ||
24 | QString caption; | ||
25 | QString kind; | ||
26 | QFont font; | ||
27 | }; | ||
28 | |||
29 | #endif /* _MENU_TITLE_ITEM_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/QPopupMenuEx.h b/noncore/applets/keyhelper/keyhelperapplet/extension/QPopupMenuEx.h new file mode 100644 index 0000000..16e18a1 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/QPopupMenuEx.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef _QPOPUPMENUEX_H_ | ||
2 | #define _QPOPUPMENUEX_H_ | ||
3 | |||
4 | #include <qpopupmenu.h> | ||
5 | #include <qstring.h> | ||
6 | #include <qevent.h> | ||
7 | |||
8 | class QPopupMenuEx : public QPopupMenu | ||
9 | { | ||
10 | public: | ||
11 | QPopupMenuEx(QWidget* parent=0, const char* name=0) | ||
12 | : QPopupMenu(parent, name){} | ||
13 | protected: | ||
14 | void keyPressEvent(QKeyEvent* e){ | ||
15 | QChar c = e->text()[0]; | ||
16 | QKeyEvent* ke = new QKeyEvent( | ||
17 | e->type(), | ||
18 | e->key(), | ||
19 | c.lower().latin1(), | ||
20 | 0, | ||
21 | c.lower(), | ||
22 | e->isAutoRepeat()); | ||
23 | QPopupMenu::keyPressEvent(ke); | ||
24 | } | ||
25 | private: | ||
26 | }; | ||
27 | |||
28 | #endif /* _QPOPUPMENUEX_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSelector.cpp b/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSelector.cpp new file mode 100644 index 0000000..4fc9cc4 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSelector.cpp | |||
@@ -0,0 +1,225 @@ | |||
1 | #include "TaskSelector.h" | ||
2 | extern QWidget* g_Widget; | ||
3 | |||
4 | static const char* defkeys = | ||
5 | "QWERTYUIOPASDFGHJKLZXCVBNM1234567890"; | ||
6 | |||
7 | #define START_INDEX 1 | ||
8 | |||
9 | TaskSelector::TaskSelector(const QString& kind) : m_kind(kind) | ||
10 | { | ||
11 | qDebug("TaskSelector::TaskSelector()"); | ||
12 | m_pMenu = new QPopupMenuEx(g_Widget); | ||
13 | m_pMenu->installEventFilter(this); | ||
14 | |||
15 | m_isShowing = false; | ||
16 | m_index = START_INDEX-1; | ||
17 | connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(select(int))); | ||
18 | connect(m_pMenu, SIGNAL(highlighted(int)), this, SLOT(highlight(int))); | ||
19 | } | ||
20 | |||
21 | TaskSelector::~TaskSelector() | ||
22 | { | ||
23 | qDebug("TaskSelector::~TaskSelector()"); | ||
24 | delete m_pMenu; | ||
25 | } | ||
26 | |||
27 | bool TaskSelector::onKeyPress(int /*keycode*/) | ||
28 | { | ||
29 | if(m_isShowing){ | ||
30 | qDebug("showing ..."); | ||
31 | } else if(m_pMenu->isVisible()){ | ||
32 | next(); | ||
33 | } else { | ||
34 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
35 | cfg.setGroup("Global"); | ||
36 | int delay = cfg.readNumEntry("DelayPopup", 5); | ||
37 | QTimer::singleShot(delay, this, SLOT(show())); | ||
38 | m_isShowing = true; | ||
39 | } | ||
40 | return true; | ||
41 | } | ||
42 | |||
43 | bool TaskSelector::onModRelease(int /*modcode*/) | ||
44 | { | ||
45 | if(m_pMenu->isVisible()){ | ||
46 | //m_pMenu->hide(); | ||
47 | QTimer::singleShot(0, this, SLOT(select())); | ||
48 | return(true); | ||
49 | } else { | ||
50 | return(false); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | int TaskSelector::buildMenu() | ||
55 | { | ||
56 | const AppLnk* lnk; | ||
57 | |||
58 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
59 | QString oldgroup; | ||
60 | |||
61 | oldgroup = cfg.getGroup(); | ||
62 | cfg.setGroup("Global"); | ||
63 | QString accesskeys = cfg.readEntry("AccessKeys", defkeys); | ||
64 | if(accesskeys.length() <= 0){ | ||
65 | accesskeys = defkeys; | ||
66 | } | ||
67 | cfg.setGroup(oldgroup); | ||
68 | |||
69 | /* get list */ | ||
70 | int cnt = 0; | ||
71 | m_index = START_INDEX+1; | ||
72 | m_applist.clear(); | ||
73 | m_pMenu->clear(); | ||
74 | MenuTitle* pTitle = new MenuTitle("TaskSelector", m_pMenu->font(), kind()); | ||
75 | m_pMenu->insertItem(pTitle); | ||
76 | const QList<QWSWindow>& list = qwsServer->clientWindows(); | ||
77 | QWSWindow* w; | ||
78 | for(QListIterator<QWSWindow> it(list); (w=it.current()); ++it){ | ||
79 | if(w->isVisible() == false | ||
80 | || w->caption() == QString::null){ | ||
81 | continue; | ||
82 | } | ||
83 | QString app = w->client()->identity(); | ||
84 | if(app == NULL || m_applist.contains(app)){ | ||
85 | continue; | ||
86 | } | ||
87 | /* exclude "launcher" */ | ||
88 | if(app == "launcher"){ | ||
89 | if(cnt == 0){ | ||
90 | m_index--; | ||
91 | } | ||
92 | continue; | ||
93 | } | ||
94 | m_applist.append(app); | ||
95 | /* append menu */ | ||
96 | cnt++; | ||
97 | AppLnkSet* lnkSet = AppLnkManager::getInstance(); | ||
98 | lnk = lnkSet->findExec(app); | ||
99 | QString text; | ||
100 | QPixmap icon; | ||
101 | #if 0 | ||
102 | if(lnk != NULL){ | ||
103 | icon = lnk->pixmap(); | ||
104 | text = lnk->name(); | ||
105 | } else { | ||
106 | AppLnkManager::notfound(); | ||
107 | icon = QPixmap(); | ||
108 | text = w->caption(); | ||
109 | } | ||
110 | #else | ||
111 | if(lnk != NULL){ | ||
112 | icon = lnk->pixmap(); | ||
113 | if(w->caption().length() > 0){ | ||
114 | text = w->caption(); | ||
115 | } else { | ||
116 | text = lnk->name(); | ||
117 | } | ||
118 | } else { | ||
119 | AppLnkManager::notfound(); | ||
120 | icon = QPixmap(); | ||
121 | text = w->caption(); | ||
122 | } | ||
123 | #endif | ||
124 | if(cnt <= (int)accesskeys.length()){ | ||
125 | text.append("(&"); | ||
126 | text.append(accesskeys[cnt-1].upper()); | ||
127 | text.append(")"); | ||
128 | } | ||
129 | m_pMenu->insertItem(icon, text, cnt); | ||
130 | } | ||
131 | return(cnt); | ||
132 | } | ||
133 | |||
134 | void TaskSelector::show() | ||
135 | { | ||
136 | /* build task selector menu */ | ||
137 | int cnt = buildMenu(); | ||
138 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
139 | QString oldgroup = cfg.getGroup(); | ||
140 | cfg.setGroup("Global"); | ||
141 | int min = cfg.readNumEntry("SelectMenuMin", 2); | ||
142 | if(min != 1 && min != 3){ | ||
143 | min = 2; | ||
144 | } | ||
145 | cfg.setGroup(oldgroup); | ||
146 | |||
147 | if(cnt == 0){ | ||
148 | qDebug("no applications"); | ||
149 | } else if(cnt < min){ | ||
150 | //m_index = START_INDEX; | ||
151 | if(m_index > cnt){ | ||
152 | m_index = cnt; | ||
153 | } | ||
154 | QTimer::singleShot(0, this, SLOT(select())); | ||
155 | } else { | ||
156 | if(m_index > cnt){ | ||
157 | m_index = cnt; | ||
158 | } | ||
159 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
160 | cfg.setGroup("Style"); | ||
161 | int x,y; | ||
162 | QString key = "Position_" + kind(); | ||
163 | if(cfg.hasKey(key)){ | ||
164 | const QStringList& list = cfg.readListEntry(key, ','); | ||
165 | x = list[0].toInt(); | ||
166 | y = list[1].toInt(); | ||
167 | } else { | ||
168 | x = (qt_screen->width() - m_pMenu->sizeHint().width()) / 2; | ||
169 | y = (qt_screen->height() - m_pMenu->sizeHint().height()) / 2; | ||
170 | } | ||
171 | QPoint pos(x, y); | ||
172 | m_pMenu->popup(pos); | ||
173 | m_pMenu->setActiveItem(m_index); | ||
174 | } | ||
175 | m_isShowing = false; | ||
176 | } | ||
177 | |||
178 | void TaskSelector::next() | ||
179 | { | ||
180 | m_index++; | ||
181 | if(m_index > (signed int)m_applist.count()){ | ||
182 | m_index = START_INDEX; | ||
183 | } | ||
184 | m_pMenu->setActiveItem(m_index); | ||
185 | } | ||
186 | |||
187 | void TaskSelector::select() | ||
188 | { | ||
189 | //select(m_index); | ||
190 | m_pMenu->activateItemAt(m_index); | ||
191 | } | ||
192 | |||
193 | void TaskSelector::select(int index) | ||
194 | { | ||
195 | if(index > 0){ | ||
196 | Global::execute(m_applist[index-1]); | ||
197 | } | ||
198 | m_index = 0; | ||
199 | } | ||
200 | |||
201 | void TaskSelector::highlight(int index) | ||
202 | { | ||
203 | if(m_pMenu->isVisible()){ | ||
204 | m_index = index; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | bool TaskSelector::eventFilter(QObject* o, QEvent* e) | ||
209 | { | ||
210 | if(m_pMenu->isVisible()){ | ||
211 | QKeyEvent* ke = (QKeyEvent*)e; | ||
212 | switch(e->type()){ | ||
213 | case QEvent::Accel: | ||
214 | if(ke->key() == Qt::Key_Space | ||
215 | && ke->isAutoRepeat() == false){ | ||
216 | select(); | ||
217 | } | ||
218 | break; | ||
219 | default: | ||
220 | //qDebug(">>>>> [%p][%d] <<<<<", o, e->type()); | ||
221 | break; | ||
222 | } | ||
223 | } | ||
224 | return QObject::eventFilter(o, e); | ||
225 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSelector.h b/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSelector.h new file mode 100644 index 0000000..ceb157d --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSelector.h | |||
@@ -0,0 +1,85 @@ | |||
1 | #ifndef _TASK_SELECTOR_H_ | ||
2 | #define _TASK_SELECTOR_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qwindowsystem_qws.h> | ||
8 | #include <qpopupmenu.h> | ||
9 | #include <qpoint.h> | ||
10 | #include <qtimer.h> | ||
11 | #include <qgfx_qws.h> | ||
12 | |||
13 | #include <qpe/global.h> | ||
14 | #include <qpe/applnk.h> | ||
15 | #include <qpe/config.h> | ||
16 | #include <qpe/mimetype.h> | ||
17 | |||
18 | #include "ExtensionInterface.h" | ||
19 | #include "MenuTitle.h" | ||
20 | #include "KeyNames.h" | ||
21 | #include "AppLnkManager.h" | ||
22 | #include "ConfigEx.h" | ||
23 | #include "QPopupMenuEx.h" | ||
24 | |||
25 | class TaskSelector : public QObject, public ExtensionInterface | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | public: | ||
29 | TaskSelector(const QString& kind = "select"); | ||
30 | virtual ~TaskSelector(); | ||
31 | |||
32 | virtual bool onKeyPress(int keycode); | ||
33 | virtual bool onModRelease(int modcode); | ||
34 | virtual int getKeycode() | ||
35 | { | ||
36 | return(m_keycode); | ||
37 | } | ||
38 | virtual int getKeymask() | ||
39 | { | ||
40 | return(m_keymask); | ||
41 | } | ||
42 | virtual const QValueList<int>& getModcodes() | ||
43 | { | ||
44 | return(m_modcodes); | ||
45 | } | ||
46 | virtual void setKeycode(int keycode) | ||
47 | { | ||
48 | m_keycode = keycode; | ||
49 | } | ||
50 | virtual void setKeymask(int keymask) | ||
51 | { | ||
52 | m_keymask = keymask; | ||
53 | } | ||
54 | virtual void setModcodes(const QValueList<int>& modcodes) | ||
55 | { | ||
56 | m_modcodes = modcodes; | ||
57 | } | ||
58 | virtual const QString& kind() | ||
59 | { | ||
60 | return(m_kind); | ||
61 | } | ||
62 | public slots: | ||
63 | void show(); | ||
64 | void select(); | ||
65 | void select(int); | ||
66 | void highlight(int id); | ||
67 | private: | ||
68 | int m_keycode; | ||
69 | int m_keymask; | ||
70 | QString m_kind; | ||
71 | QValueList<int> m_modcodes; | ||
72 | |||
73 | bool m_isShowing; | ||
74 | int m_index; | ||
75 | QPopupMenu* m_pMenu; | ||
76 | QStringList m_applist; | ||
77 | QString m_accesskeys; | ||
78 | |||
79 | int buildMenu(); | ||
80 | void next(); | ||
81 | private slots: | ||
82 | bool eventFilter(QObject* o, QEvent* e); | ||
83 | }; | ||
84 | |||
85 | #endif /* _TASK_SELECTOR_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSwitcher.cpp b/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSwitcher.cpp new file mode 100644 index 0000000..c51eba5 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSwitcher.cpp | |||
@@ -0,0 +1,58 @@ | |||
1 | #include "TaskSwitcher.h" | ||
2 | |||
3 | TaskSwitcher::TaskSwitcher(const QString& kind) : m_kind(kind) | ||
4 | { | ||
5 | qDebug("TaskSwitcher::TaskSwitcher()"); | ||
6 | } | ||
7 | |||
8 | TaskSwitcher::~TaskSwitcher() | ||
9 | { | ||
10 | qDebug("TaskSwitcher::~TaskSwitcher()"); | ||
11 | } | ||
12 | |||
13 | bool TaskSwitcher::onKeyPress(int /*keycode*/) | ||
14 | { | ||
15 | if(m_applist.isEmpty()){ | ||
16 | /* get list */ | ||
17 | const QList<QWSWindow>& list = qwsServer->clientWindows(); | ||
18 | QWSWindow* w; | ||
19 | for(QListIterator<QWSWindow> it(list); (w=it.current()); ++it){ | ||
20 | if(w->isVisible()){ | ||
21 | QString app = w->client()->identity(); | ||
22 | qDebug("applist[%s]", app.latin1()); | ||
23 | if(app != NULL && m_applist.contains(app) == false){ | ||
24 | m_applist.append(app); | ||
25 | } | ||
26 | } | ||
27 | } | ||
28 | m_appit = m_applist.begin(); | ||
29 | } | ||
30 | if(m_applist.count() > 1){ | ||
31 | /* switch next */ | ||
32 | next(); | ||
33 | if(*m_appit == "launcher"){ | ||
34 | next(); | ||
35 | } | ||
36 | Global::execute(*m_appit); | ||
37 | } else if(m_applist.count() == 1 | ||
38 | && *m_appit != "launcher"){ | ||
39 | Global::execute(*m_appit); | ||
40 | } else { | ||
41 | qDebug("no applications"); | ||
42 | } | ||
43 | return(true); | ||
44 | } | ||
45 | |||
46 | bool TaskSwitcher::onModRelease(int /*keycode*/) | ||
47 | { | ||
48 | m_applist.clear(); | ||
49 | return(false); | ||
50 | } | ||
51 | |||
52 | void TaskSwitcher::next() | ||
53 | { | ||
54 | ++m_appit; | ||
55 | if(m_appit == m_applist.end()){ | ||
56 | m_appit = m_applist.begin(); | ||
57 | } | ||
58 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSwitcher.h b/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSwitcher.h new file mode 100644 index 0000000..7bbde55 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/TaskSwitcher.h | |||
@@ -0,0 +1,61 @@ | |||
1 | #ifndef _TASK_SWITCHER_H_ | ||
2 | #define _TASK_SWITCHER_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qwindowsystem_qws.h> | ||
8 | |||
9 | #include <qpe/global.h> | ||
10 | |||
11 | #include "ExtensionInterface.h" | ||
12 | |||
13 | class TaskSwitcher : public ExtensionInterface | ||
14 | { | ||
15 | public: | ||
16 | TaskSwitcher(const QString& kind = "switch"); | ||
17 | virtual ~TaskSwitcher(); | ||
18 | |||
19 | virtual bool onKeyPress(int keycode); | ||
20 | virtual bool onModRelease(int modcode); | ||
21 | virtual int getKeycode() | ||
22 | { | ||
23 | return(m_keycode); | ||
24 | } | ||
25 | virtual int getKeymask() | ||
26 | { | ||
27 | return(m_keymask); | ||
28 | } | ||
29 | virtual const QValueList<int>& getModcodes() | ||
30 | { | ||
31 | return(m_modcodes); | ||
32 | } | ||
33 | virtual void setKeycode(int keycode) | ||
34 | { | ||
35 | m_keycode = keycode; | ||
36 | } | ||
37 | virtual void setKeymask(int keymask) | ||
38 | { | ||
39 | m_keymask = keymask; | ||
40 | } | ||
41 | virtual void setModcodes(const QValueList<int>& modcodes) | ||
42 | { | ||
43 | m_modcodes = modcodes; | ||
44 | } | ||
45 | virtual const QString& kind() | ||
46 | { | ||
47 | return(m_kind); | ||
48 | } | ||
49 | private: | ||
50 | int m_keycode; | ||
51 | int m_keymask; | ||
52 | QString m_kind; | ||
53 | QValueList<int> m_modcodes; | ||
54 | |||
55 | QStringList m_applist; | ||
56 | QStringList::Iterator m_appit; | ||
57 | |||
58 | void next(); | ||
59 | }; | ||
60 | |||
61 | #endif /* _TASK_SWITCHER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/keyhelperapplet.pro b/noncore/applets/keyhelper/keyhelperapplet/keyhelperapplet.pro new file mode 100644 index 0000000..dafb077 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/keyhelperapplet.pro | |||
@@ -0,0 +1,80 @@ | |||
1 | TEMPLATE= lib | ||
2 | CONFIG = qt plugin warn_on | ||
3 | HEADERS = anylnk/AnyLnk.h \ | ||
4 | anylnk/AppLnkManager.h \ | ||
5 | anylnk/AppLnkWrapper.h \ | ||
6 | anylnk/DocLnkWrapper.h \ | ||
7 | anylnk/ExecLnk.h \ | ||
8 | anylnk/LnkWrapper.h \ | ||
9 | anylnk/MenuLnk.h \ | ||
10 | anylnk/ProcessInvoker.h \ | ||
11 | anylnk/QCopLnk.h \ | ||
12 | anylnk/TextLnk.h \ | ||
13 | applet/KeyHelper.h \ | ||
14 | applet/KeyHelperApplet.h \ | ||
15 | applet/KeyHelperWidget.h \ | ||
16 | applet/QSafeDataStream.h \ | ||
17 | config/ExtensionsHandler.h \ | ||
18 | config/KeycfgErrorHandler.h \ | ||
19 | config/KeycfgHandler.h \ | ||
20 | config/KeycfgReader.h \ | ||
21 | config/MappingsHandler.h \ | ||
22 | config/ModifiersHandler.h \ | ||
23 | config/RepeaterHandler.h \ | ||
24 | extension/ExtensionFactory.h \ | ||
25 | extension/ExtensionInterface.h \ | ||
26 | extension/KeyExtensions.h \ | ||
27 | extension/KeyLauncher.h \ | ||
28 | extension/MenuLauncher.h \ | ||
29 | extension/MenuTitle.h \ | ||
30 | extension/QPopupMenuEx.h \ | ||
31 | extension/TaskSelector.h \ | ||
32 | extension/TaskSwitcher.h \ | ||
33 | misc/ConfigEx.h \ | ||
34 | misc/KHUtil.h \ | ||
35 | misc/KeyAction.h \ | ||
36 | misc/KeyMappings.h \ | ||
37 | misc/KeyModifiers.h \ | ||
38 | misc/KeyNames.h \ | ||
39 | misc/KeyRepeater.h \ | ||
40 | misc/StringParser.h | ||
41 | SOURCES = anylnk/AnyLnk.cpp \ | ||
42 | anylnk/AppLnkManager.cpp \ | ||
43 | anylnk/AppLnkWrapper.cpp \ | ||
44 | anylnk/LnkWrapper.cpp \ | ||
45 | anylnk/ProcessInvoker.cpp \ | ||
46 | anylnk/QCopLnk.cpp \ | ||
47 | anylnk/TextLnk.cpp \ | ||
48 | applet/KeyHelper.cpp \ | ||
49 | applet/KeyHelperApplet.cpp \ | ||
50 | applet/KeyHelperWidget.cpp \ | ||
51 | applet/QSafeDataStream.cpp \ | ||
52 | config/ExtensionsHandler.cpp \ | ||
53 | config/KeycfgErrorHandler.cpp \ | ||
54 | config/KeycfgHandler.cpp \ | ||
55 | config/KeycfgReader.cpp \ | ||
56 | config/MappingsHandler.cpp \ | ||
57 | config/ModifiersHandler.cpp \ | ||
58 | config/RepeaterHandler.cpp \ | ||
59 | extension/ExtensionFactory.cpp \ | ||
60 | extension/KeyExtensions.cpp \ | ||
61 | extension/KeyLauncher.cpp \ | ||
62 | extension/MenuLauncher.cpp \ | ||
63 | extension/MenuTitle.cpp \ | ||
64 | extension/TaskSelector.cpp \ | ||
65 | extension/TaskSwitcher.cpp \ | ||
66 | misc/ConfigEx.cpp \ | ||
67 | misc/KHUtil.cpp \ | ||
68 | misc/KeyAction.cpp \ | ||
69 | misc/KeyMappings.cpp \ | ||
70 | misc/KeyModifiers.cpp \ | ||
71 | misc/KeyNames.cpp \ | ||
72 | misc/KeyRepeater.cpp \ | ||
73 | misc/StringParser.cpp | ||
74 | DESTDIR = $(OPIEDIR)/plugins/applets/ | ||
75 | INCLUDEPATH += $(OPIEDIR)/include ./misc ./config ./applet ./extension ./anylnk | ||
76 | LIBS += -lqpe -lopiecore2 | ||
77 | TARGET = keyhelperapplet | ||
78 | VERSION = 1.2.2 | ||
79 | |||
80 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/ConfigEx.cpp b/noncore/applets/keyhelper/keyhelperapplet/misc/ConfigEx.cpp new file mode 100644 index 0000000..3693dff --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/ConfigEx.cpp | |||
@@ -0,0 +1,112 @@ | |||
1 | #include "ConfigEx.h" | ||
2 | |||
3 | ConfigEx::ConfigEx(const QString& name, Domain domain) | ||
4 | : Config(name, domain) | ||
5 | { | ||
6 | m_charset = "utf8"; | ||
7 | decode(); | ||
8 | m_lastRead = QDateTime::currentDateTime(); | ||
9 | } | ||
10 | |||
11 | #if 0 | ||
12 | void ConfigEx::removeComment() | ||
13 | { | ||
14 | for(QMap<QString,ConfigGroup>::Iterator it=groups.begin(); | ||
15 | it!=groups.end(); ++it){ | ||
16 | QStringList removeList; | ||
17 | for(ConfigGroup::Iterator it2=(*it).begin(); | ||
18 | it2!=(*it).end(); ++it2){ | ||
19 | if(it2.key()[0] == '#'){ | ||
20 | QString key = it2.key(); | ||
21 | removeList.append(it2.key()); | ||
22 | } | ||
23 | } | ||
24 | for(QStringList::Iterator it3=removeList.begin(); | ||
25 | it3!=removeList.end(); ++it3){ | ||
26 | (*it).remove(*it3); | ||
27 | } | ||
28 | } | ||
29 | } | ||
30 | #endif | ||
31 | |||
32 | void ConfigEx::decode() | ||
33 | { | ||
34 | QString group = getGroup(); | ||
35 | setGroup("Global"); | ||
36 | QString charset = readEntry("CharSet", "utf8"); | ||
37 | qWarning("ConfigEx::decode()[%s][%s]", charset.latin1(), m_charset.latin1()); | ||
38 | setGroup(group); | ||
39 | if(charset != m_charset){ | ||
40 | m_charset = charset; | ||
41 | read(); | ||
42 | } | ||
43 | //removeComment(); | ||
44 | } | ||
45 | |||
46 | void ConfigEx::read() | ||
47 | { | ||
48 | qWarning("ConfigEx::read()"); | ||
49 | groups.clear(); | ||
50 | changed = FALSE; | ||
51 | |||
52 | if ( !QFileInfo( filename ).exists() ) { | ||
53 | git = groups.end(); | ||
54 | return; | ||
55 | } | ||
56 | |||
57 | QFile f( filename ); | ||
58 | if ( !f.open( IO_ReadOnly ) ) { | ||
59 | git = groups.end(); | ||
60 | return; | ||
61 | } | ||
62 | |||
63 | QTextStream s( &f ); | ||
64 | #ifdef CONFIG_MULTICODEC | ||
65 | QTextCodec* codec = QTextCodec::codecForName(m_charset); | ||
66 | if(codec == NULL){ | ||
67 | codec = QTextCodec::codecForName("utf8"); | ||
68 | qWarning("Config CharSet[utf8]"); | ||
69 | } else { | ||
70 | qWarning("Config CharSet[%s]", m_charset.latin1()); | ||
71 | } | ||
72 | s.setCodec(codec); | ||
73 | #else /* CONFIG_MULTICODEC */ | ||
74 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | ||
75 | // The below should work, but doesn't in Qt 2.3.0 | ||
76 | s.setCodec( QTextCodec::codecForMib( 106 ) ); | ||
77 | #else | ||
78 | s.setEncoding( QTextStream::UnicodeUTF8 ); | ||
79 | #endif | ||
80 | #endif /* CONFIG_MULTICODEC */ | ||
81 | |||
82 | QStringList list = QStringList::split('\n', s.read() ); | ||
83 | |||
84 | f.close(); | ||
85 | |||
86 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
87 | if ( !parse( *it ) ) { | ||
88 | git = groups.end(); | ||
89 | return; | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | QStringList ConfigEx::getKeys() | ||
95 | { | ||
96 | QStringList keys; | ||
97 | if(groups.end() != git){ | ||
98 | for(ConfigGroup::ConstIterator it=(*git).begin(); | ||
99 | it!=(*git).end(); ++it){ | ||
100 | if(it.key()[0] != '#'){ | ||
101 | keys.append(it.key()); | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | return(keys); | ||
106 | } | ||
107 | |||
108 | QDateTime ConfigEx::lastModified() | ||
109 | { | ||
110 | QFileInfo info(filename); | ||
111 | return(info.lastModified()); | ||
112 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/ConfigEx.h b/noncore/applets/keyhelper/keyhelperapplet/misc/ConfigEx.h new file mode 100644 index 0000000..32120cc --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/ConfigEx.h | |||
@@ -0,0 +1,89 @@ | |||
1 | #ifndef _CONFIG_EX_H_ | ||
2 | #define _CONFIG_EX_H_ | ||
3 | |||
4 | #include <qstringlist.h> | ||
5 | #include <qdatetime.h> | ||
6 | #include <qfileinfo.h> | ||
7 | #include <qtextstream.h> | ||
8 | #include <qtextcodec.h> | ||
9 | |||
10 | #define QTOPIA_INTERNAL_LANGLIST | ||
11 | #include <qpe/config.h> | ||
12 | #include <qpe/global.h> | ||
13 | |||
14 | #define CONFIG_MULTICODEC | ||
15 | |||
16 | /* Singleton Object */ | ||
17 | class ConfigEx : public Config | ||
18 | { | ||
19 | public: | ||
20 | static ConfigEx& getInstance(const QString& name){ | ||
21 | static ConfigEx cfg(name); | ||
22 | if(/*cfg.flush() ||*/cfg.m_lastRead < cfg.lastModified()){ | ||
23 | cfg.load(&cfg); | ||
24 | } | ||
25 | return(cfg); | ||
26 | } | ||
27 | |||
28 | #if 0 | ||
29 | bool flush(){ | ||
30 | if(changed){ | ||
31 | write(); | ||
32 | return(true); | ||
33 | } else { | ||
34 | return(false); | ||
35 | } | ||
36 | } | ||
37 | #endif | ||
38 | |||
39 | const QString& getGroup(){ | ||
40 | return(git.key()); | ||
41 | } | ||
42 | |||
43 | void load(ConfigEx* cfg){ | ||
44 | cfg->read(); | ||
45 | cfg->decode(); | ||
46 | cfg->m_lastRead = QDateTime::currentDateTime(); | ||
47 | } | ||
48 | |||
49 | void setConfig(const QString& name){ | ||
50 | if(name == QString::null){ | ||
51 | return; | ||
52 | } | ||
53 | /*flush();*/ | ||
54 | filename = configFilename(name, User); | ||
55 | load(this); | ||
56 | } | ||
57 | |||
58 | void reload() { | ||
59 | /*flush();*/ | ||
60 | load(this); | ||
61 | } | ||
62 | |||
63 | QStringList getKeys(); | ||
64 | QDateTime lastModified(); | ||
65 | QDateTime lastRead(){ | ||
66 | return(m_lastRead); | ||
67 | } | ||
68 | |||
69 | friend class Dummy; /* for compie warning */ | ||
70 | private: | ||
71 | ConfigEx(const QString& name, Domain domain=User); | ||
72 | ConfigEx& operator=(const ConfigEx&); | ||
73 | virtual ~ConfigEx(){changed = false;} | ||
74 | |||
75 | class Dummy{}; /* for compile warning */ | ||
76 | |||
77 | |||
78 | void read(); | ||
79 | void decode(); | ||
80 | //void removeComment(); | ||
81 | |||
82 | QDateTime m_lastRead; | ||
83 | #ifdef CONFIG_MULTICODEC | ||
84 | QString m_charset; | ||
85 | #endif | ||
86 | }; | ||
87 | |||
88 | #endif /* _CONFIG_EX_H_ */ | ||
89 | |||
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 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.h b/noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.h new file mode 100644 index 0000000..a92a1b2 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KHUtil.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef _KHUTIL_H_ | ||
2 | #define _KHUTIL_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | |||
7 | class KHUtil | ||
8 | { | ||
9 | public: | ||
10 | static int hex2int(const QString& hexstr, bool* ok=NULL); | ||
11 | static const QStringList parseArgs(const QString& arguments); | ||
12 | static const QString currentApp(); | ||
13 | }; | ||
14 | |||
15 | #endif /* _KHUTIL_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyAction.cpp b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyAction.cpp new file mode 100644 index 0000000..f44138c --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyAction.cpp | |||
@@ -0,0 +1,253 @@ | |||
1 | #include "KeyAction.h" | ||
2 | |||
3 | KeyAction::KeyAction() | ||
4 | { | ||
5 | qDebug("KeyAction::KeyAction()"); | ||
6 | enable(); | ||
7 | } | ||
8 | |||
9 | KeyAction::~KeyAction() | ||
10 | { | ||
11 | qDebug("KeyAction::~KeyAction()"); | ||
12 | } | ||
13 | |||
14 | void KeyAction::init() | ||
15 | { | ||
16 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
17 | |||
18 | QString oldgroup = cfg.getGroup(); | ||
19 | cfg.setGroup("Global"); | ||
20 | |||
21 | m_keepToggle = cfg.readBoolEntry("KeepToggle", true); | ||
22 | |||
23 | m_excludeKeys.clear(); | ||
24 | if(cfg.hasKey("ExcludeKeys")){ | ||
25 | QStringList keys = cfg.readListEntry("ExcludeKeys", ','); | ||
26 | for(QStringList::Iterator it=keys.begin(); | ||
27 | it!=keys.end(); ++it){ | ||
28 | int code; | ||
29 | if((*it).find("0x") == 0){ | ||
30 | code = KHUtil::hex2int(*it); | ||
31 | } else { | ||
32 | code = KeyNames::getCode(*it); | ||
33 | } | ||
34 | if(code > 0){ | ||
35 | m_excludeKeys.append(code); | ||
36 | } | ||
37 | } | ||
38 | } else { | ||
39 | m_excludeKeys.append(Qt::Key_F34); | ||
40 | } | ||
41 | |||
42 | m_presscnt = 0; | ||
43 | m_check = true; | ||
44 | m_keep_toggle_code = 0; | ||
45 | m_capture = false; | ||
46 | cfg.setGroup(oldgroup); | ||
47 | } | ||
48 | |||
49 | void KeyAction::setAction(int unicode, int keycode, int modifiers, | ||
50 | bool isPress, bool autoRepeat) | ||
51 | { | ||
52 | m_unicode = unicode; | ||
53 | m_keycode = keycode; | ||
54 | m_modifiers = modifiers; | ||
55 | m_isPress = isPress; | ||
56 | m_autoRepeat = autoRepeat; | ||
57 | } | ||
58 | |||
59 | bool KeyAction::checkState() | ||
60 | { | ||
61 | if(0 < m_unicode && m_unicode < 0xFFFF){ | ||
62 | QChar ch(m_unicode); | ||
63 | QChar::Category category = ch.category(); | ||
64 | if(category == QChar::Letter_Lowercase){ | ||
65 | if(m_modifiers == 0){ | ||
66 | m_pMappings->setCapsLock(false); | ||
67 | return(true); | ||
68 | } else if(m_modifiers == Qt::ShiftButton){ | ||
69 | m_pMappings->setCapsLock(true); | ||
70 | return(true); | ||
71 | } | ||
72 | } else if(category == QChar::Letter_Uppercase){ | ||
73 | if(m_modifiers == 0){ | ||
74 | m_pMappings->setCapsLock(true); | ||
75 | return(true); | ||
76 | } else if(m_modifiers == Qt::ShiftButton){ | ||
77 | m_pMappings->setCapsLock(false); | ||
78 | return(true); | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | return(false); | ||
83 | } | ||
84 | |||
85 | void KeyAction::sendKeyEvent(int unicode, int keycode, int modifiers, | ||
86 | bool isPress, bool autoRepeat) | ||
87 | { | ||
88 | if(m_hookChannel.isEmpty()){ | ||
89 | QWSServer::sendKeyEvent(unicode, keycode, modifiers, isPress, autoRepeat); | ||
90 | } else { | ||
91 | if(QCopChannel::isRegistered(m_hookChannel)){ | ||
92 | QCopEnvelope e(m_hookChannel, "keyEvent(int,int,int,int,int)"); | ||
93 | e << unicode << keycode << modifiers << (int)isPress << (int)autoRepeat; | ||
94 | } else { | ||
95 | m_hookChannel = ""; | ||
96 | QWSServer::sendKeyEvent(unicode, keycode, modifiers, isPress, autoRepeat); | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | |||
101 | bool KeyAction::doAction() | ||
102 | { | ||
103 | if(m_enable == false){ | ||
104 | return(false); | ||
105 | } | ||
106 | #if 0 | ||
107 | if(m_excludeKeys.contains(m_keycode)){ | ||
108 | return(false); | ||
109 | } | ||
110 | #endif | ||
111 | if(!m_autoRepeat){ | ||
112 | qDebug("recv[%x][%x][%x][%d]", | ||
113 | m_unicode, | ||
114 | m_keycode, | ||
115 | m_modifiers, | ||
116 | m_isPress); | ||
117 | } | ||
118 | |||
119 | if(m_autoRepeat && !m_excludeKeys.contains(m_keycode)){ | ||
120 | KeyRepeater::RepeaterMode repMode = m_pRepeater->getMode(); | ||
121 | if(repMode == KeyRepeater::ENABLE | ||
122 | || repMode == KeyRepeater::KILL){ | ||
123 | /* autoRepeat ¤Ï̵»ë */ | ||
124 | return(true); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | if(m_pRepeater->isRepeatable(m_keycode)){ | ||
129 | if(m_isPress){ | ||
130 | m_presscnt++; | ||
131 | } else { | ||
132 | m_presscnt--; | ||
133 | if(m_presscnt <= 0){ | ||
134 | m_pRepeater->stop(); | ||
135 | m_presscnt = 0; | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | |||
140 | if(m_check && m_isPress){ | ||
141 | /* check capslock state */ | ||
142 | if(checkState()){ | ||
143 | m_check = false; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | int unicode, keycode, modifiers; | ||
148 | /* keep toggle reset */ | ||
149 | if(m_keepToggle && m_keep_toggle_code != 0){ | ||
150 | if(m_keep_toggle_code != m_keycode){ | ||
151 | m_pModifiers->resetToggles(); | ||
152 | m_keep_toggle_code = 0; | ||
153 | } else { | ||
154 | m_pModifiers->keepToggles(); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | /* modifier ¾õÂÖ¼èÆÀ */ | ||
159 | int keymask = m_pModifiers->getState(m_modifiers); | ||
160 | modifiers = m_pModifiers->getModifiers(m_modifiers); | ||
161 | |||
162 | bool isModMapped = false; | ||
163 | /* modifier ¾õÂÖ¹¹¿· */ | ||
164 | if(m_autoRepeat == false){ | ||
165 | if(m_isPress){ | ||
166 | isModMapped = m_pModifiers->pressKey(m_keycode, m_modifiers); | ||
167 | } else { | ||
168 | m_pModifiers->releaseKey(m_keycode); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | if(m_capture && m_isPress && m_autoRepeat == false){ | ||
173 | QCopEnvelope e("QPE/KeyHelperConf", "event(int,int,int)"); | ||
174 | e << m_keycode << m_unicode << modifiers; | ||
175 | } | ||
176 | |||
177 | /* keyextension ŬÍÑ */ | ||
178 | bool fKeyCancel = m_pExtensions->doKey(m_keycode, keymask, m_isPress); | ||
179 | if(fKeyCancel){ | ||
180 | if(m_keepToggle){ | ||
181 | m_keep_toggle_code = m_keycode; | ||
182 | } else { | ||
183 | m_pModifiers->resetToggles(); | ||
184 | } | ||
185 | m_pRepeater->stop(); | ||
186 | return(true); | ||
187 | } | ||
188 | |||
189 | /* keymapping ŬÍÑ */ | ||
190 | #if 0 | ||
191 | bool isMapped = m_pMappings->apply(m_keycode, keymask, m_isPress); | ||
192 | if(isMapped == false){ | ||
193 | if(m_pMappings->isDefined()){ | ||
194 | m_pMappings->setOriginal(m_unicode, m_modifiers); | ||
195 | } else { | ||
196 | m_pMappings->setUnicode(m_unicode); | ||
197 | //m_pMappings->setKeycode(m_keycode); | ||
198 | } | ||
199 | //return(false); | ||
200 | } | ||
201 | #else | ||
202 | bool isMapped = m_pMappings->apply(m_unicode, m_keycode, m_modifiers, | ||
203 | keymask, m_isPress); | ||
204 | #endif | ||
205 | |||
206 | /* modifier ŬÍÑ */ | ||
207 | m_pMappings->setModifiers(modifiers); | ||
208 | |||
209 | keycode = m_pMappings->getKeycode(); | ||
210 | if(keycode <= 0){ | ||
211 | return(true); | ||
212 | } | ||
213 | |||
214 | if(/*m_autoRepeat == false &&*/ m_isPress){ | ||
215 | if(isModMapped == false || (isModMapped && isMapped)){ | ||
216 | if(m_pModifiers->isModifier(keycode) == false){ | ||
217 | m_pModifiers->resetToggles(); | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | unicode = m_pMappings->getUnicode(); | ||
222 | modifiers = m_pMappings->getModifiers(); | ||
223 | if(keycode > 0){ | ||
224 | /* disable mapping */ | ||
225 | if(m_excludeKeys.contains(keycode)){ | ||
226 | return(false); | ||
227 | } | ||
228 | /* send key event */ | ||
229 | sendKeyEvent( | ||
230 | unicode, | ||
231 | keycode, | ||
232 | modifiers, | ||
233 | m_isPress, | ||
234 | m_autoRepeat); | ||
235 | } | ||
236 | if(m_isPress){ | ||
237 | /* repeater start */ | ||
238 | m_pRepeater->start(unicode, keycode, modifiers); | ||
239 | #if 0 | ||
240 | } else if(m_presscnt <= 0){ | ||
241 | m_presscnt = 0; | ||
242 | m_pRepeater->stop(); | ||
243 | #endif | ||
244 | } else { | ||
245 | m_pRepeater->stop(keycode); | ||
246 | } | ||
247 | qWarning("send[%x][%x][%x][%d]", | ||
248 | m_pMappings->getUnicode(), | ||
249 | m_pMappings->getKeycode(), | ||
250 | m_pMappings->getModifiers(), | ||
251 | m_isPress); | ||
252 | return(true); | ||
253 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyAction.h b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyAction.h new file mode 100644 index 0000000..4eb5eb6 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyAction.h | |||
@@ -0,0 +1,87 @@ | |||
1 | #ifndef _KEY_ACTION_H_ | ||
2 | #define _KEY_ACTION_H_ | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <qwindowsystem_qws.h> | ||
6 | #include <qtimer.h> | ||
7 | #include <qpe/power.h> | ||
8 | #include "KeyMappings.h" | ||
9 | #include "KeyModifiers.h" | ||
10 | #include "KeyExtensions.h" | ||
11 | #include "KeyRepeater.h" | ||
12 | #include "ConfigEx.h" | ||
13 | |||
14 | class KeyAction : public QObject | ||
15 | { | ||
16 | Q_OBJECT | ||
17 | public: | ||
18 | KeyAction(); | ||
19 | virtual ~KeyAction(); | ||
20 | |||
21 | void setKeyMappings(KeyMappings* map) | ||
22 | { | ||
23 | m_pMappings = map; | ||
24 | } | ||
25 | void setKeyModifiers(KeyModifiers* mod) | ||
26 | { | ||
27 | m_pModifiers = mod; | ||
28 | } | ||
29 | void setKeyExtensions(KeyExtensions* ext) | ||
30 | { | ||
31 | m_pExtensions = ext; | ||
32 | } | ||
33 | void setKeyRepeater(KeyRepeater* rep) | ||
34 | { | ||
35 | m_pRepeater = rep; | ||
36 | connect(m_pRepeater, SIGNAL(keyEvent(int,int,int,bool,bool)), | ||
37 | this, SLOT(sendKeyEvent(int,int,int,bool,bool))); | ||
38 | } | ||
39 | void setAction(int unicode, int keycode, int modifiers, | ||
40 | bool isPress, bool autoRepeat); | ||
41 | bool doAction(); | ||
42 | |||
43 | void enable(){ | ||
44 | init(); | ||
45 | m_enable = true; | ||
46 | }; | ||
47 | void disable(){ | ||
48 | m_enable = false; | ||
49 | }; | ||
50 | void setCapture(bool enable){ | ||
51 | m_capture = enable; | ||
52 | } | ||
53 | |||
54 | void setHook(const QCString& s){ | ||
55 | m_hookChannel = s; | ||
56 | } | ||
57 | private: | ||
58 | int m_unicode; | ||
59 | int m_keycode; | ||
60 | int m_modifiers; | ||
61 | bool m_isPress; | ||
62 | bool m_autoRepeat; | ||
63 | |||
64 | bool m_capture; | ||
65 | bool m_enable; | ||
66 | int m_presscnt; | ||
67 | |||
68 | int m_keep_toggle_code; | ||
69 | bool m_keepToggle; | ||
70 | bool m_check; | ||
71 | QValueList<int> m_excludeKeys; | ||
72 | |||
73 | QCString m_hookChannel; | ||
74 | |||
75 | KeyMappings* m_pMappings; | ||
76 | KeyModifiers* m_pModifiers; | ||
77 | KeyExtensions* m_pExtensions; | ||
78 | KeyRepeater* m_pRepeater; | ||
79 | |||
80 | void init(); | ||
81 | bool checkState(); | ||
82 | private slots: | ||
83 | void sendKeyEvent(int unicode, int keycode, int modifiers, | ||
84 | bool isPress, bool autoRepeat); | ||
85 | }; | ||
86 | |||
87 | #endif /* _KEY_ACTION_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyMappings.cpp b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyMappings.cpp new file mode 100644 index 0000000..0151d39 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyMappings.cpp | |||
@@ -0,0 +1,340 @@ | |||
1 | #include "KeyMappings.h" | ||
2 | |||
3 | static QIntDict<QWSServer::KeyMap> g_mapCache(127); | ||
4 | |||
5 | MapInfo::MapInfo(int code, int mod, int uni, | ||
6 | int shift_uni, int ctrl_uni) | ||
7 | { | ||
8 | const QWSServer::KeyMap* map; | ||
9 | if(uni == 0 || shift_uni == 0 || ctrl_uni == 0){ | ||
10 | map = MapInfo::findKeyMap(code); | ||
11 | if(map != NULL){ | ||
12 | isDefined = true; | ||
13 | unicode = map->unicode; | ||
14 | shift_unicode = map->shift_unicode; | ||
15 | ctrl_unicode = map->ctrl_unicode; | ||
16 | } else { | ||
17 | isDefined = false; | ||
18 | unicode = 0; | ||
19 | shift_unicode = 0; | ||
20 | ctrl_unicode = 0; | ||
21 | } | ||
22 | } else { | ||
23 | isDefined = true; | ||
24 | } | ||
25 | keycode = code; | ||
26 | modifiers = mod; | ||
27 | if(uni != 0){ | ||
28 | unicode = uni; | ||
29 | } | ||
30 | if(shift_uni != 0){ | ||
31 | shift_unicode = shift_uni; | ||
32 | } | ||
33 | if(ctrl_uni != 0){ | ||
34 | ctrl_unicode = ctrl_uni; | ||
35 | } | ||
36 | } | ||
37 | |||
38 | const QWSServer::KeyMap* MapInfo::findKeyMap(int keycode) | ||
39 | { | ||
40 | const QWSServer::KeyMap* m = QWSServer::keyMap(); | ||
41 | |||
42 | while(m->key_code != 0){ | ||
43 | if(m->key_code == keycode){ | ||
44 | return(m); | ||
45 | } | ||
46 | m++; | ||
47 | } | ||
48 | return(NULL); | ||
49 | } | ||
50 | |||
51 | KeyMappings::KeyMappings() | ||
52 | { | ||
53 | qDebug("KeyMappings::KeyMappings()"); | ||
54 | init(); | ||
55 | } | ||
56 | |||
57 | KeyMappings::~KeyMappings() | ||
58 | { | ||
59 | qDebug("KeyMappings::~KeyMappings()"); | ||
60 | clear(); | ||
61 | } | ||
62 | |||
63 | void KeyMappings::init() | ||
64 | { | ||
65 | m_capslock = false; | ||
66 | } | ||
67 | |||
68 | void KeyMappings::reset() | ||
69 | { | ||
70 | clear(); | ||
71 | } | ||
72 | |||
73 | void KeyMappings::clear() | ||
74 | { | ||
75 | for(QMap<int, CodeMaps*>::Iterator it = m_keymaps.begin(); | ||
76 | it!=m_keymaps.end(); ++it){ | ||
77 | delete (*it); | ||
78 | } | ||
79 | m_keymaps.clear(); | ||
80 | g_mapCache.setAutoDelete(true); | ||
81 | g_mapCache.clear(); | ||
82 | } | ||
83 | |||
84 | void KeyMappings::assign(int keycode, int keymask, int mapcode, | ||
85 | int mapmodifiers, int unicode, int shift_unicode, int ctrl_unicode) | ||
86 | { | ||
87 | CodeMaps* map; | ||
88 | if(m_keymaps.contains(keycode)){ | ||
89 | map = m_keymaps[keycode]; | ||
90 | } else { | ||
91 | map = new CodeMaps(); | ||
92 | m_keymaps.insert(keycode, map); | ||
93 | } | ||
94 | |||
95 | MapInfo info(mapcode, mapmodifiers, unicode, shift_unicode, ctrl_unicode); | ||
96 | m_it = map->insert(keymask, info); | ||
97 | } | ||
98 | |||
99 | void KeyMappings::assignModifier(const QString& type, const QString& state) | ||
100 | { | ||
101 | int maskbit = 0; | ||
102 | QString str; | ||
103 | str = type.lower(); | ||
104 | if(str == "shift"){ | ||
105 | maskbit = Qt::ShiftButton; | ||
106 | } else if(str == "control"){ | ||
107 | maskbit = Qt::ControlButton; | ||
108 | } else if(str == "alt"){ | ||
109 | maskbit = Qt::AltButton; | ||
110 | } | ||
111 | str = state.lower(); | ||
112 | if(str == "off"){ | ||
113 | maskbit = (maskbit << 16) & 0xFFFF0000; | ||
114 | } | ||
115 | (*m_it).modifiers |= maskbit; | ||
116 | } | ||
117 | |||
118 | void KeyMappings::assignUnicode(const QString& kind, const QString& ch) | ||
119 | { | ||
120 | QString str; | ||
121 | int code = ch[0].unicode(); | ||
122 | str = kind.lower(); | ||
123 | if(str == "unicode"){ | ||
124 | (*m_it).unicode = code; | ||
125 | } else if(str == "shift_unicode"){ | ||
126 | (*m_it).shift_unicode = code; | ||
127 | } else if(str == "ctrl_unicode"){ | ||
128 | (*m_it).ctrl_unicode = code; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | void KeyMappings::assignUnicode(int unicode) | ||
133 | { | ||
134 | (*m_it).unicode = (*m_it).shift_unicode = | ||
135 | (*m_it).ctrl_unicode = unicode; | ||
136 | } | ||
137 | |||
138 | void KeyMappings::statistics() | ||
139 | { | ||
140 | qWarning("KeyMappings::statistics()"); | ||
141 | for(QMap<int, CodeMaps*>::Iterator it=m_keymaps.begin(); | ||
142 | it!=m_keymaps.end(); ++it){ | ||
143 | qWarning(" code = %x", it.key()); | ||
144 | for(QMap<int, MapInfo>::Iterator it2=(*it)->begin(); | ||
145 | it2!=(*it)->end(); ++it2){ | ||
146 | qDebug(" [%x]-[%x][%x][%x][%x][%x]", it2.key(), | ||
147 | (*it2).keycode, | ||
148 | (*it2).modifiers, | ||
149 | (*it2).unicode, | ||
150 | (*it2).shift_unicode, | ||
151 | (*it2).ctrl_unicode); | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | |||
156 | bool KeyMappings::apply(int unicode, int keycode, int modifiers, | ||
157 | int keymask, bool isPress) | ||
158 | { | ||
159 | CodeMaps* map; | ||
160 | m_isMapped = false; | ||
161 | |||
162 | if(m_keymaps.contains(keycode)){ | ||
163 | map = m_keymaps[keycode]; | ||
164 | if(map->contains(keymask)){ | ||
165 | m_isMapped = true; | ||
166 | m_keyinfo = (*map)[keymask]; | ||
167 | } else { | ||
168 | int mask = -1; | ||
169 | for(CodeMaps::Iterator it=map->begin(); | ||
170 | it!=map->end(); ++it){ | ||
171 | if((keymask & it.key()) == it.key() | ||
172 | && it.key() > mask){ | ||
173 | mask = it.key(); | ||
174 | } | ||
175 | } | ||
176 | if(mask != -1){ | ||
177 | m_isMapped = true; | ||
178 | m_keyinfo = (*map)[mask]; | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | |||
183 | if(m_isMapped == false){ | ||
184 | QWSServer::KeyMap* cache = g_mapCache[keycode]; | ||
185 | if(cache == NULL){ | ||
186 | cache = new QWSServer::KeyMap(); | ||
187 | g_mapCache.insert(keycode, cache); | ||
188 | cache->unicode = cache->shift_unicode = cache->ctrl_unicode = 0; | ||
189 | } | ||
190 | if(cache->unicode == 0 || cache->shift_unicode == 0 || cache->ctrl_unicode == 0){ | ||
191 | QChar ch(unicode); | ||
192 | if(modifiers & Qt::ControlButton){ | ||
193 | cache->ctrl_unicode = unicode; | ||
194 | } else if(modifiers & Qt::ShiftButton){ | ||
195 | cache->shift_unicode = ch.upper().unicode(); | ||
196 | } else { | ||
197 | cache->unicode = ch.lower().unicode(); | ||
198 | } | ||
199 | } | ||
200 | m_keyinfo = MapInfo(keycode, 0, | ||
201 | cache->unicode, cache->shift_unicode, cache->ctrl_unicode); | ||
202 | if(m_keyinfo.isDefined){ | ||
203 | setOriginal(unicode, modifiers); | ||
204 | } else { | ||
205 | setUnicode(unicode); | ||
206 | } | ||
207 | } | ||
208 | |||
209 | #if 1 | ||
210 | if(isPress){ | ||
211 | if(m_keyinfo.keycode == Qt::Key_CapsLock){ | ||
212 | m_capslock = !m_capslock; | ||
213 | } | ||
214 | } | ||
215 | #endif | ||
216 | return(m_isMapped); | ||
217 | } | ||
218 | |||
219 | bool KeyMappings::apply(int keycode, int keymask, bool isPress) | ||
220 | { | ||
221 | CodeMaps* map; | ||
222 | m_isMapped = false; | ||
223 | |||
224 | if(m_keymaps.contains(keycode)){ | ||
225 | map = m_keymaps[keycode]; | ||
226 | if(map->contains(keymask)){ | ||
227 | m_isMapped = true; | ||
228 | m_keyinfo = (*map)[keymask]; | ||
229 | } else { | ||
230 | int mask = -1; | ||
231 | for(CodeMaps::Iterator it=map->begin(); | ||
232 | it!=map->end(); ++it){ | ||
233 | if((keymask & it.key()) == it.key() | ||
234 | && it.key() > mask){ | ||
235 | mask = it.key(); | ||
236 | } | ||
237 | } | ||
238 | if(mask != -1){ | ||
239 | m_isMapped = true; | ||
240 | m_keyinfo = (*map)[mask]; | ||
241 | } | ||
242 | } | ||
243 | } | ||
244 | if(m_isMapped == false){ | ||
245 | m_keyinfo = MapInfo(keycode); | ||
246 | } | ||
247 | #if 1 | ||
248 | if(isPress){ | ||
249 | if(m_keyinfo.keycode == Qt::Key_CapsLock){ | ||
250 | m_capslock = !m_capslock; | ||
251 | } | ||
252 | } | ||
253 | #endif | ||
254 | return(m_isMapped); | ||
255 | } | ||
256 | |||
257 | /** | ||
258 | * set original unicode | ||
259 | */ | ||
260 | void KeyMappings::setOriginal(int unicode, int modifiers) | ||
261 | { | ||
262 | if(modifiers & Qt::ControlButton){ | ||
263 | m_keyinfo.ctrl_unicode = unicode; | ||
264 | } else if(modifiers & Qt::ShiftButton){ | ||
265 | m_keyinfo.shift_unicode = unicode; | ||
266 | } else { | ||
267 | m_keyinfo.unicode = unicode; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | void KeyMappings::setModifiers(int modifiers) | ||
272 | { | ||
273 | m_modifiers = modifiers; | ||
274 | m_modifiers |= (m_keyinfo.modifiers & 0xFFFF); | ||
275 | m_modifiers &= ~((m_keyinfo.modifiers >> 16) & 0xFFFF); | ||
276 | } | ||
277 | |||
278 | void KeyMappings::setUnicode(int unicode) | ||
279 | { | ||
280 | m_keyinfo.unicode = unicode; | ||
281 | m_keyinfo.shift_unicode = unicode; | ||
282 | m_keyinfo.ctrl_unicode = unicode; | ||
283 | } | ||
284 | |||
285 | void KeyMappings::setKeycode(int keycode) | ||
286 | { | ||
287 | m_keyinfo.keycode = keycode; | ||
288 | } | ||
289 | |||
290 | int KeyMappings::getUnicode() | ||
291 | { | ||
292 | int unicode; | ||
293 | if(m_modifiers & Qt::ControlButton){ | ||
294 | unicode = m_keyinfo.ctrl_unicode; | ||
295 | } else if(m_modifiers & Qt::ShiftButton){ | ||
296 | unicode = m_keyinfo.shift_unicode; | ||
297 | QChar ch(unicode); | ||
298 | if(m_capslock){ | ||
299 | unicode = ch.lower().unicode(); | ||
300 | } else { | ||
301 | unicode = ch.upper().unicode(); | ||
302 | } | ||
303 | } else { | ||
304 | unicode = m_keyinfo.unicode; | ||
305 | QChar ch(unicode); | ||
306 | if(m_capslock){ | ||
307 | unicode = ch.upper().unicode(); | ||
308 | } else { | ||
309 | unicode = ch.lower().unicode(); | ||
310 | } | ||
311 | } | ||
312 | qDebug("UNICODE[%d][%x][%x]", m_capslock, unicode, m_keyinfo.unicode); | ||
313 | #if 0 | ||
314 | if(m_isMapped && m_capslock){ | ||
315 | QChar ch(unicode); | ||
316 | QChar::Category category = ch.category(); | ||
317 | if(category == QChar::Letter_Uppercase){ | ||
318 | unicode = ch.lower().unicode(); | ||
319 | } else if(category == QChar::Letter_Lowercase){ | ||
320 | unicode = ch.upper().unicode(); | ||
321 | } | ||
322 | } | ||
323 | #endif | ||
324 | return(unicode); | ||
325 | } | ||
326 | |||
327 | int KeyMappings::getKeycode() | ||
328 | { | ||
329 | return(m_keyinfo.keycode); | ||
330 | } | ||
331 | |||
332 | int KeyMappings::getModifiers() | ||
333 | { | ||
334 | return(m_modifiers); | ||
335 | } | ||
336 | |||
337 | bool KeyMappings::isDefined() | ||
338 | { | ||
339 | return(m_keyinfo.isDefined); | ||
340 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyMappings.h b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyMappings.h new file mode 100644 index 0000000..9705c8c --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyMappings.h | |||
@@ -0,0 +1,72 @@ | |||
1 | #ifndef _KEY_MAPPINGS_H_ | ||
2 | #define _KEY_MAPPINGS_H_ | ||
3 | |||
4 | #include <qwindowsystem_qws.h> | ||
5 | #include <qmap.h> | ||
6 | |||
7 | #include <qintdict.h> | ||
8 | |||
9 | class MapInfo | ||
10 | { | ||
11 | public: | ||
12 | MapInfo(){}; | ||
13 | MapInfo(int code, int mod = 0, int uni = 0, | ||
14 | int shift_uni = 0, int ctrl_uni = 0); | ||
15 | |||
16 | static const QWSServer::KeyMap* findKeyMap(int code); | ||
17 | |||
18 | int keycode; | ||
19 | int modifiers; | ||
20 | int unicode; | ||
21 | int shift_unicode; | ||
22 | int ctrl_unicode; | ||
23 | bool isDefined; | ||
24 | }; | ||
25 | |||
26 | class KeyMappings | ||
27 | { | ||
28 | public: | ||
29 | typedef QWSServer::KeyMap KeyMap; | ||
30 | typedef QMap<int, MapInfo> CodeMaps; | ||
31 | |||
32 | KeyMappings(); | ||
33 | virtual ~KeyMappings(); | ||
34 | |||
35 | void setOriginal(int unicode, int modifiers); | ||
36 | void setModifiers(int modifiers); | ||
37 | void setUnicode(int unicode); | ||
38 | void setKeycode(int keycode); | ||
39 | |||
40 | int getUnicode(); | ||
41 | int getKeycode(); | ||
42 | int getModifiers(); | ||
43 | bool isDefined(); | ||
44 | |||
45 | void assign(int keycode, int keymask, int mapcode, int mapmodifiers = 0, | ||
46 | int unicode = 0, int shift_unicode = 0, int ctrl_unicode = 0); | ||
47 | void assignModifier(const QString& type, const QString& state); | ||
48 | void assignUnicode(const QString& kind, const QString& ch); | ||
49 | void assignUnicode(int unicode); | ||
50 | bool apply(int unicode, int keycode, int modifiers, int keymask, bool isPress); | ||
51 | bool apply(int keycode, int keymask, bool isPress); | ||
52 | void setCapsLock(bool on=true){ | ||
53 | m_capslock = on; | ||
54 | } | ||
55 | |||
56 | void reset(); | ||
57 | |||
58 | void statistics(); | ||
59 | private: | ||
60 | QMap<int, CodeMaps*> m_keymaps; | ||
61 | MapInfo m_keyinfo; | ||
62 | int m_modifiers; | ||
63 | CodeMaps::Iterator m_it; | ||
64 | |||
65 | bool m_capslock; | ||
66 | bool m_isMapped; | ||
67 | |||
68 | void init(); | ||
69 | void clear(); | ||
70 | }; | ||
71 | |||
72 | #endif /* _KEY_MAPPINGS_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.cpp b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.cpp new file mode 100644 index 0000000..4699b11 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.cpp | |||
@@ -0,0 +1,285 @@ | |||
1 | #include "KeyModifiers.h" | ||
2 | |||
3 | KeyModifiers::KeyModifiers() | ||
4 | { | ||
5 | qDebug("KeyModifiers::KeyModifiers()"); | ||
6 | m_pTimer = new QTimer(this); | ||
7 | connect(m_pTimer, SIGNAL(timeout()), | ||
8 | this, SLOT(resetToggles())); | ||
9 | init(); | ||
10 | } | ||
11 | |||
12 | KeyModifiers::~KeyModifiers() | ||
13 | { | ||
14 | qDebug("KeyModifiers::~KeyModifiers()"); | ||
15 | delete m_pTimer; | ||
16 | clear(); | ||
17 | } | ||
18 | |||
19 | void KeyModifiers::addType(const QString& type) | ||
20 | { | ||
21 | if(m_types.contains(type) == false){ | ||
22 | qDebug("addType[%s][%x]", type.latin1(), m_bitmask); | ||
23 | m_types.insert(type, m_bitmask); | ||
24 | m_bitmask = m_bitmask << 1; | ||
25 | } | ||
26 | } | ||
27 | |||
28 | ModifierInfo* KeyModifiers::assign(const QString& type, int keycode, | ||
29 | int keymask, bool mode) | ||
30 | { | ||
31 | m_info = new ModifierInfo(type, keycode, keymask, mode); | ||
32 | addType(type); | ||
33 | m_modifiers.append(m_info); | ||
34 | if(mode){ | ||
35 | m_togglekeys.append(m_info); | ||
36 | } | ||
37 | assignRelease(m_info, keycode); | ||
38 | return(m_info); | ||
39 | } | ||
40 | |||
41 | void KeyModifiers::assignRelease(int keycode) | ||
42 | { | ||
43 | assignRelease(m_info, keycode); | ||
44 | } | ||
45 | |||
46 | void KeyModifiers::assignRelease(ModifierInfo* info, int keycode) | ||
47 | { | ||
48 | if(m_releasekeys.contains(keycode) == false){ | ||
49 | m_releasekeys.insert(keycode, new ModifierList); | ||
50 | } | ||
51 | m_releasekeys[keycode]->append(info); | ||
52 | } | ||
53 | |||
54 | void KeyModifiers::setToggle() | ||
55 | { | ||
56 | setToggle(m_info); | ||
57 | } | ||
58 | |||
59 | void KeyModifiers::setToggle(ModifierInfo* info) | ||
60 | { | ||
61 | info->toggle_mode = true; | ||
62 | m_togglekeys.append(info); | ||
63 | } | ||
64 | |||
65 | void KeyModifiers::keepToggles() | ||
66 | { | ||
67 | if(m_timeout > 0){ | ||
68 | m_pTimer->start(m_timeout, true); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | bool KeyModifiers::pressKey(int keycode, int modifiers) | ||
73 | { | ||
74 | int keymask; | ||
75 | |||
76 | keymask = getState(modifiers, true); | ||
77 | |||
78 | for(ModifierList::Iterator it=m_modifiers.begin(); | ||
79 | it!=m_modifiers.end(); ++it){ | ||
80 | if((*it)->keycode == keycode | ||
81 | && ((*it)->keymask & keymask) == (*it)->keymask){ | ||
82 | (*it)->pressed = true; | ||
83 | if((*it)->toggle_mode){ | ||
84 | /* change toggle state */ | ||
85 | (*it)->toggled = !((*it)->toggled); | ||
86 | if((*it)->toggled){ | ||
87 | keepToggles(); | ||
88 | } else { | ||
89 | m_pTimer->stop(); | ||
90 | } | ||
91 | } | ||
92 | return(true); | ||
93 | } | ||
94 | } | ||
95 | return(false); | ||
96 | } | ||
97 | |||
98 | bool KeyModifiers::isModifier(int keycode) | ||
99 | { | ||
100 | if(keycode == Qt::Key_Shift | ||
101 | || keycode == Qt::Key_Control | ||
102 | || keycode == Qt::Key_Alt | ||
103 | || keycode == Qt::Key_Meta | ||
104 | || keycode == Qt::Key_F22){ | ||
105 | return(true); | ||
106 | } else { | ||
107 | return(false); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | void KeyModifiers::releaseKey(int keycode) | ||
112 | { | ||
113 | if(m_releasekeys.contains(keycode)){ | ||
114 | ModifierList* list = m_releasekeys[keycode]; | ||
115 | for(ModifierList::Iterator it=(*list).begin(); | ||
116 | it!=(*list).end(); ++it){ | ||
117 | (*it)->pressed = false; | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | |||
122 | int KeyModifiers::getState() | ||
123 | { | ||
124 | int state = 0; | ||
125 | for(ModifierList::Iterator it=m_modifiers.begin(); | ||
126 | it!=m_modifiers.end(); ++it){ | ||
127 | if((*it)->pressed || (*it)->toggled){ | ||
128 | state |= m_types[(*it)->type]; | ||
129 | } | ||
130 | } | ||
131 | return(state); | ||
132 | } | ||
133 | |||
134 | int KeyModifiers::getState(int modifiers, bool reset) | ||
135 | { | ||
136 | int state = getState(); | ||
137 | int mask; | ||
138 | |||
139 | mask = getMask("Shift"); | ||
140 | if(modifiers & Qt::ShiftButton){ | ||
141 | state |= mask; | ||
142 | } else { | ||
143 | if(reset){ | ||
144 | state &= ~mask; | ||
145 | } | ||
146 | } | ||
147 | mask = getMask("Control"); | ||
148 | if(modifiers & Qt::ControlButton){ | ||
149 | state |= mask; | ||
150 | } else { | ||
151 | if(reset){ | ||
152 | state &= ~mask; | ||
153 | } | ||
154 | } | ||
155 | mask = getMask("Alt"); | ||
156 | if(modifiers & Qt::AltButton){ | ||
157 | state |= mask; | ||
158 | } else { | ||
159 | if(reset){ | ||
160 | state &= ~mask; | ||
161 | } | ||
162 | } | ||
163 | |||
164 | return(state); | ||
165 | } | ||
166 | |||
167 | int KeyModifiers::getModifiers(int modifiers) | ||
168 | { | ||
169 | int state = getState(); | ||
170 | |||
171 | if(state & getMask("Shift")){ | ||
172 | modifiers |= Qt::ShiftButton; | ||
173 | } | ||
174 | if(state & getMask("Control")){ | ||
175 | modifiers |= Qt::ControlButton; | ||
176 | } | ||
177 | if(state & getMask("Alt")){ | ||
178 | modifiers |= Qt::AltButton; | ||
179 | } | ||
180 | |||
181 | return(modifiers); | ||
182 | } | ||
183 | |||
184 | int KeyModifiers::getMask(const QString& type) | ||
185 | { | ||
186 | if(m_types.contains(type)){ | ||
187 | return(m_types[type]); | ||
188 | } else { | ||
189 | return(0); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | void KeyModifiers::clear() | ||
194 | { | ||
195 | m_types.clear(); | ||
196 | |||
197 | m_togglekeys.clear(); | ||
198 | |||
199 | for(ModifierList::Iterator it=m_modifiers.begin(); | ||
200 | it!=m_modifiers.end(); ++it){ | ||
201 | delete *it; | ||
202 | } | ||
203 | m_modifiers.clear(); | ||
204 | |||
205 | for(QMap<int, ModifierList*>::Iterator it=m_releasekeys.begin(); | ||
206 | it!=m_releasekeys.end(); ++it){ | ||
207 | delete *it; | ||
208 | } | ||
209 | m_releasekeys.clear(); | ||
210 | } | ||
211 | |||
212 | void KeyModifiers::init() | ||
213 | { | ||
214 | m_bitmask = 0x00000001; | ||
215 | addType("Shift"); | ||
216 | addType("Control"); | ||
217 | addType("Alt"); | ||
218 | |||
219 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | ||
220 | |||
221 | cfg.setGroup("Global"); | ||
222 | |||
223 | QString timeout = cfg.readEntry("ToggleTimeout", "10"); | ||
224 | int msec = timeout.toInt(); | ||
225 | msec *= 1000; /* sec to msec */ | ||
226 | m_timeout = msec; | ||
227 | } | ||
228 | |||
229 | void KeyModifiers::reset() | ||
230 | { | ||
231 | clear(); | ||
232 | init(); | ||
233 | } | ||
234 | |||
235 | bool KeyModifiers::isToggled() | ||
236 | { | ||
237 | for(ModifierList::Iterator it=m_togglekeys.begin(); | ||
238 | it!=m_togglekeys.end(); ++it){ | ||
239 | if((*it)->toggled){ | ||
240 | return(true); | ||
241 | } | ||
242 | } | ||
243 | return(false); | ||
244 | } | ||
245 | |||
246 | void KeyModifiers::resetToggles() | ||
247 | { | ||
248 | for(ModifierList::Iterator it=m_togglekeys.begin(); | ||
249 | it!=m_togglekeys.end(); ++it){ | ||
250 | (*it)->toggled = false; | ||
251 | } | ||
252 | m_pTimer->stop(); | ||
253 | } | ||
254 | |||
255 | void KeyModifiers::resetStates() | ||
256 | { | ||
257 | for(ModifierList::Iterator it=m_modifiers.begin(); | ||
258 | it!=m_modifiers.end(); ++it){ | ||
259 | (*it)->pressed = false; | ||
260 | } | ||
261 | resetToggles(); | ||
262 | } | ||
263 | |||
264 | void KeyModifiers::statistics() | ||
265 | { | ||
266 | qWarning("KeyModifiers::statistics()"); | ||
267 | for(ModifierList::Iterator it=m_modifiers.begin(); | ||
268 | it!=m_modifiers.end(); ++it){ | ||
269 | qWarning(" [%s][%x][%x][%d][%d]", | ||
270 | (*it)->type.latin1(), | ||
271 | (*it)->keycode, | ||
272 | (*it)->keymask, | ||
273 | (*it)->pressed, | ||
274 | (*it)->toggled); | ||
275 | for(QMap<int, ModifierList*>::Iterator it2=m_releasekeys.begin(); | ||
276 | it2!=m_releasekeys.end(); ++it2){ | ||
277 | for(ModifierList::Iterator it3=(*it2)->begin(); | ||
278 | it3!=(*it2)->end(); ++it3){ | ||
279 | if(*it == *it3){ | ||
280 | qWarning(" release[%x]", it2.key()); | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | } | ||
285 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.h b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.h new file mode 100644 index 0000000..a99c181 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyModifiers.h | |||
@@ -0,0 +1,80 @@ | |||
1 | #ifndef _KEY_MODIFIERS_H_ | ||
2 | #define _KEY_MODIFIERS_H_ | ||
3 | |||
4 | #include <qmap.h> | ||
5 | #include <qtimer.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qnamespace.h> | ||
8 | |||
9 | #include <qpe/config.h> | ||
10 | #include "ConfigEx.h" | ||
11 | |||
12 | struct ModifierInfo { | ||
13 | public: | ||
14 | ModifierInfo(const QString& tp, int code, int mask, bool mode) | ||
15 | { | ||
16 | type = tp; | ||
17 | keycode = code; | ||
18 | keymask = mask; | ||
19 | pressed = false; | ||
20 | toggled = false; | ||
21 | toggle_mode = mode; | ||
22 | } | ||
23 | QString type; | ||
24 | int keycode; | ||
25 | int keymask; | ||
26 | bool pressed; | ||
27 | bool toggled; | ||
28 | bool toggle_mode; | ||
29 | private: | ||
30 | } ; | ||
31 | |||
32 | class KeyModifiers : public QObject | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | public: | ||
36 | typedef QValueList<ModifierInfo*> ModifierList; | ||
37 | |||
38 | KeyModifiers(); | ||
39 | virtual ~KeyModifiers(); | ||
40 | void addType(const QString& type); | ||
41 | ModifierInfo* assign(const QString& type, int keycode, | ||
42 | int keymask = 0, bool toggle = false); | ||
43 | void assignRelease(int keycode); | ||
44 | void assignRelease(ModifierInfo* info, int keycode); | ||
45 | void setToggle(); | ||
46 | void setToggle(ModifierInfo* info); | ||
47 | |||
48 | bool isToggled(); | ||
49 | void resetStates(); | ||
50 | void keepToggles(); | ||
51 | |||
52 | bool pressKey(int keycode, int modifiers); | ||
53 | void releaseKey(int keycode); | ||
54 | int getState(); | ||
55 | int getState(int modifiers, bool reset = false); | ||
56 | int getMask(const QString& type); | ||
57 | int getModifiers(int modifiers); | ||
58 | |||
59 | bool isModifier(int keycode); | ||
60 | |||
61 | void statistics(); | ||
62 | |||
63 | void reset(); | ||
64 | public slots: | ||
65 | void resetToggles(); | ||
66 | private: | ||
67 | QMap<QString, int> m_types; | ||
68 | int m_bitmask; | ||
69 | ModifierList m_modifiers; | ||
70 | QMap<int, ModifierList*> m_releasekeys; | ||
71 | ModifierList m_togglekeys; | ||
72 | ModifierInfo* m_info; | ||
73 | QTimer* m_pTimer; | ||
74 | int m_timeout; | ||
75 | |||
76 | void clear(); | ||
77 | void init(); | ||
78 | }; | ||
79 | |||
80 | #endif /* _KEY_MODIFIERS_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyNames.cpp b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyNames.cpp new file mode 100644 index 0000000..2def857 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyNames.cpp | |||
@@ -0,0 +1,303 @@ | |||
1 | #include "KeyNames.h" | ||
2 | |||
3 | QMap<QString, int> KeyNames::codemap; | ||
4 | QMap<int, QString> KeyNames::namemap; | ||
5 | QString KeyNames::tmpname; | ||
6 | |||
7 | static struct { | ||
8 | int code; | ||
9 | char* name; | ||
10 | } stKeyNames[] = { | ||
11 | {Qt::Key_Escape, "Escape"}, | ||
12 | {Qt::Key_Tab, "Tab"}, | ||
13 | {Qt::Key_Backtab, "Backtab"}, | ||
14 | {Qt::Key_BackTab, "BackTab"}, | ||
15 | {Qt::Key_Backtab, "Backtab"}, | ||
16 | {Qt::Key_Backspace, "Backspace"}, | ||
17 | {Qt::Key_BackSpace, "BackSpace"}, | ||
18 | {Qt::Key_Backspace, "Backspace"}, | ||
19 | {Qt::Key_Return, "Return"}, | ||
20 | {Qt::Key_Enter, "Enter"}, | ||
21 | {Qt::Key_Insert, "Insert"}, | ||
22 | {Qt::Key_Delete, "Delete"}, | ||
23 | {Qt::Key_Pause, "Pause"}, | ||
24 | {Qt::Key_Print, "Print"}, | ||
25 | {Qt::Key_SysReq, "SysReq"}, | ||
26 | {Qt::Key_Home, "Home"}, | ||
27 | {Qt::Key_End, "End"}, | ||
28 | {Qt::Key_Left, "Left"}, | ||
29 | {Qt::Key_Up, "Up"}, | ||
30 | {Qt::Key_Right, "Right"}, | ||
31 | {Qt::Key_Down, "Down"}, | ||
32 | {Qt::Key_Prior, "Prior"}, | ||
33 | {Qt::Key_PageUp, "PageUp"}, | ||
34 | {Qt::Key_Prior, "Prior"}, | ||
35 | {Qt::Key_Next, "Next"}, | ||
36 | {Qt::Key_PageDown, "PageDown"}, | ||
37 | {Qt::Key_Next, "Next"}, | ||
38 | {Qt::Key_Shift, "Shift"}, | ||
39 | {Qt::Key_Control, "Control"}, | ||
40 | {Qt::Key_Meta, "Meta"}, | ||
41 | {Qt::Key_Alt, "Alt"}, | ||
42 | {Qt::Key_CapsLock, "CapsLock"}, | ||
43 | {Qt::Key_NumLock, "NumLock"}, | ||
44 | {Qt::Key_ScrollLock, "ScrollLock"}, | ||
45 | {Qt::Key_F1, "F1"}, | ||
46 | {Qt::Key_F2, "F2"}, | ||
47 | {Qt::Key_F3, "F3"}, | ||
48 | {Qt::Key_F4, "F4"}, | ||
49 | {Qt::Key_F5, "F5"}, | ||
50 | {Qt::Key_F6, "F6"}, | ||
51 | {Qt::Key_F7, "F7"}, | ||
52 | {Qt::Key_F8, "F8"}, | ||
53 | {Qt::Key_F9, "F9"}, | ||
54 | {Qt::Key_F10, "F10"}, | ||
55 | {Qt::Key_F11, "F11"}, | ||
56 | {Qt::Key_F12, "F12"}, | ||
57 | {Qt::Key_F13, "F13"}, | ||
58 | {Qt::Key_F14, "F14"}, | ||
59 | {Qt::Key_F15, "F15"}, | ||
60 | {Qt::Key_F16, "F16"}, | ||
61 | {Qt::Key_F17, "F17"}, | ||
62 | {Qt::Key_F18, "F18"}, | ||
63 | {Qt::Key_F19, "F19"}, | ||
64 | {Qt::Key_F20, "F20"}, | ||
65 | {Qt::Key_F21, "F21"}, | ||
66 | {Qt::Key_F22, "F22"}, | ||
67 | {Qt::Key_F23, "F23"}, | ||
68 | {Qt::Key_F24, "F24"}, | ||
69 | {Qt::Key_F25, "F25"}, | ||
70 | {Qt::Key_F26, "F26"}, | ||
71 | {Qt::Key_F27, "F27"}, | ||
72 | {Qt::Key_F28, "F28"}, | ||
73 | {Qt::Key_F29, "F29"}, | ||
74 | {Qt::Key_F30, "F30"}, | ||
75 | {Qt::Key_F31, "F31"}, | ||
76 | {Qt::Key_F32, "F32"}, | ||
77 | {Qt::Key_F33, "F33"}, | ||
78 | {Qt::Key_F34, "F34"}, | ||
79 | {Qt::Key_F35, "F35"}, | ||
80 | {Qt::Key_Super_L, "Super_L"}, | ||
81 | {Qt::Key_Super_R, "Super_R"}, | ||
82 | {Qt::Key_Menu, "Menu"}, | ||
83 | {Qt::Key_Hyper_L, "Hyper_L"}, | ||
84 | {Qt::Key_Hyper_R, "Hyper_R"}, | ||
85 | {Qt::Key_Help, "Help"}, | ||
86 | {Qt::Key_Space, "Space"}, | ||
87 | {Qt::Key_Any, "Any"}, | ||
88 | {Qt::Key_Space, "Space"}, | ||
89 | {Qt::Key_Exclam, "Exclam"}, | ||
90 | {Qt::Key_QuoteDbl, "QuoteDbl"}, | ||
91 | {Qt::Key_NumberSign, "NumberSign"}, | ||
92 | {Qt::Key_Dollar, "Dollar"}, | ||
93 | {Qt::Key_Percent, "Percent"}, | ||
94 | {Qt::Key_Ampersand, "Ampersand"}, | ||
95 | {Qt::Key_Apostrophe, "Apostrophe"}, | ||
96 | {Qt::Key_ParenLeft, "ParenLeft"}, | ||
97 | {Qt::Key_ParenRight, "ParenRight"}, | ||
98 | {Qt::Key_Asterisk, "Asterisk"}, | ||
99 | {Qt::Key_Plus, "Plus"}, | ||
100 | {Qt::Key_Comma, "Comma"}, | ||
101 | {Qt::Key_Minus, "Minus"}, | ||
102 | {Qt::Key_Period, "Period"}, | ||
103 | {Qt::Key_Slash, "Slash"}, | ||
104 | {Qt::Key_0, "0"}, | ||
105 | {Qt::Key_1, "1"}, | ||
106 | {Qt::Key_2, "2"}, | ||
107 | {Qt::Key_3, "3"}, | ||
108 | {Qt::Key_4, "4"}, | ||
109 | {Qt::Key_5, "5"}, | ||
110 | {Qt::Key_6, "6"}, | ||
111 | {Qt::Key_7, "7"}, | ||
112 | {Qt::Key_8, "8"}, | ||
113 | {Qt::Key_9, "9"}, | ||
114 | {Qt::Key_Colon, "Colon"}, | ||
115 | {Qt::Key_Semicolon, "Semicolon"}, | ||
116 | {Qt::Key_Less, "Less"}, | ||
117 | {Qt::Key_Equal, "Equal"}, | ||
118 | {Qt::Key_Greater, "Greater"}, | ||
119 | {Qt::Key_Question, "Question"}, | ||
120 | {Qt::Key_At, "At"}, | ||
121 | {Qt::Key_A, "A"}, | ||
122 | {Qt::Key_B, "B"}, | ||
123 | {Qt::Key_C, "C"}, | ||
124 | {Qt::Key_D, "D"}, | ||
125 | {Qt::Key_E, "E"}, | ||
126 | {Qt::Key_F, "F"}, | ||
127 | {Qt::Key_G, "G"}, | ||
128 | {Qt::Key_H, "H"}, | ||
129 | {Qt::Key_I, "I"}, | ||
130 | {Qt::Key_J, "J"}, | ||
131 | {Qt::Key_K, "K"}, | ||
132 | {Qt::Key_L, "L"}, | ||
133 | {Qt::Key_M, "M"}, | ||
134 | {Qt::Key_N, "N"}, | ||
135 | {Qt::Key_O, "O"}, | ||
136 | {Qt::Key_P, "P"}, | ||
137 | {Qt::Key_Q, "Q"}, | ||
138 | {Qt::Key_R, "R"}, | ||
139 | {Qt::Key_S, "S"}, | ||
140 | {Qt::Key_T, "T"}, | ||
141 | {Qt::Key_U, "U"}, | ||
142 | {Qt::Key_V, "V"}, | ||
143 | {Qt::Key_W, "W"}, | ||
144 | {Qt::Key_X, "X"}, | ||
145 | {Qt::Key_Y, "Y"}, | ||
146 | {Qt::Key_Z, "Z"}, | ||
147 | {Qt::Key_BracketLeft, "BracketLeft"}, | ||
148 | {Qt::Key_Backslash, "Backslash"}, | ||
149 | {Qt::Key_BracketRight, "BracketRight"}, | ||
150 | {Qt::Key_AsciiCircum, "AsciiCircum"}, | ||
151 | {Qt::Key_Underscore, "Underscore"}, | ||
152 | {Qt::Key_QuoteLeft, "QuoteLeft"}, | ||
153 | {Qt::Key_BraceLeft, "BraceLeft"}, | ||
154 | {Qt::Key_Bar, "Bar"}, | ||
155 | {Qt::Key_BraceRight, "BraceRight"}, | ||
156 | {Qt::Key_AsciiTilde, "AsciiTilde"}, | ||
157 | {Qt::Key_nobreakspace, "nobreakspace"}, | ||
158 | {Qt::Key_exclamdown, "exclamdown"}, | ||
159 | {Qt::Key_cent, "cent"}, | ||
160 | {Qt::Key_sterling, "sterling"}, | ||
161 | {Qt::Key_currency, "currency"}, | ||
162 | {Qt::Key_yen, "yen"}, | ||
163 | {Qt::Key_brokenbar, "brokenbar"}, | ||
164 | {Qt::Key_section, "section"}, | ||
165 | {Qt::Key_diaeresis, "diaeresis"}, | ||
166 | {Qt::Key_copyright, "copyright"}, | ||
167 | {Qt::Key_ordfeminine, "ordfeminine"}, | ||
168 | {Qt::Key_guillemotleft, "guillemotleft"}, | ||
169 | {Qt::Key_notsign, "notsign"}, | ||
170 | {Qt::Key_hyphen, "hyphen"}, | ||
171 | {Qt::Key_registered, "registered"}, | ||
172 | {Qt::Key_macron, "macron"}, | ||
173 | {Qt::Key_degree, "degree"}, | ||
174 | {Qt::Key_plusminus, "plusminus"}, | ||
175 | {Qt::Key_twosuperior, "twosuperior"}, | ||
176 | {Qt::Key_threesuperior, "threesuperior"}, | ||
177 | {Qt::Key_acute, "acute"}, | ||
178 | {Qt::Key_mu, "mu"}, | ||
179 | {Qt::Key_paragraph, "paragraph"}, | ||
180 | {Qt::Key_periodcentered, "periodcentered"}, | ||
181 | {Qt::Key_cedilla, "cedilla"}, | ||
182 | {Qt::Key_onesuperior, "onesuperior"}, | ||
183 | {Qt::Key_masculine, "masculine"}, | ||
184 | {Qt::Key_guillemotright, "guillemotright"}, | ||
185 | {Qt::Key_onequarter, "onequarter"}, | ||
186 | {Qt::Key_onehalf, "onehalf"}, | ||
187 | {Qt::Key_threequarters, "threequarters"}, | ||
188 | {Qt::Key_questiondown, "questiondown"}, | ||
189 | {Qt::Key_Agrave, "Agrave"}, | ||
190 | {Qt::Key_Aacute, "Aacute"}, | ||
191 | {Qt::Key_Acircumflex, "Acircumflex"}, | ||
192 | {Qt::Key_Atilde, "Atilde"}, | ||
193 | {Qt::Key_Adiaeresis, "Adiaeresis"}, | ||
194 | {Qt::Key_Aring, "Aring"}, | ||
195 | {Qt::Key_AE, "AE"}, | ||
196 | {Qt::Key_Ccedilla, "Ccedilla"}, | ||
197 | {Qt::Key_Egrave, "Egrave"}, | ||
198 | {Qt::Key_Eacute, "Eacute"}, | ||
199 | {Qt::Key_Ecircumflex, "Ecircumflex"}, | ||
200 | {Qt::Key_Ediaeresis, "Ediaeresis"}, | ||
201 | {Qt::Key_Igrave, "Igrave"}, | ||
202 | {Qt::Key_Iacute, "Iacute"}, | ||
203 | {Qt::Key_Icircumflex, "Icircumflex"}, | ||
204 | {Qt::Key_Idiaeresis, "Idiaeresis"}, | ||
205 | {Qt::Key_ETH, "ETH"}, | ||
206 | {Qt::Key_Ntilde, "Ntilde"}, | ||
207 | {Qt::Key_Ograve, "Ograve"}, | ||
208 | {Qt::Key_Oacute, "Oacute"}, | ||
209 | {Qt::Key_Ocircumflex, "Ocircumflex"}, | ||
210 | {Qt::Key_Otilde, "Otilde"}, | ||
211 | {Qt::Key_Odiaeresis, "Odiaeresis"}, | ||
212 | {Qt::Key_multiply, "multiply"}, | ||
213 | {Qt::Key_Ooblique, "Ooblique"}, | ||
214 | {Qt::Key_Ugrave, "Ugrave"}, | ||
215 | {Qt::Key_Uacute, "Uacute"}, | ||
216 | {Qt::Key_Ucircumflex, "Ucircumflex"}, | ||
217 | {Qt::Key_Udiaeresis, "Udiaeresis"}, | ||
218 | {Qt::Key_Yacute, "Yacute"}, | ||
219 | {Qt::Key_THORN, "THORN"}, | ||
220 | {Qt::Key_ssharp, "ssharp"}, | ||
221 | {Qt::Key_agrave, "agrave"}, | ||
222 | {Qt::Key_aacute, "aacute"}, | ||
223 | {Qt::Key_acircumflex, "acircumflex"}, | ||
224 | {Qt::Key_atilde, "atilde"}, | ||
225 | {Qt::Key_adiaeresis, "adiaeresis"}, | ||
226 | {Qt::Key_aring, "aring"}, | ||
227 | {Qt::Key_ae, "ae"}, | ||
228 | {Qt::Key_ccedilla, "ccedilla"}, | ||
229 | {Qt::Key_egrave, "egrave"}, | ||
230 | {Qt::Key_eacute, "eacute"}, | ||
231 | {Qt::Key_ecircumflex, "ecircumflex"}, | ||
232 | {Qt::Key_ediaeresis, "ediaeresis"}, | ||
233 | {Qt::Key_igrave, "igrave"}, | ||
234 | {Qt::Key_iacute, "iacute"}, | ||
235 | {Qt::Key_icircumflex, "icircumflex"}, | ||
236 | {Qt::Key_idiaeresis, "idiaeresis"}, | ||
237 | {Qt::Key_eth, "eth"}, | ||
238 | {Qt::Key_ntilde, "ntilde"}, | ||
239 | {Qt::Key_ograve, "ograve"}, | ||
240 | {Qt::Key_oacute, "oacute"}, | ||
241 | {Qt::Key_ocircumflex, "ocircumflex"}, | ||
242 | {Qt::Key_otilde, "otilde"}, | ||
243 | {Qt::Key_odiaeresis, "odiaeresis"}, | ||
244 | {Qt::Key_division, "division"}, | ||
245 | {Qt::Key_oslash, "oslash"}, | ||
246 | {Qt::Key_ugrave, "ugrave"}, | ||
247 | {Qt::Key_uacute, "uacute"}, | ||
248 | {Qt::Key_ucircumflex, "ucircumflex"}, | ||
249 | {Qt::Key_udiaeresis, "udiaeresis"}, | ||
250 | {Qt::Key_yacute, "yacute"}, | ||
251 | {Qt::Key_thorn, "thorn"}, | ||
252 | {Qt::Key_ydiaeresis, "ydiaeresis"}, | ||
253 | {Qt::Key_unknown, "unknown"}, | ||
254 | {0,0}, | ||
255 | }; | ||
256 | |||
257 | void KeyNames::setCodeMap() | ||
258 | { | ||
259 | int i; | ||
260 | |||
261 | codemap.clear(); | ||
262 | for(i=0; stKeyNames[i].code != 0; i++){ | ||
263 | codemap.insert(stKeyNames[i].name, stKeyNames[i].code); | ||
264 | } | ||
265 | } | ||
266 | |||
267 | void KeyNames::setNameMap() | ||
268 | { | ||
269 | int i; | ||
270 | |||
271 | namemap.clear(); | ||
272 | for(i=0; stKeyNames[i].code != 0; i++){ | ||
273 | namemap.insert(stKeyNames[i].code, stKeyNames[i].name); | ||
274 | } | ||
275 | } | ||
276 | |||
277 | |||
278 | int KeyNames::getCode(const QString& s){ | ||
279 | if(codemap.isEmpty()) setCodeMap(); | ||
280 | if(codemap.contains(s)){ | ||
281 | return(codemap[s]); | ||
282 | } else { | ||
283 | if(s.find("0x") == 0){ | ||
284 | bool success; | ||
285 | int val = s.mid(2).toInt(&success, 16); | ||
286 | if(success){ | ||
287 | return(val); | ||
288 | } | ||
289 | } | ||
290 | return(0); | ||
291 | } | ||
292 | } | ||
293 | |||
294 | const QString& KeyNames::getName(int code){ | ||
295 | if(namemap.isEmpty()) setNameMap(); | ||
296 | if(namemap.contains(code)){ | ||
297 | return(namemap[code]); | ||
298 | } else { | ||
299 | tmpname.sprintf("0x%x", code); | ||
300 | return(tmpname); | ||
301 | //return(QString::null); | ||
302 | } | ||
303 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyNames.h b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyNames.h new file mode 100644 index 0000000..3e80763 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyNames.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #ifndef _KEY_NAMES_H_ | ||
2 | #define _KEY_NAMES_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qmap.h> | ||
6 | #include <qnamespace.h> | ||
7 | |||
8 | class KeyNames | ||
9 | { | ||
10 | public: | ||
11 | static const QString& getName(int code); | ||
12 | static int getCode(const QString& s); | ||
13 | |||
14 | static void clearName(){ | ||
15 | namemap.clear(); | ||
16 | } | ||
17 | static void setCode(const QString& s, int code){ | ||
18 | if(codemap.contains(s) == false){ | ||
19 | codemap.insert(s, code); | ||
20 | } | ||
21 | } | ||
22 | static void clearCode(){ | ||
23 | codemap.clear(); | ||
24 | } | ||
25 | static void reset(){ | ||
26 | clearCode(); | ||
27 | } | ||
28 | private: | ||
29 | static QMap<QString, int> codemap; | ||
30 | static QMap<int, QString> namemap; | ||
31 | static QString tmpname; | ||
32 | |||
33 | static void setCodeMap(); | ||
34 | static void setNameMap(); | ||
35 | }; | ||
36 | |||
37 | #endif /* _KEY_NAMES_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyRepeater.cpp b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyRepeater.cpp new file mode 100644 index 0000000..84a8a89 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyRepeater.cpp | |||
@@ -0,0 +1,140 @@ | |||
1 | #include "KeyRepeater.h" | ||
2 | |||
3 | KeyRepeater::KeyRepeater() | ||
4 | { | ||
5 | qDebug("KeyRepeater::KeyRepeater()"); | ||
6 | m_pTimer = new QTimer(this); | ||
7 | connect(m_pTimer, SIGNAL(timeout()), this, SLOT(autoRepeat())); | ||
8 | init(); | ||
9 | } | ||
10 | |||
11 | KeyRepeater::~KeyRepeater() | ||
12 | { | ||
13 | qDebug("KeyRepeater::~KeyRepeater()"); | ||
14 | delete m_pTimer; | ||
15 | } | ||
16 | |||
17 | void KeyRepeater::start(int unicode, int keycode, int modifiers) | ||
18 | { | ||
19 | m_unicode = unicode; | ||
20 | m_keycode = keycode; | ||
21 | m_modifiers = modifiers; | ||
22 | if(m_mode == ENABLE){ | ||
23 | m_pTimer->stop(); | ||
24 | if(isRepeatable(keycode)){ | ||
25 | /* repeater start */ | ||
26 | m_pTimer->start(m_repeatdelay, TRUE); | ||
27 | } | ||
28 | } | ||
29 | } | ||
30 | |||
31 | void KeyRepeater::stop(int keycode) | ||
32 | { | ||
33 | if(keycode == 0 | ||
34 | || keycode == m_keycode | ||
35 | || isRepeatable(keycode) == false){ | ||
36 | m_pTimer->stop(); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | void KeyRepeater::init() | ||
41 | { | ||
42 | m_mode = ENABLE; | ||
43 | m_repeatdelay = 400; | ||
44 | m_repeatperiod = 60; | ||
45 | m_disablekeys.append(0); | ||
46 | m_disablekeys.append(Qt::Key_Escape); | ||
47 | m_disablekeys.append(Qt::Key_Shift); | ||
48 | m_disablekeys.append(Qt::Key_Control); | ||
49 | m_disablekeys.append(Qt::Key_Alt); | ||
50 | m_disablekeys.append(Qt::Key_Meta); | ||
51 | for(int i=Qt::Key_F1; i<=Qt::Key_F35; i++){ | ||
52 | m_disablekeys.append(i); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | void KeyRepeater::clear() | ||
57 | { | ||
58 | m_disablekeys.clear(); | ||
59 | } | ||
60 | |||
61 | void KeyRepeater::reset() | ||
62 | { | ||
63 | clear(); | ||
64 | init(); | ||
65 | } | ||
66 | |||
67 | void KeyRepeater::setRepeatable(int keycode, bool enable) | ||
68 | { | ||
69 | if(enable){ | ||
70 | QValueList<int>::Iterator it = m_disablekeys.find(keycode); | ||
71 | if(it != m_disablekeys.end()){ | ||
72 | m_disablekeys.remove(it); | ||
73 | } | ||
74 | } else { | ||
75 | if(m_disablekeys.contains(keycode) == false){ | ||
76 | m_disablekeys.append(keycode); | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | bool KeyRepeater::isRepeatable(int keycode) | ||
82 | { | ||
83 | if(m_disablekeys.contains(keycode)){ | ||
84 | return(false); | ||
85 | } else { | ||
86 | return(true); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | void KeyRepeater::autoRepeat() | ||
91 | { | ||
92 | /* key release event */ | ||
93 | #if 0 | ||
94 | sendKeyEvent( | ||
95 | m_unicode, | ||
96 | m_keycode, | ||
97 | m_modifiers, | ||
98 | FALSE, | ||
99 | TRUE); | ||
100 | /* key press event */ | ||
101 | sendKeyEvent( | ||
102 | m_unicode, | ||
103 | m_keycode, | ||
104 | m_modifiers, | ||
105 | TRUE, | ||
106 | TRUE); | ||
107 | #else | ||
108 | emit keyEvent( | ||
109 | m_unicode, | ||
110 | m_keycode, | ||
111 | m_modifiers, | ||
112 | FALSE, | ||
113 | TRUE); | ||
114 | /* key press event */ | ||
115 | emit keyEvent( | ||
116 | m_unicode, | ||
117 | m_keycode, | ||
118 | m_modifiers, | ||
119 | TRUE, | ||
120 | TRUE); | ||
121 | #endif | ||
122 | /* start auto repeat */ | ||
123 | m_pTimer->start(m_repeatperiod); | ||
124 | #if 0 | ||
125 | qDebug("autoRepeat[%x][%x][%x]", | ||
126 | m_unicode, | ||
127 | m_keycode, | ||
128 | m_modifiers); | ||
129 | #endif | ||
130 | } | ||
131 | |||
132 | void KeyRepeater::statistics() | ||
133 | { | ||
134 | qWarning("KeyRepeater::statistics()"); | ||
135 | qWarning(" delay[%d] period[%d]", m_repeatdelay, m_repeatperiod); | ||
136 | for(QValueList<int>::Iterator it=m_disablekeys.begin(); | ||
137 | it!=m_disablekeys.end(); ++it){ | ||
138 | qDebug(" disable[%x]", *it); | ||
139 | } | ||
140 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/KeyRepeater.h b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyRepeater.h new file mode 100644 index 0000000..56d6414 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/KeyRepeater.h | |||
@@ -0,0 +1,86 @@ | |||
1 | #ifndef _KEY_REPEATER_H_ | ||
2 | #define _KEY_REPEATER_H_ | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <qtimer.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qwindowsystem_qws.h> | ||
8 | |||
9 | #include <syslog.h> | ||
10 | |||
11 | class KeyRepeater : public QObject | ||
12 | { | ||
13 | Q_OBJECT | ||
14 | public: | ||
15 | KeyRepeater(); | ||
16 | virtual ~KeyRepeater(); | ||
17 | |||
18 | typedef enum { | ||
19 | DISABLE=0, | ||
20 | ENABLE=1, | ||
21 | KILL=2, | ||
22 | } RepeaterMode; | ||
23 | |||
24 | void start(int unicode, int keycode, int modifieres); | ||
25 | void stop(int keycode = 0); | ||
26 | void reset(); | ||
27 | |||
28 | void setRepeatable(int keycode, bool enable); | ||
29 | bool isRepeatable(int keycode); | ||
30 | |||
31 | void setMode(int mode){ | ||
32 | switch(mode){ | ||
33 | case DISABLE: | ||
34 | m_mode = DISABLE; | ||
35 | break; | ||
36 | case ENABLE: | ||
37 | m_mode = ENABLE; | ||
38 | break; | ||
39 | case KILL: | ||
40 | m_mode = KILL; | ||
41 | break; | ||
42 | default: | ||
43 | m_mode = ENABLE; | ||
44 | break; | ||
45 | } | ||
46 | } | ||
47 | RepeaterMode getMode(){ | ||
48 | return(m_mode); | ||
49 | } | ||
50 | |||
51 | void setDelay(int msec) | ||
52 | { | ||
53 | m_repeatdelay = msec; | ||
54 | } | ||
55 | void setPeriod(int msec) | ||
56 | { | ||
57 | m_repeatperiod = msec; | ||
58 | } | ||
59 | |||
60 | void statistics(); | ||
61 | private slots: | ||
62 | void autoRepeat(); | ||
63 | private: | ||
64 | int m_unicode; | ||
65 | int m_keycode; | ||
66 | int m_modifiers; | ||
67 | |||
68 | int m_repeatdelay; | ||
69 | int m_repeatperiod; | ||
70 | |||
71 | QCString m_hookChannel; | ||
72 | |||
73 | RepeaterMode m_mode; | ||
74 | |||
75 | QValueList<int> m_disablekeys; | ||
76 | |||
77 | QTimer* m_pTimer; | ||
78 | |||
79 | void init(); | ||
80 | void clear(); | ||
81 | signals: | ||
82 | void keyEvent(int unicode, int keycode, int modifiers, | ||
83 | bool isPress, bool autoRepeat); | ||
84 | }; | ||
85 | |||
86 | #endif /* _KEY_REPEATER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/StringParser.cpp b/noncore/applets/keyhelper/keyhelperapplet/misc/StringParser.cpp new file mode 100644 index 0000000..72c15f1 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/StringParser.cpp | |||
@@ -0,0 +1,72 @@ | |||
1 | #include "StringParser.h" | ||
2 | |||
3 | #include <qregexp.h> | ||
4 | |||
5 | QStringList StringParser::split(const QChar& sep, const QString& str, | ||
6 | bool allowEmptyEntries) | ||
7 | { | ||
8 | QString line = str + sep; | ||
9 | QString quote; | ||
10 | QRegExp rxend; | ||
11 | QRegExp rxdbl; | ||
12 | int pos=0, len, idx=0; | ||
13 | QStringList list; | ||
14 | while(idx < (int)line.length()-1){ | ||
15 | if(!quote.isEmpty()){ | ||
16 | QString s; | ||
17 | while((pos = rxend.match(line, idx, &len)) != -1){ | ||
18 | s += line.mid(idx, len+pos-idx-1); | ||
19 | idx = pos+len-1; | ||
20 | if(len % 2 == 0){ | ||
21 | s.replace(rxdbl, quote); | ||
22 | list.append(s.left(s.length()-1)); | ||
23 | idx++; | ||
24 | break; | ||
25 | } | ||
26 | } | ||
27 | quote = ""; | ||
28 | } else if(line[idx] == '\"'){ | ||
29 | rxend.setPattern(QString("\"+") + sep); | ||
30 | rxdbl.setPattern("\"\""); | ||
31 | quote = "\""; | ||
32 | idx++; | ||
33 | } else if(line[idx] == '\''){ | ||
34 | rxend.setPattern(QString("\'+") + sep); | ||
35 | rxdbl.setPattern("\'\'"); | ||
36 | quote = "\'"; | ||
37 | idx++; | ||
38 | } else if(!allowEmptyEntries && line[idx] == sep){ | ||
39 | idx++; | ||
40 | } else { | ||
41 | pos = line.find(sep, idx); | ||
42 | if(pos != -1){ | ||
43 | const QString& s = line.mid(idx, pos-idx); | ||
44 | list.append(s); | ||
45 | idx = pos+1; | ||
46 | } | ||
47 | } | ||
48 | if(pos == -1) break; | ||
49 | } | ||
50 | return list; | ||
51 | } | ||
52 | |||
53 | QString StringParser::join(const QChar& sep, const QStringList& list) | ||
54 | { | ||
55 | QString str; | ||
56 | QString s; | ||
57 | QStringList tmp; | ||
58 | QRegExp quote("\""); | ||
59 | for(QStringList::ConstIterator it=list.begin(); | ||
60 | it!=list.end(); ++it){ | ||
61 | s = *it; | ||
62 | if(s.find(sep) != -1 | ||
63 | || s[0] == '\"' | ||
64 | || s[0] == '\''){ | ||
65 | s.replace(quote, "\"\""); | ||
66 | tmp.append("\"" + s + "\""); | ||
67 | } else { | ||
68 | tmp.append(s); | ||
69 | } | ||
70 | } | ||
71 | return tmp.join(sep); | ||
72 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperapplet/misc/StringParser.h b/noncore/applets/keyhelper/keyhelperapplet/misc/StringParser.h new file mode 100644 index 0000000..8c1dc58 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/misc/StringParser.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _STRING_PARSER_H_ | ||
2 | #define _STRING_PARSER_H_ | ||
3 | |||
4 | #include <qstringlist.h> | ||
5 | |||
6 | class StringParser | ||
7 | { | ||
8 | public: | ||
9 | static QStringList split(const QChar& sep, const QString& str, | ||
10 | bool allowEmptyEntries=FALSE); | ||
11 | static QString join(const QChar& sep, const QStringList& list); | ||
12 | }; | ||
13 | |||
14 | #endif /* _STRING_PARSER_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperconf/KHCWidget.cpp b/noncore/applets/keyhelper/keyhelperconf/KHCWidget.cpp new file mode 100644 index 0000000..b0767cf --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/KHCWidget.cpp | |||
@@ -0,0 +1,307 @@ | |||
1 | #include "KHCWidget.h" | ||
2 | |||
3 | KHCWidget::KHCWidget(QWidget* parent, const char* name, WFlags fl) | ||
4 | : KHCWidgetBase(parent, name, fl) | ||
5 | { | ||
6 | m_isEnable = true; | ||
7 | setLayout(); | ||
8 | setHandler(); | ||
9 | |||
10 | txtOrgKey->installEventFilter(this); | ||
11 | txtMapKey->installEventFilter(this); | ||
12 | } | ||
13 | |||
14 | KHCWidget::~KHCWidget() | ||
15 | { | ||
16 | } | ||
17 | |||
18 | void KHCWidget::setLayout() | ||
19 | { | ||
20 | QBoxLayout* topLayout = new QVBoxLayout(this, 5); | ||
21 | |||
22 | QBoxLayout* orgLayout1 = new QHBoxLayout(topLayout); | ||
23 | orgLayout1->addWidget(lblOriginal); | ||
24 | orgLayout1->addWidget(txtOrgKey); | ||
25 | |||
26 | QBoxLayout* orgLayout2 = new QHBoxLayout(topLayout); | ||
27 | orgLayout2->addWidget(lblOrgK); | ||
28 | orgLayout2->addWidget(lblOrgKeycode); | ||
29 | #if 0 | ||
30 | orgLayout2->addWidget(lblOrgM); | ||
31 | orgLayout2->addWidget(lblOrgModifiers); | ||
32 | #endif | ||
33 | orgLayout2->addWidget(lblOrgU); | ||
34 | orgLayout2->addWidget(lblOrgUnicode); | ||
35 | orgLayout2->addWidget(chkOrgShift); | ||
36 | orgLayout2->addWidget(chkOrgCtrl); | ||
37 | orgLayout2->addWidget(chkOrgAlt); | ||
38 | |||
39 | QBoxLayout* mapLayout1 = new QHBoxLayout(topLayout); | ||
40 | mapLayout1->addWidget(lblMapping); | ||
41 | mapLayout1->addWidget(txtMapKey); | ||
42 | |||
43 | QBoxLayout* mapLayout2 = new QHBoxLayout(topLayout); | ||
44 | mapLayout2->addWidget(lblMapK); | ||
45 | mapLayout2->addWidget(lblMapKeycode); | ||
46 | #if 0 | ||
47 | mapLayout2->addWidget(lblMapM); | ||
48 | mapLayout2->addWidget(lblMapModifiers); | ||
49 | #endif | ||
50 | mapLayout2->addWidget(lblMapU); | ||
51 | mapLayout2->addWidget(lblMapUnicode); | ||
52 | mapLayout2->addWidget(chkMapShift); | ||
53 | mapLayout2->addWidget(chkMapCtrl); | ||
54 | mapLayout2->addWidget(chkMapAlt); | ||
55 | |||
56 | QBoxLayout* btnLayout = new QHBoxLayout(topLayout); | ||
57 | btnLayout->addWidget(btnGen); | ||
58 | btnLayout->addWidget(btnCopy); | ||
59 | btnLayout->addWidget(btnCtrl); | ||
60 | |||
61 | topLayout->addWidget(mleDefine); | ||
62 | } | ||
63 | |||
64 | void KHCWidget::setHandler() | ||
65 | { | ||
66 | connect(btnGen, SIGNAL(clicked()), this, SLOT(onClick_Gen())); | ||
67 | connect(btnCopy, SIGNAL(clicked()), this, SLOT(onClick_Copy())); | ||
68 | connect(btnCtrl, SIGNAL(clicked()), this, SLOT(onClick_Ctrl())); | ||
69 | } | ||
70 | |||
71 | bool KHCWidget::eventFilter(QObject* o, QEvent* e) | ||
72 | { | ||
73 | if(::strcmp(o->name(), "txtOrgKey") == 0){ | ||
74 | if(e->type() == QEvent::KeyPress){ | ||
75 | QKeyEvent* ke = (QKeyEvent*)e; | ||
76 | if(ke->isAutoRepeat() == false){ | ||
77 | onPress_Org(ke); | ||
78 | } | ||
79 | return(true); | ||
80 | } | ||
81 | } else if(::strcmp(o->name(), "txtMapKey") == 0){ | ||
82 | if(e->type() == QEvent::KeyPress){ | ||
83 | QKeyEvent* ke = (QKeyEvent*)e; | ||
84 | if(ke->isAutoRepeat() == false){ | ||
85 | onPress_Map(ke); | ||
86 | } | ||
87 | return(true); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | return QWidget::eventFilter(o, e); | ||
92 | } | ||
93 | |||
94 | void KHCWidget::onPress_Org(QKeyEvent* ke) | ||
95 | { | ||
96 | /* keycode */ | ||
97 | const QString& name = KeyNames::getName(ke->key()); | ||
98 | if(name == QString::null){ | ||
99 | lblOrgKeycode->setText(QString::number(ke->key(), 16)); | ||
100 | } else { | ||
101 | lblOrgKeycode->setText(name); | ||
102 | } | ||
103 | /* modifiers */ | ||
104 | chkOrgShift->setChecked(ke->state() & Qt::ShiftButton); | ||
105 | chkOrgCtrl->setChecked(ke->state() & Qt::ControlButton); | ||
106 | chkOrgAlt->setChecked(ke->state() & Qt::AltButton); | ||
107 | |||
108 | /* unicode */ | ||
109 | if(ke->text()[0].isPrint()){ | ||
110 | lblOrgUnicode->setText(ke->text()); | ||
111 | } else { | ||
112 | lblOrgUnicode->setText(QString::number(ke->ascii(), 16)); | ||
113 | } | ||
114 | m_OrgkeyData.setData(ke); | ||
115 | } | ||
116 | |||
117 | void KHCWidget::onPress_Map(QKeyEvent* ke) | ||
118 | { | ||
119 | /* keycode */ | ||
120 | const QString& name = KeyNames::getName(ke->key()); | ||
121 | if(name == QString::null){ | ||
122 | lblMapKeycode->setText(QString::number(ke->key(), 16)); | ||
123 | } else { | ||
124 | lblMapKeycode->setText(name); | ||
125 | } | ||
126 | /* modifiers */ | ||
127 | chkMapShift->setChecked(ke->state() & Qt::ShiftButton); | ||
128 | chkMapCtrl->setChecked(ke->state() & Qt::ControlButton); | ||
129 | chkMapAlt->setChecked(ke->state() & Qt::AltButton); | ||
130 | |||
131 | /* unicode */ | ||
132 | if(ke->text()[0].isPrint()){ | ||
133 | lblMapUnicode->setText(ke->text()); | ||
134 | } else { | ||
135 | lblMapUnicode->setText(QString::number(ke->ascii(), 16)); | ||
136 | } | ||
137 | m_MapkeyData.setData(ke); | ||
138 | } | ||
139 | |||
140 | void KHCWidget::onClick_Gen() | ||
141 | { | ||
142 | mleDefine->clear(); | ||
143 | if(m_OrgkeyData.key == 0 | ||
144 | || m_MapkeyData.key == 0){ | ||
145 | return; | ||
146 | } | ||
147 | /* original key */ | ||
148 | QString line; | ||
149 | const QString& name = KeyNames::getName(m_OrgkeyData.key); | ||
150 | line = "<define "; | ||
151 | if(name == QString::null){ | ||
152 | line.append("code=\""); | ||
153 | line.append(QString::number(m_OrgkeyData.key, 16)); | ||
154 | } else { | ||
155 | line.append("key=\""); | ||
156 | line.append(name); | ||
157 | } | ||
158 | line.append("\">"); | ||
159 | mleDefine->append(line); | ||
160 | |||
161 | /* original modifiers */ | ||
162 | bool need = false; | ||
163 | line = "<modifier"; | ||
164 | if(chkOrgShift->isChecked()){ | ||
165 | line.append(" Shift=\"On\""); | ||
166 | need = true; | ||
167 | } | ||
168 | if(chkOrgCtrl->isChecked()){ | ||
169 | line.append(" Control=\"On\""); | ||
170 | need = true; | ||
171 | } | ||
172 | if(chkOrgAlt->isChecked()){ | ||
173 | line.append(" Alt=\"On\""); | ||
174 | need = true; | ||
175 | } | ||
176 | line.append("/>"); | ||
177 | if(need){ | ||
178 | mleDefine->append(line); | ||
179 | } | ||
180 | |||
181 | /* mapping key */ | ||
182 | const QString& mapname = KeyNames::getName(m_MapkeyData.key); | ||
183 | line = "<map"; | ||
184 | if(mapname == QString::null){ | ||
185 | line.append(" code=\""); | ||
186 | line.append(QString::number(m_MapkeyData.key, 16)); | ||
187 | } else { | ||
188 | line.append(" key=\""); | ||
189 | line.append(mapname); | ||
190 | } | ||
191 | line.append("\"/>"); | ||
192 | mleDefine->append(line); | ||
193 | |||
194 | /* mapping modifiers */ | ||
195 | need = false; | ||
196 | line = "<map_modifier"; | ||
197 | bool on = chkMapShift->isChecked(); | ||
198 | if(chkOrgShift->isChecked() != on){ | ||
199 | line.append(" Shift=\""); | ||
200 | if(on){ | ||
201 | line.append("On\""); | ||
202 | } else { | ||
203 | line.append("Off\""); | ||
204 | } | ||
205 | need = true; | ||
206 | } | ||
207 | on = chkMapCtrl->isChecked(); | ||
208 | if(chkOrgCtrl->isChecked() != on){ | ||
209 | line.append(" Control=\""); | ||
210 | if(on){ | ||
211 | line.append("On\""); | ||
212 | } else { | ||
213 | line.append("Off\""); | ||
214 | } | ||
215 | need = true; | ||
216 | } | ||
217 | on = chkMapAlt->isChecked(); | ||
218 | if(chkOrgAlt->isChecked() != on){ | ||
219 | line.append(" Alt=\""); | ||
220 | if(on){ | ||
221 | line.append("On\""); | ||
222 | } else { | ||
223 | line.append("Off\""); | ||
224 | } | ||
225 | need = true; | ||
226 | } | ||
227 | line.append("/>"); | ||
228 | if(need){ | ||
229 | mleDefine->append(line); | ||
230 | } | ||
231 | |||
232 | /* mapping unicode */ | ||
233 | bool found = false; | ||
234 | for(const QWSServer::KeyMap* m = QWSServer::keyMap(); | ||
235 | m->key_code != 0; m++){ | ||
236 | if(m->key_code == m_MapkeyData.key){ | ||
237 | if(m_MapkeyData.state & Qt::ControlButton){ | ||
238 | if(m->ctrl_unicode == m_MapkeyData.ascii){ | ||
239 | found = true; | ||
240 | break; | ||
241 | } | ||
242 | } else if(m_MapkeyData.state & Qt::ShiftButton){ | ||
243 | if(m->shift_unicode == m_MapkeyData.ascii){ | ||
244 | found = true; | ||
245 | break; | ||
246 | } | ||
247 | } else { | ||
248 | if(m->unicode == m_MapkeyData.ascii){ | ||
249 | found = true; | ||
250 | break; | ||
251 | } | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | if(found == false){ | ||
256 | if(m_MapkeyData.text[0].isPrint()){ | ||
257 | line = "<map_unicode"; | ||
258 | if(m_MapkeyData.state & Qt::ControlButton){ | ||
259 | line.append(" ctrl_unicode=\""); | ||
260 | } else if(m_MapkeyData.state & Qt::ShiftButton){ | ||
261 | line.append(" shift_unicode=\""); | ||
262 | } else { | ||
263 | line.append(" unicode=\""); | ||
264 | } | ||
265 | line.append(m_MapkeyData.text); | ||
266 | line.append("\"/>"); | ||
267 | mleDefine->append(line); | ||
268 | } else { | ||
269 | mleDefine->clear(); | ||
270 | mleDefine->append("Not Support"); | ||
271 | return; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | /* close tag */ | ||
276 | line = "</define>"; | ||
277 | mleDefine->append(line); | ||
278 | } | ||
279 | |||
280 | void KHCWidget::onClick_Copy() | ||
281 | { | ||
282 | mleDefine->selectAll(); | ||
283 | mleDefine->copy(); | ||
284 | mleDefine->deselect(); | ||
285 | } | ||
286 | |||
287 | void KHCWidget::onClick_Ctrl() | ||
288 | { | ||
289 | if(m_isEnable){ | ||
290 | QCopEnvelope e("QPE/KeyHelper", "disable()"); | ||
291 | btnCtrl->setText(tr("Enable")); | ||
292 | //btnCtrl->update(); | ||
293 | } else { | ||
294 | QCopEnvelope e("QPE/KeyHelper", "enable()"); | ||
295 | btnCtrl->setText(tr("Disable")); | ||
296 | //btnCtrl->update(); | ||
297 | } | ||
298 | m_isEnable = !m_isEnable; | ||
299 | } | ||
300 | |||
301 | void KHCWidget::closeEvent(QCloseEvent* ce) | ||
302 | { | ||
303 | qDebug("closeEvent()"); | ||
304 | QCopEnvelope e("QPE/KeyHelper", "enable()"); | ||
305 | ce->accept(); | ||
306 | } | ||
307 | |||
diff --git a/noncore/applets/keyhelper/keyhelperconf/KHCWidget.h b/noncore/applets/keyhelper/keyhelperconf/KHCWidget.h new file mode 100644 index 0000000..08b29b3 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/KHCWidget.h | |||
@@ -0,0 +1,68 @@ | |||
1 | #ifndef _KHC_WIDGET_H_ | ||
2 | #define _KHC_WIDGET_H_ | ||
3 | |||
4 | #include <stdlib.h> | ||
5 | |||
6 | #include <qlabel.h> | ||
7 | #include <qpushbutton.h> | ||
8 | #include <qlineedit.h> | ||
9 | #include <qmultilineedit.h> | ||
10 | #include <qgroupbox.h> | ||
11 | #include <qcheckbox.h> | ||
12 | #include <qlayout.h> | ||
13 | |||
14 | #include <qwindowsystem_qws.h> | ||
15 | |||
16 | #include <qpe/qcopenvelope_qws.h> | ||
17 | |||
18 | #include "KHCWidgetBase.h" | ||
19 | #include "KeyNames.h" | ||
20 | |||
21 | struct KeyData | ||
22 | { | ||
23 | KeyData(){ | ||
24 | key = 0; | ||
25 | state = 0; | ||
26 | ascii = 0; | ||
27 | } | ||
28 | void setData(QKeyEvent* ke) { | ||
29 | key = ke->key(); | ||
30 | state = ke->state(); | ||
31 | ascii = ke->ascii(); | ||
32 | text = ke->text(); | ||
33 | } | ||
34 | int key; | ||
35 | int state; | ||
36 | int ascii; | ||
37 | QString text; | ||
38 | }; | ||
39 | |||
40 | class KHCWidget : public KHCWidgetBase | ||
41 | { | ||
42 | Q_OBJECT | ||
43 | public: | ||
44 | KHCWidget(QWidget* parent=0, const char* name=0, WFlags fl=0); | ||
45 | virtual ~KHCWidget(); | ||
46 | |||
47 | protected: | ||
48 | void closeEvent(QCloseEvent* ce); | ||
49 | |||
50 | private: | ||
51 | void setLayout(); | ||
52 | void setHandler(); | ||
53 | |||
54 | void onPress_Org(QKeyEvent* ke); | ||
55 | void onPress_Map(QKeyEvent* ke); | ||
56 | |||
57 | bool eventFilter(QObject* o, QEvent* e); | ||
58 | |||
59 | bool m_isEnable; | ||
60 | KeyData m_OrgkeyData; | ||
61 | KeyData m_MapkeyData; | ||
62 | private slots: | ||
63 | void onClick_Gen(); | ||
64 | void onClick_Copy(); | ||
65 | void onClick_Ctrl(); | ||
66 | }; | ||
67 | |||
68 | #endif /* _KHC_WIDGET_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperconf/KHCWidgetBase.cpp b/noncore/applets/keyhelper/keyhelperconf/KHCWidgetBase.cpp new file mode 100644 index 0000000..16841f1 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/KHCWidgetBase.cpp | |||
@@ -0,0 +1,162 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form implementation generated from reading ui file 'KHCWidgetBase.ui' | ||
3 | ** | ||
4 | ** Created: Mon Feb 28 09:58:22 2005 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #include "KHCWidgetBase.h" | ||
10 | |||
11 | #include <qcheckbox.h> | ||
12 | #include <qlabel.h> | ||
13 | #include <qlineedit.h> | ||
14 | #include <qmultilineedit.h> | ||
15 | #include <qpushbutton.h> | ||
16 | #include <qlayout.h> | ||
17 | #include <qvariant.h> | ||
18 | #include <qtooltip.h> | ||
19 | #include <qwhatsthis.h> | ||
20 | |||
21 | /* | ||
22 | * Constructs a KHCWidgetBase which is a child of 'parent', with the | ||
23 | * name 'name' and widget flags set to 'f' | ||
24 | */ | ||
25 | KHCWidgetBase::KHCWidgetBase( QWidget* parent, const char* name, WFlags fl ) | ||
26 | : QWidget( parent, name, fl ) | ||
27 | { | ||
28 | if ( !name ) | ||
29 | setName( "KHCWidgetBase" ); | ||
30 | resize( 431, 388 ); | ||
31 | setCaption( tr( "KeyHelperConf" ) ); | ||
32 | |||
33 | btnCtrl = new QPushButton( this, "btnCtrl" ); | ||
34 | btnCtrl->setGeometry( QRect( 280, 150, 121, 31 ) ); | ||
35 | btnCtrl->setText( tr( "Disable" ) ); | ||
36 | |||
37 | btnGen = new QPushButton( this, "btnGen" ); | ||
38 | btnGen->setGeometry( QRect( 10, 150, 110, 31 ) ); | ||
39 | btnGen->setText( tr( "Generate" ) ); | ||
40 | |||
41 | btnCopy = new QPushButton( this, "btnCopy" ); | ||
42 | btnCopy->setGeometry( QRect( 140, 150, 121, 31 ) ); | ||
43 | btnCopy->setText( tr( "Copy" ) ); | ||
44 | |||
45 | lblOrgK = new QLabel( this, "lblOrgK" ); | ||
46 | lblOrgK->setGeometry( QRect( 20, 50, 50, 20 ) ); | ||
47 | lblOrgK->setText( tr( "K" ) ); | ||
48 | |||
49 | lblMapK = new QLabel( this, "lblMapK" ); | ||
50 | lblMapK->setGeometry( QRect( 20, 120, 20, 20 ) ); | ||
51 | lblMapK->setText( tr( "K" ) ); | ||
52 | |||
53 | lblMapKeycode = new QLabel( this, "lblMapKeycode" ); | ||
54 | lblMapKeycode->setGeometry( QRect( 40, 120, 80, 21 ) ); | ||
55 | lblMapKeycode->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, lblMapKeycode->sizePolicy().hasHeightForWidth() ) ); | ||
56 | lblMapKeycode->setFrameShape( QLabel::Panel ); | ||
57 | lblMapKeycode->setFrameShadow( QLabel::Sunken ); | ||
58 | lblMapKeycode->setText( tr( "keycode" ) ); | ||
59 | |||
60 | txtMapKey = new QLineEdit( this, "txtMapKey" ); | ||
61 | txtMapKey->setGeometry( QRect( 200, 80, 200, 22 ) ); | ||
62 | |||
63 | txtOrgKey = new QLineEdit( this, "txtOrgKey" ); | ||
64 | txtOrgKey->setGeometry( QRect( 190, 10, 200, 22 ) ); | ||
65 | |||
66 | lblOriginal = new QLabel( this, "lblOriginal" ); | ||
67 | lblOriginal->setGeometry( QRect( 10, 10, 120, 31 ) ); | ||
68 | lblOriginal->setFrameShape( QLabel::Box ); | ||
69 | lblOriginal->setFrameShadow( QLabel::Raised ); | ||
70 | lblOriginal->setText( tr( "Original Key" ) ); | ||
71 | |||
72 | lblMapping = new QLabel( this, "lblMapping" ); | ||
73 | lblMapping->setGeometry( QRect( 10, 80, 120, 21 ) ); | ||
74 | lblMapping->setFrameShape( QLabel::Box ); | ||
75 | lblMapping->setFrameShadow( QLabel::Raised ); | ||
76 | lblMapping->setText( tr( "Mapping Key" ) ); | ||
77 | |||
78 | mleDefine = new QMultiLineEdit( this, "mleDefine" ); | ||
79 | mleDefine->setGeometry( QRect( 10, 200, 391, 110 ) ); | ||
80 | mleDefine->setReadOnly( TRUE ); | ||
81 | |||
82 | lblOrgKeycode = new QLabel( this, "lblOrgKeycode" ); | ||
83 | lblOrgKeycode->setGeometry( QRect( 50, 50, 70, 21 ) ); | ||
84 | lblOrgKeycode->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, lblOrgKeycode->sizePolicy().hasHeightForWidth() ) ); | ||
85 | lblOrgKeycode->setFrameShape( QLabel::Panel ); | ||
86 | lblOrgKeycode->setFrameShadow( QLabel::Sunken ); | ||
87 | lblOrgKeycode->setText( tr( "keycode" ) ); | ||
88 | |||
89 | lblOrgU = new QLabel( this, "lblOrgU" ); | ||
90 | lblOrgU->setGeometry( QRect( 130, 50, 20, 21 ) ); | ||
91 | lblOrgU->setText( tr( "U" ) ); | ||
92 | |||
93 | lblOrgUnicode = new QLabel( this, "lblOrgUnicode" ); | ||
94 | lblOrgUnicode->setGeometry( QRect( 150, 50, 80, 21 ) ); | ||
95 | lblOrgUnicode->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, lblOrgUnicode->sizePolicy().hasHeightForWidth() ) ); | ||
96 | lblOrgUnicode->setFrameShape( QLabel::Panel ); | ||
97 | lblOrgUnicode->setFrameShadow( QLabel::Sunken ); | ||
98 | lblOrgUnicode->setText( tr( "unicode" ) ); | ||
99 | |||
100 | lblMapU = new QLabel( this, "lblMapU" ); | ||
101 | lblMapU->setGeometry( QRect( 130, 120, 20, 21 ) ); | ||
102 | lblMapU->setText( tr( "U" ) ); | ||
103 | |||
104 | lblMapUnicode = new QLabel( this, "lblMapUnicode" ); | ||
105 | lblMapUnicode->setGeometry( QRect( 150, 120, 80, 21 ) ); | ||
106 | lblMapUnicode->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)1, lblMapUnicode->sizePolicy().hasHeightForWidth() ) ); | ||
107 | lblMapUnicode->setFrameShape( QLabel::Panel ); | ||
108 | lblMapUnicode->setFrameShadow( QLabel::Sunken ); | ||
109 | lblMapUnicode->setText( tr( "unicode" ) ); | ||
110 | |||
111 | chkMapShift = new QCheckBox( this, "chkMapShift" ); | ||
112 | chkMapShift->setGeometry( QRect( 260, 120, 33, 19 ) ); | ||
113 | chkMapShift->setText( tr( "S" ) ); | ||
114 | chkMapShift->setAutoResize( TRUE ); | ||
115 | |||
116 | chkMapCtrl = new QCheckBox( this, "chkMapCtrl" ); | ||
117 | chkMapCtrl->setGeometry( QRect( 310, 120, 34, 19 ) ); | ||
118 | chkMapCtrl->setText( tr( "C" ) ); | ||
119 | chkMapCtrl->setAutoResize( TRUE ); | ||
120 | |||
121 | chkMapAlt = new QCheckBox( this, "chkMapAlt" ); | ||
122 | chkMapAlt->setGeometry( QRect( 360, 120, 34, 19 ) ); | ||
123 | chkMapAlt->setText( tr( "A" ) ); | ||
124 | chkMapAlt->setAutoResize( TRUE ); | ||
125 | |||
126 | chkOrgShift = new QCheckBox( this, "chkOrgShift" ); | ||
127 | chkOrgShift->setGeometry( QRect( 250, 50, 33, 19 ) ); | ||
128 | chkOrgShift->setText( tr( "S" ) ); | ||
129 | chkOrgShift->setAutoResize( TRUE ); | ||
130 | |||
131 | chkOrgCtrl = new QCheckBox( this, "chkOrgCtrl" ); | ||
132 | chkOrgCtrl->setGeometry( QRect( 300, 50, 34, 19 ) ); | ||
133 | chkOrgCtrl->setText( tr( "C" ) ); | ||
134 | chkOrgCtrl->setAutoResize( TRUE ); | ||
135 | |||
136 | chkOrgAlt = new QCheckBox( this, "chkOrgAlt" ); | ||
137 | chkOrgAlt->setGeometry( QRect( 350, 50, 34, 19 ) ); | ||
138 | chkOrgAlt->setText( tr( "A" ) ); | ||
139 | chkOrgAlt->setAutoResize( TRUE ); | ||
140 | |||
141 | // tab order | ||
142 | setTabOrder( txtOrgKey, chkOrgShift ); | ||
143 | setTabOrder( chkOrgShift, chkOrgCtrl ); | ||
144 | setTabOrder( chkOrgCtrl, chkOrgAlt ); | ||
145 | setTabOrder( chkOrgAlt, txtMapKey ); | ||
146 | setTabOrder( txtMapKey, chkMapShift ); | ||
147 | setTabOrder( chkMapShift, chkMapCtrl ); | ||
148 | setTabOrder( chkMapCtrl, chkMapAlt ); | ||
149 | setTabOrder( chkMapAlt, btnGen ); | ||
150 | setTabOrder( btnGen, btnCopy ); | ||
151 | setTabOrder( btnCopy, btnCtrl ); | ||
152 | setTabOrder( btnCtrl, mleDefine ); | ||
153 | } | ||
154 | |||
155 | /* | ||
156 | * Destroys the object and frees any allocated resources | ||
157 | */ | ||
158 | KHCWidgetBase::~KHCWidgetBase() | ||
159 | { | ||
160 | // no need to delete child widgets, Qt does it all for us | ||
161 | } | ||
162 | |||
diff --git a/noncore/applets/keyhelper/keyhelperconf/KHCWidgetBase.h b/noncore/applets/keyhelper/keyhelperconf/KHCWidgetBase.h new file mode 100644 index 0000000..8193b61 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/KHCWidgetBase.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form interface generated from reading ui file 'KHCWidgetBase.ui' | ||
3 | ** | ||
4 | ** Created: Mon Feb 28 09:54:07 2005 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #ifndef KHCWIDGETBASE_H | ||
10 | #define KHCWIDGETBASE_H | ||
11 | |||
12 | #include <qvariant.h> | ||
13 | #include <qwidget.h> | ||
14 | class QVBoxLayout; | ||
15 | class QHBoxLayout; | ||
16 | class QGridLayout; | ||
17 | class QCheckBox; | ||
18 | class QLabel; | ||
19 | class QLineEdit; | ||
20 | class QMultiLineEdit; | ||
21 | class QPushButton; | ||
22 | |||
23 | class KHCWidgetBase : public QWidget | ||
24 | { | ||
25 | Q_OBJECT | ||
26 | |||
27 | public: | ||
28 | KHCWidgetBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | ||
29 | ~KHCWidgetBase(); | ||
30 | |||
31 | QPushButton* btnCtrl; | ||
32 | QPushButton* btnGen; | ||
33 | QPushButton* btnCopy; | ||
34 | QLabel* lblOrgK; | ||
35 | QLabel* lblMapK; | ||
36 | QLabel* lblMapKeycode; | ||
37 | QLineEdit* txtMapKey; | ||
38 | QLineEdit* txtOrgKey; | ||
39 | QLabel* lblOriginal; | ||
40 | QLabel* lblMapping; | ||
41 | QMultiLineEdit* mleDefine; | ||
42 | QLabel* lblOrgKeycode; | ||
43 | QLabel* lblOrgU; | ||
44 | QLabel* lblOrgUnicode; | ||
45 | QLabel* lblMapU; | ||
46 | QLabel* lblMapUnicode; | ||
47 | QCheckBox* chkMapShift; | ||
48 | QCheckBox* chkMapCtrl; | ||
49 | QCheckBox* chkMapAlt; | ||
50 | QCheckBox* chkOrgShift; | ||
51 | QCheckBox* chkOrgCtrl; | ||
52 | QCheckBox* chkOrgAlt; | ||
53 | |||
54 | }; | ||
55 | |||
56 | #endif // KHCWIDGETBASE_H | ||
diff --git a/noncore/applets/keyhelper/keyhelperconf/KHCWidgetBase.ui b/noncore/applets/keyhelper/keyhelperconf/KHCWidgetBase.ui new file mode 100644 index 0000000..2be0772 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/KHCWidgetBase.ui | |||
@@ -0,0 +1,569 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>KHCWidgetBase</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>KHCWidgetBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>431</width> | ||
15 | <height>388</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>KeyHelperConf</string> | ||
21 | </property> | ||
22 | <widget> | ||
23 | <class>QPushButton</class> | ||
24 | <property stdset="1"> | ||
25 | <name>name</name> | ||
26 | <cstring>btnCtrl</cstring> | ||
27 | </property> | ||
28 | <property stdset="1"> | ||
29 | <name>geometry</name> | ||
30 | <rect> | ||
31 | <x>280</x> | ||
32 | <y>150</y> | ||
33 | <width>121</width> | ||
34 | <height>31</height> | ||
35 | </rect> | ||
36 | </property> | ||
37 | <property stdset="1"> | ||
38 | <name>text</name> | ||
39 | <string>Disable</string> | ||
40 | </property> | ||
41 | </widget> | ||
42 | <widget> | ||
43 | <class>QPushButton</class> | ||
44 | <property stdset="1"> | ||
45 | <name>name</name> | ||
46 | <cstring>btnGen</cstring> | ||
47 | </property> | ||
48 | <property stdset="1"> | ||
49 | <name>geometry</name> | ||
50 | <rect> | ||
51 | <x>10</x> | ||
52 | <y>150</y> | ||
53 | <width>110</width> | ||
54 | <height>31</height> | ||
55 | </rect> | ||
56 | </property> | ||
57 | <property stdset="1"> | ||
58 | <name>text</name> | ||
59 | <string>Generate</string> | ||
60 | </property> | ||
61 | </widget> | ||
62 | <widget> | ||
63 | <class>QPushButton</class> | ||
64 | <property stdset="1"> | ||
65 | <name>name</name> | ||
66 | <cstring>btnCopy</cstring> | ||
67 | </property> | ||
68 | <property stdset="1"> | ||
69 | <name>geometry</name> | ||
70 | <rect> | ||
71 | <x>140</x> | ||
72 | <y>150</y> | ||
73 | <width>121</width> | ||
74 | <height>31</height> | ||
75 | </rect> | ||
76 | </property> | ||
77 | <property stdset="1"> | ||
78 | <name>text</name> | ||
79 | <string>Copy</string> | ||
80 | </property> | ||
81 | </widget> | ||
82 | <widget> | ||
83 | <class>QLabel</class> | ||
84 | <property stdset="1"> | ||
85 | <name>name</name> | ||
86 | <cstring>lblOrgK</cstring> | ||
87 | </property> | ||
88 | <property stdset="1"> | ||
89 | <name>geometry</name> | ||
90 | <rect> | ||
91 | <x>20</x> | ||
92 | <y>50</y> | ||
93 | <width>50</width> | ||
94 | <height>20</height> | ||
95 | </rect> | ||
96 | </property> | ||
97 | <property stdset="1"> | ||
98 | <name>text</name> | ||
99 | <string>K</string> | ||
100 | </property> | ||
101 | </widget> | ||
102 | <widget> | ||
103 | <class>QLabel</class> | ||
104 | <property stdset="1"> | ||
105 | <name>name</name> | ||
106 | <cstring>lblMapK</cstring> | ||
107 | </property> | ||
108 | <property stdset="1"> | ||
109 | <name>geometry</name> | ||
110 | <rect> | ||
111 | <x>20</x> | ||
112 | <y>120</y> | ||
113 | <width>20</width> | ||
114 | <height>20</height> | ||
115 | </rect> | ||
116 | </property> | ||
117 | <property stdset="1"> | ||
118 | <name>text</name> | ||
119 | <string>K</string> | ||
120 | </property> | ||
121 | </widget> | ||
122 | <widget> | ||
123 | <class>QLabel</class> | ||
124 | <property stdset="1"> | ||
125 | <name>name</name> | ||
126 | <cstring>lblMapKeycode</cstring> | ||
127 | </property> | ||
128 | <property stdset="1"> | ||
129 | <name>geometry</name> | ||
130 | <rect> | ||
131 | <x>40</x> | ||
132 | <y>120</y> | ||
133 | <width>80</width> | ||
134 | <height>21</height> | ||
135 | </rect> | ||
136 | </property> | ||
137 | <property stdset="1"> | ||
138 | <name>sizePolicy</name> | ||
139 | <sizepolicy> | ||
140 | <hsizetype>7</hsizetype> | ||
141 | <vsizetype>1</vsizetype> | ||
142 | </sizepolicy> | ||
143 | </property> | ||
144 | <property stdset="1"> | ||
145 | <name>frameShape</name> | ||
146 | <enum>Panel</enum> | ||
147 | </property> | ||
148 | <property stdset="1"> | ||
149 | <name>frameShadow</name> | ||
150 | <enum>Sunken</enum> | ||
151 | </property> | ||
152 | <property stdset="1"> | ||
153 | <name>text</name> | ||
154 | <string>keycode</string> | ||
155 | </property> | ||
156 | </widget> | ||
157 | <widget> | ||
158 | <class>QLineEdit</class> | ||
159 | <property stdset="1"> | ||
160 | <name>name</name> | ||
161 | <cstring>txtMapKey</cstring> | ||
162 | </property> | ||
163 | <property stdset="1"> | ||
164 | <name>geometry</name> | ||
165 | <rect> | ||
166 | <x>200</x> | ||
167 | <y>80</y> | ||
168 | <width>200</width> | ||
169 | <height>22</height> | ||
170 | </rect> | ||
171 | </property> | ||
172 | </widget> | ||
173 | <widget> | ||
174 | <class>QLineEdit</class> | ||
175 | <property stdset="1"> | ||
176 | <name>name</name> | ||
177 | <cstring>txtOrgKey</cstring> | ||
178 | </property> | ||
179 | <property stdset="1"> | ||
180 | <name>geometry</name> | ||
181 | <rect> | ||
182 | <x>190</x> | ||
183 | <y>10</y> | ||
184 | <width>200</width> | ||
185 | <height>22</height> | ||
186 | </rect> | ||
187 | </property> | ||
188 | </widget> | ||
189 | <widget> | ||
190 | <class>QLabel</class> | ||
191 | <property stdset="1"> | ||
192 | <name>name</name> | ||
193 | <cstring>lblOriginal</cstring> | ||
194 | </property> | ||
195 | <property stdset="1"> | ||
196 | <name>geometry</name> | ||
197 | <rect> | ||
198 | <x>10</x> | ||
199 | <y>10</y> | ||
200 | <width>120</width> | ||
201 | <height>31</height> | ||
202 | </rect> | ||
203 | </property> | ||
204 | <property stdset="1"> | ||
205 | <name>frameShape</name> | ||
206 | <enum>Box</enum> | ||
207 | </property> | ||
208 | <property stdset="1"> | ||
209 | <name>frameShadow</name> | ||
210 | <enum>Raised</enum> | ||
211 | </property> | ||
212 | <property stdset="1"> | ||
213 | <name>text</name> | ||
214 | <string>Original Key</string> | ||
215 | </property> | ||
216 | </widget> | ||
217 | <widget> | ||
218 | <class>QLabel</class> | ||
219 | <property stdset="1"> | ||
220 | <name>name</name> | ||
221 | <cstring>lblMapping</cstring> | ||
222 | </property> | ||
223 | <property stdset="1"> | ||
224 | <name>geometry</name> | ||
225 | <rect> | ||
226 | <x>10</x> | ||
227 | <y>80</y> | ||
228 | <width>120</width> | ||
229 | <height>21</height> | ||
230 | </rect> | ||
231 | </property> | ||
232 | <property stdset="1"> | ||
233 | <name>frameShape</name> | ||
234 | <enum>Box</enum> | ||
235 | </property> | ||
236 | <property stdset="1"> | ||
237 | <name>frameShadow</name> | ||
238 | <enum>Raised</enum> | ||
239 | </property> | ||
240 | <property stdset="1"> | ||
241 | <name>text</name> | ||
242 | <string>Mapping Key</string> | ||
243 | </property> | ||
244 | </widget> | ||
245 | <widget> | ||
246 | <class>QMultiLineEdit</class> | ||
247 | <property stdset="1"> | ||
248 | <name>name</name> | ||
249 | <cstring>mleDefine</cstring> | ||
250 | </property> | ||
251 | <property stdset="1"> | ||
252 | <name>geometry</name> | ||
253 | <rect> | ||
254 | <x>10</x> | ||
255 | <y>200</y> | ||
256 | <width>391</width> | ||
257 | <height>110</height> | ||
258 | </rect> | ||
259 | </property> | ||
260 | <property stdset="1"> | ||
261 | <name>readOnly</name> | ||
262 | <bool>true</bool> | ||
263 | </property> | ||
264 | </widget> | ||
265 | <widget> | ||
266 | <class>QLabel</class> | ||
267 | <property stdset="1"> | ||
268 | <name>name</name> | ||
269 | <cstring>lblOrgKeycode</cstring> | ||
270 | </property> | ||
271 | <property stdset="1"> | ||
272 | <name>geometry</name> | ||
273 | <rect> | ||
274 | <x>50</x> | ||
275 | <y>50</y> | ||
276 | <width>70</width> | ||
277 | <height>21</height> | ||
278 | </rect> | ||
279 | </property> | ||
280 | <property stdset="1"> | ||
281 | <name>sizePolicy</name> | ||
282 | <sizepolicy> | ||
283 | <hsizetype>7</hsizetype> | ||
284 | <vsizetype>1</vsizetype> | ||
285 | </sizepolicy> | ||
286 | </property> | ||
287 | <property stdset="1"> | ||
288 | <name>frameShape</name> | ||
289 | <enum>Panel</enum> | ||
290 | </property> | ||
291 | <property stdset="1"> | ||
292 | <name>frameShadow</name> | ||
293 | <enum>Sunken</enum> | ||
294 | </property> | ||
295 | <property stdset="1"> | ||
296 | <name>text</name> | ||
297 | <string>keycode</string> | ||
298 | </property> | ||
299 | </widget> | ||
300 | <widget> | ||
301 | <class>QLabel</class> | ||
302 | <property stdset="1"> | ||
303 | <name>name</name> | ||
304 | <cstring>lblOrgU</cstring> | ||
305 | </property> | ||
306 | <property stdset="1"> | ||
307 | <name>geometry</name> | ||
308 | <rect> | ||
309 | <x>130</x> | ||
310 | <y>50</y> | ||
311 | <width>20</width> | ||
312 | <height>21</height> | ||
313 | </rect> | ||
314 | </property> | ||
315 | <property stdset="1"> | ||
316 | <name>text</name> | ||
317 | <string>U</string> | ||
318 | </property> | ||
319 | </widget> | ||
320 | <widget> | ||
321 | <class>QLabel</class> | ||
322 | <property stdset="1"> | ||
323 | <name>name</name> | ||
324 | <cstring>lblOrgUnicode</cstring> | ||
325 | </property> | ||
326 | <property stdset="1"> | ||
327 | <name>geometry</name> | ||
328 | <rect> | ||
329 | <x>150</x> | ||
330 | <y>50</y> | ||
331 | <width>80</width> | ||
332 | <height>21</height> | ||
333 | </rect> | ||
334 | </property> | ||
335 | <property stdset="1"> | ||
336 | <name>sizePolicy</name> | ||
337 | <sizepolicy> | ||
338 | <hsizetype>7</hsizetype> | ||
339 | <vsizetype>1</vsizetype> | ||
340 | </sizepolicy> | ||
341 | </property> | ||
342 | <property stdset="1"> | ||
343 | <name>frameShape</name> | ||
344 | <enum>Panel</enum> | ||
345 | </property> | ||
346 | <property stdset="1"> | ||
347 | <name>frameShadow</name> | ||
348 | <enum>Sunken</enum> | ||
349 | </property> | ||
350 | <property stdset="1"> | ||
351 | <name>text</name> | ||
352 | <string>unicode</string> | ||
353 | </property> | ||
354 | </widget> | ||
355 | <widget> | ||
356 | <class>QLabel</class> | ||
357 | <property stdset="1"> | ||
358 | <name>name</name> | ||
359 | <cstring>lblMapU</cstring> | ||
360 | </property> | ||
361 | <property stdset="1"> | ||
362 | <name>geometry</name> | ||
363 | <rect> | ||
364 | <x>130</x> | ||
365 | <y>120</y> | ||
366 | <width>20</width> | ||
367 | <height>21</height> | ||
368 | </rect> | ||
369 | </property> | ||
370 | <property stdset="1"> | ||
371 | <name>text</name> | ||
372 | <string>U</string> | ||
373 | </property> | ||
374 | </widget> | ||
375 | <widget> | ||
376 | <class>QLabel</class> | ||
377 | <property stdset="1"> | ||
378 | <name>name</name> | ||
379 | <cstring>lblMapUnicode</cstring> | ||
380 | </property> | ||
381 | <property stdset="1"> | ||
382 | <name>geometry</name> | ||
383 | <rect> | ||
384 | <x>150</x> | ||
385 | <y>120</y> | ||
386 | <width>80</width> | ||
387 | <height>21</height> | ||
388 | </rect> | ||
389 | </property> | ||
390 | <property stdset="1"> | ||
391 | <name>sizePolicy</name> | ||
392 | <sizepolicy> | ||
393 | <hsizetype>7</hsizetype> | ||
394 | <vsizetype>1</vsizetype> | ||
395 | </sizepolicy> | ||
396 | </property> | ||
397 | <property stdset="1"> | ||
398 | <name>frameShape</name> | ||
399 | <enum>Panel</enum> | ||
400 | </property> | ||
401 | <property stdset="1"> | ||
402 | <name>frameShadow</name> | ||
403 | <enum>Sunken</enum> | ||
404 | </property> | ||
405 | <property stdset="1"> | ||
406 | <name>text</name> | ||
407 | <string>unicode</string> | ||
408 | </property> | ||
409 | </widget> | ||
410 | <widget> | ||
411 | <class>QCheckBox</class> | ||
412 | <property stdset="1"> | ||
413 | <name>name</name> | ||
414 | <cstring>chkMapShift</cstring> | ||
415 | </property> | ||
416 | <property stdset="1"> | ||
417 | <name>geometry</name> | ||
418 | <rect> | ||
419 | <x>260</x> | ||
420 | <y>120</y> | ||
421 | <width>33</width> | ||
422 | <height>19</height> | ||
423 | </rect> | ||
424 | </property> | ||
425 | <property stdset="1"> | ||
426 | <name>text</name> | ||
427 | <string>S</string> | ||
428 | </property> | ||
429 | <property stdset="1"> | ||
430 | <name>autoResize</name> | ||
431 | <bool>true</bool> | ||
432 | </property> | ||
433 | </widget> | ||
434 | <widget> | ||
435 | <class>QCheckBox</class> | ||
436 | <property stdset="1"> | ||
437 | <name>name</name> | ||
438 | <cstring>chkMapCtrl</cstring> | ||
439 | </property> | ||
440 | <property stdset="1"> | ||
441 | <name>geometry</name> | ||
442 | <rect> | ||
443 | <x>310</x> | ||
444 | <y>120</y> | ||
445 | <width>34</width> | ||
446 | <height>19</height> | ||
447 | </rect> | ||
448 | </property> | ||
449 | <property stdset="1"> | ||
450 | <name>text</name> | ||
451 | <string>C</string> | ||
452 | </property> | ||
453 | <property stdset="1"> | ||
454 | <name>autoResize</name> | ||
455 | <bool>true</bool> | ||
456 | </property> | ||
457 | </widget> | ||
458 | <widget> | ||
459 | <class>QCheckBox</class> | ||
460 | <property stdset="1"> | ||
461 | <name>name</name> | ||
462 | <cstring>chkMapAlt</cstring> | ||
463 | </property> | ||
464 | <property stdset="1"> | ||
465 | <name>geometry</name> | ||
466 | <rect> | ||
467 | <x>360</x> | ||
468 | <y>120</y> | ||
469 | <width>34</width> | ||
470 | <height>19</height> | ||
471 | </rect> | ||
472 | </property> | ||
473 | <property stdset="1"> | ||
474 | <name>text</name> | ||
475 | <string>A</string> | ||
476 | </property> | ||
477 | <property stdset="1"> | ||
478 | <name>autoResize</name> | ||
479 | <bool>true</bool> | ||
480 | </property> | ||
481 | </widget> | ||
482 | <widget> | ||
483 | <class>QCheckBox</class> | ||
484 | <property stdset="1"> | ||
485 | <name>name</name> | ||
486 | <cstring>chkOrgShift</cstring> | ||
487 | </property> | ||
488 | <property stdset="1"> | ||
489 | <name>geometry</name> | ||
490 | <rect> | ||
491 | <x>250</x> | ||
492 | <y>50</y> | ||
493 | <width>33</width> | ||
494 | <height>19</height> | ||
495 | </rect> | ||
496 | </property> | ||
497 | <property stdset="1"> | ||
498 | <name>text</name> | ||
499 | <string>S</string> | ||
500 | </property> | ||
501 | <property stdset="1"> | ||
502 | <name>autoResize</name> | ||
503 | <bool>true</bool> | ||
504 | </property> | ||
505 | </widget> | ||
506 | <widget> | ||
507 | <class>QCheckBox</class> | ||
508 | <property stdset="1"> | ||
509 | <name>name</name> | ||
510 | <cstring>chkOrgCtrl</cstring> | ||
511 | </property> | ||
512 | <property stdset="1"> | ||
513 | <name>geometry</name> | ||
514 | <rect> | ||
515 | <x>300</x> | ||
516 | <y>50</y> | ||
517 | <width>34</width> | ||
518 | <height>19</height> | ||
519 | </rect> | ||
520 | </property> | ||
521 | <property stdset="1"> | ||
522 | <name>text</name> | ||
523 | <string>C</string> | ||
524 | </property> | ||
525 | <property stdset="1"> | ||
526 | <name>autoResize</name> | ||
527 | <bool>true</bool> | ||
528 | </property> | ||
529 | </widget> | ||
530 | <widget> | ||
531 | <class>QCheckBox</class> | ||
532 | <property stdset="1"> | ||
533 | <name>name</name> | ||
534 | <cstring>chkOrgAlt</cstring> | ||
535 | </property> | ||
536 | <property stdset="1"> | ||
537 | <name>geometry</name> | ||
538 | <rect> | ||
539 | <x>350</x> | ||
540 | <y>50</y> | ||
541 | <width>34</width> | ||
542 | <height>19</height> | ||
543 | </rect> | ||
544 | </property> | ||
545 | <property stdset="1"> | ||
546 | <name>text</name> | ||
547 | <string>A</string> | ||
548 | </property> | ||
549 | <property stdset="1"> | ||
550 | <name>autoResize</name> | ||
551 | <bool>true</bool> | ||
552 | </property> | ||
553 | </widget> | ||
554 | </widget> | ||
555 | <tabstops> | ||
556 | <tabstop>txtOrgKey</tabstop> | ||
557 | <tabstop>chkOrgShift</tabstop> | ||
558 | <tabstop>chkOrgCtrl</tabstop> | ||
559 | <tabstop>chkOrgAlt</tabstop> | ||
560 | <tabstop>txtMapKey</tabstop> | ||
561 | <tabstop>chkMapShift</tabstop> | ||
562 | <tabstop>chkMapCtrl</tabstop> | ||
563 | <tabstop>chkMapAlt</tabstop> | ||
564 | <tabstop>btnGen</tabstop> | ||
565 | <tabstop>btnCopy</tabstop> | ||
566 | <tabstop>btnCtrl</tabstop> | ||
567 | <tabstop>mleDefine</tabstop> | ||
568 | </tabstops> | ||
569 | </UI> | ||
diff --git a/noncore/applets/keyhelper/keyhelperconf/KeyNames.cpp b/noncore/applets/keyhelper/keyhelperconf/KeyNames.cpp new file mode 100644 index 0000000..e3d90b4 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/KeyNames.cpp | |||
@@ -0,0 +1,274 @@ | |||
1 | #include "KeyNames.h" | ||
2 | |||
3 | QMap<QString, int> KeyNames::codemap; | ||
4 | QMap<int, QString> KeyNames::namemap; | ||
5 | |||
6 | static struct { | ||
7 | int code; | ||
8 | char* name; | ||
9 | } stKeyNames[] = { | ||
10 | {Qt::Key_Escape, "Escape"}, | ||
11 | {Qt::Key_Tab, "Tab"}, | ||
12 | {Qt::Key_Backtab, "Backtab"}, | ||
13 | {Qt::Key_BackTab, "BackTab"}, | ||
14 | {Qt::Key_Backtab, "Backtab"}, | ||
15 | {Qt::Key_Backspace, "Backspace"}, | ||
16 | {Qt::Key_BackSpace, "BackSpace"}, | ||
17 | {Qt::Key_Backspace, "Backspace"}, | ||
18 | {Qt::Key_Return, "Return"}, | ||
19 | {Qt::Key_Enter, "Enter"}, | ||
20 | {Qt::Key_Insert, "Insert"}, | ||
21 | {Qt::Key_Delete, "Delete"}, | ||
22 | {Qt::Key_Pause, "Pause"}, | ||
23 | {Qt::Key_Print, "Print"}, | ||
24 | {Qt::Key_SysReq, "SysReq"}, | ||
25 | {Qt::Key_Home, "Home"}, | ||
26 | {Qt::Key_End, "End"}, | ||
27 | {Qt::Key_Left, "Left"}, | ||
28 | {Qt::Key_Up, "Up"}, | ||
29 | {Qt::Key_Right, "Right"}, | ||
30 | {Qt::Key_Down, "Down"}, | ||
31 | {Qt::Key_Prior, "Prior"}, | ||
32 | {Qt::Key_PageUp, "PageUp"}, | ||
33 | {Qt::Key_Prior, "Prior"}, | ||
34 | {Qt::Key_Next, "Next"}, | ||
35 | {Qt::Key_PageDown, "PageDown"}, | ||
36 | {Qt::Key_Next, "Next"}, | ||
37 | {Qt::Key_Shift, "Shift"}, | ||
38 | {Qt::Key_Control, "Control"}, | ||
39 | {Qt::Key_Meta, "Meta"}, | ||
40 | {Qt::Key_Alt, "Alt"}, | ||
41 | {Qt::Key_CapsLock, "CapsLock"}, | ||
42 | {Qt::Key_NumLock, "NumLock"}, | ||
43 | {Qt::Key_ScrollLock, "ScrollLock"}, | ||
44 | {Qt::Key_F1, "F1"}, | ||
45 | {Qt::Key_F2, "F2"}, | ||
46 | {Qt::Key_F3, "F3"}, | ||
47 | {Qt::Key_F4, "F4"}, | ||
48 | {Qt::Key_F5, "F5"}, | ||
49 | {Qt::Key_F6, "F6"}, | ||
50 | {Qt::Key_F7, "F7"}, | ||
51 | {Qt::Key_F8, "F8"}, | ||
52 | {Qt::Key_F9, "F9"}, | ||
53 | {Qt::Key_F10, "F10"}, | ||
54 | {Qt::Key_F11, "F11"}, | ||
55 | {Qt::Key_F12, "F12"}, | ||
56 | {Qt::Key_F13, "F13"}, | ||
57 | {Qt::Key_F14, "F14"}, | ||
58 | {Qt::Key_F15, "F15"}, | ||
59 | {Qt::Key_F16, "F16"}, | ||
60 | {Qt::Key_F17, "F17"}, | ||
61 | {Qt::Key_F18, "F18"}, | ||
62 | {Qt::Key_F19, "F19"}, | ||
63 | {Qt::Key_F20, "F20"}, | ||
64 | {Qt::Key_F21, "F21"}, | ||
65 | {Qt::Key_F22, "F22"}, | ||
66 | {Qt::Key_F23, "F23"}, | ||
67 | {Qt::Key_F24, "F24"}, | ||
68 | {Qt::Key_F25, "F25"}, | ||
69 | {Qt::Key_F26, "F26"}, | ||
70 | {Qt::Key_F27, "F27"}, | ||
71 | {Qt::Key_F28, "F28"}, | ||
72 | {Qt::Key_F29, "F29"}, | ||
73 | {Qt::Key_F30, "F30"}, | ||
74 | {Qt::Key_F31, "F31"}, | ||
75 | {Qt::Key_F32, "F32"}, | ||
76 | {Qt::Key_F33, "F33"}, | ||
77 | {Qt::Key_F34, "F34"}, | ||
78 | {Qt::Key_F35, "F35"}, | ||
79 | {Qt::Key_Super_L, "Super_L"}, | ||
80 | {Qt::Key_Super_R, "Super_R"}, | ||
81 | {Qt::Key_Menu, "Menu"}, | ||
82 | {Qt::Key_Hyper_L, "Hyper_L"}, | ||
83 | {Qt::Key_Hyper_R, "Hyper_R"}, | ||
84 | {Qt::Key_Help, "Help"}, | ||
85 | {Qt::Key_Space, "Space"}, | ||
86 | {Qt::Key_Any, "Any"}, | ||
87 | {Qt::Key_Space, "Space"}, | ||
88 | {Qt::Key_Exclam, "Exclam"}, | ||
89 | {Qt::Key_QuoteDbl, "QuoteDbl"}, | ||
90 | {Qt::Key_NumberSign, "NumberSign"}, | ||
91 | {Qt::Key_Dollar, "Dollar"}, | ||
92 | {Qt::Key_Percent, "Percent"}, | ||
93 | {Qt::Key_Ampersand, "Ampersand"}, | ||
94 | {Qt::Key_Apostrophe, "Apostrophe"}, | ||
95 | {Qt::Key_ParenLeft, "ParenLeft"}, | ||
96 | {Qt::Key_ParenRight, "ParenRight"}, | ||
97 | {Qt::Key_Asterisk, "Asterisk"}, | ||
98 | {Qt::Key_Plus, "Plus"}, | ||
99 | {Qt::Key_Comma, "Comma"}, | ||
100 | {Qt::Key_Minus, "Minus"}, | ||
101 | {Qt::Key_Period, "Period"}, | ||
102 | {Qt::Key_Slash, "Slash"}, | ||
103 | {Qt::Key_0, "0"}, | ||
104 | {Qt::Key_1, "1"}, | ||
105 | {Qt::Key_2, "2"}, | ||
106 | {Qt::Key_3, "3"}, | ||
107 | {Qt::Key_4, "4"}, | ||
108 | {Qt::Key_5, "5"}, | ||
109 | {Qt::Key_6, "6"}, | ||
110 | {Qt::Key_7, "7"}, | ||
111 | {Qt::Key_8, "8"}, | ||
112 | {Qt::Key_9, "9"}, | ||
113 | {Qt::Key_Colon, "Colon"}, | ||
114 | {Qt::Key_Semicolon, "Semicolon"}, | ||
115 | {Qt::Key_Less, "Less"}, | ||
116 | {Qt::Key_Equal, "Equal"}, | ||
117 | {Qt::Key_Greater, "Greater"}, | ||
118 | {Qt::Key_Question, "Question"}, | ||
119 | {Qt::Key_At, "At"}, | ||
120 | {Qt::Key_A, "A"}, | ||
121 | {Qt::Key_B, "B"}, | ||
122 | {Qt::Key_C, "C"}, | ||
123 | {Qt::Key_D, "D"}, | ||
124 | {Qt::Key_E, "E"}, | ||
125 | {Qt::Key_F, "F"}, | ||
126 | {Qt::Key_G, "G"}, | ||
127 | {Qt::Key_H, "H"}, | ||
128 | {Qt::Key_I, "I"}, | ||
129 | {Qt::Key_J, "J"}, | ||
130 | {Qt::Key_K, "K"}, | ||
131 | {Qt::Key_L, "L"}, | ||
132 | {Qt::Key_M, "M"}, | ||
133 | {Qt::Key_N, "N"}, | ||
134 | {Qt::Key_O, "O"}, | ||
135 | {Qt::Key_P, "P"}, | ||
136 | {Qt::Key_Q, "Q"}, | ||
137 | {Qt::Key_R, "R"}, | ||
138 | {Qt::Key_S, "S"}, | ||
139 | {Qt::Key_T, "T"}, | ||
140 | {Qt::Key_U, "U"}, | ||
141 | {Qt::Key_V, "V"}, | ||
142 | {Qt::Key_W, "W"}, | ||
143 | {Qt::Key_X, "X"}, | ||
144 | {Qt::Key_Y, "Y"}, | ||
145 | {Qt::Key_Z, "Z"}, | ||
146 | {Qt::Key_BracketLeft, "BracketLeft"}, | ||
147 | {Qt::Key_Backslash, "Backslash"}, | ||
148 | {Qt::Key_BracketRight, "BracketRight"}, | ||
149 | {Qt::Key_AsciiCircum, "AsciiCircum"}, | ||
150 | {Qt::Key_Underscore, "Underscore"}, | ||
151 | {Qt::Key_QuoteLeft, "QuoteLeft"}, | ||
152 | {Qt::Key_BraceLeft, "BraceLeft"}, | ||
153 | {Qt::Key_Bar, "Bar"}, | ||
154 | {Qt::Key_BraceRight, "BraceRight"}, | ||
155 | {Qt::Key_AsciiTilde, "AsciiTilde"}, | ||
156 | {Qt::Key_nobreakspace, "nobreakspace"}, | ||
157 | {Qt::Key_exclamdown, "exclamdown"}, | ||
158 | {Qt::Key_cent, "cent"}, | ||
159 | {Qt::Key_sterling, "sterling"}, | ||
160 | {Qt::Key_currency, "currency"}, | ||
161 | {Qt::Key_yen, "yen"}, | ||
162 | {Qt::Key_brokenbar, "brokenbar"}, | ||
163 | {Qt::Key_section, "section"}, | ||
164 | {Qt::Key_diaeresis, "diaeresis"}, | ||
165 | {Qt::Key_copyright, "copyright"}, | ||
166 | {Qt::Key_ordfeminine, "ordfeminine"}, | ||
167 | {Qt::Key_guillemotleft, "guillemotleft"}, | ||
168 | {Qt::Key_notsign, "notsign"}, | ||
169 | {Qt::Key_hyphen, "hyphen"}, | ||
170 | {Qt::Key_registered, "registered"}, | ||
171 | {Qt::Key_macron, "macron"}, | ||
172 | {Qt::Key_degree, "degree"}, | ||
173 | {Qt::Key_plusminus, "plusminus"}, | ||
174 | {Qt::Key_twosuperior, "twosuperior"}, | ||
175 | {Qt::Key_threesuperior, "threesuperior"}, | ||
176 | {Qt::Key_acute, "acute"}, | ||
177 | {Qt::Key_mu, "mu"}, | ||
178 | {Qt::Key_paragraph, "paragraph"}, | ||
179 | {Qt::Key_periodcentered, "periodcentered"}, | ||
180 | {Qt::Key_cedilla, "cedilla"}, | ||
181 | {Qt::Key_onesuperior, "onesuperior"}, | ||
182 | {Qt::Key_masculine, "masculine"}, | ||
183 | {Qt::Key_guillemotright, "guillemotright"}, | ||
184 | {Qt::Key_onequarter, "onequarter"}, | ||
185 | {Qt::Key_onehalf, "onehalf"}, | ||
186 | {Qt::Key_threequarters, "threequarters"}, | ||
187 | {Qt::Key_questiondown, "questiondown"}, | ||
188 | {Qt::Key_Agrave, "Agrave"}, | ||
189 | {Qt::Key_Aacute, "Aacute"}, | ||
190 | {Qt::Key_Acircumflex, "Acircumflex"}, | ||
191 | {Qt::Key_Atilde, "Atilde"}, | ||
192 | {Qt::Key_Adiaeresis, "Adiaeresis"}, | ||
193 | {Qt::Key_Aring, "Aring"}, | ||
194 | {Qt::Key_AE, "AE"}, | ||
195 | {Qt::Key_Ccedilla, "Ccedilla"}, | ||
196 | {Qt::Key_Egrave, "Egrave"}, | ||
197 | {Qt::Key_Eacute, "Eacute"}, | ||
198 | {Qt::Key_Ecircumflex, "Ecircumflex"}, | ||
199 | {Qt::Key_Ediaeresis, "Ediaeresis"}, | ||
200 | {Qt::Key_Igrave, "Igrave"}, | ||
201 | {Qt::Key_Iacute, "Iacute"}, | ||
202 | {Qt::Key_Icircumflex, "Icircumflex"}, | ||
203 | {Qt::Key_Idiaeresis, "Idiaeresis"}, | ||
204 | {Qt::Key_ETH, "ETH"}, | ||
205 | {Qt::Key_Ntilde, "Ntilde"}, | ||
206 | {Qt::Key_Ograve, "Ograve"}, | ||
207 | {Qt::Key_Oacute, "Oacute"}, | ||
208 | {Qt::Key_Ocircumflex, "Ocircumflex"}, | ||
209 | {Qt::Key_Otilde, "Otilde"}, | ||
210 | {Qt::Key_Odiaeresis, "Odiaeresis"}, | ||
211 | {Qt::Key_multiply, "multiply"}, | ||
212 | {Qt::Key_Ooblique, "Ooblique"}, | ||
213 | {Qt::Key_Ugrave, "Ugrave"}, | ||
214 | {Qt::Key_Uacute, "Uacute"}, | ||
215 | {Qt::Key_Ucircumflex, "Ucircumflex"}, | ||
216 | {Qt::Key_Udiaeresis, "Udiaeresis"}, | ||
217 | {Qt::Key_Yacute, "Yacute"}, | ||
218 | {Qt::Key_THORN, "THORN"}, | ||
219 | {Qt::Key_ssharp, "ssharp"}, | ||
220 | {Qt::Key_agrave, "agrave"}, | ||
221 | {Qt::Key_aacute, "aacute"}, | ||
222 | {Qt::Key_acircumflex, "acircumflex"}, | ||
223 | {Qt::Key_atilde, "atilde"}, | ||
224 | {Qt::Key_adiaeresis, "adiaeresis"}, | ||
225 | {Qt::Key_aring, "aring"}, | ||
226 | {Qt::Key_ae, "ae"}, | ||
227 | {Qt::Key_ccedilla, "ccedilla"}, | ||
228 | {Qt::Key_egrave, "egrave"}, | ||
229 | {Qt::Key_eacute, "eacute"}, | ||
230 | {Qt::Key_ecircumflex, "ecircumflex"}, | ||
231 | {Qt::Key_ediaeresis, "ediaeresis"}, | ||
232 | {Qt::Key_igrave, "igrave"}, | ||
233 | {Qt::Key_iacute, "iacute"}, | ||
234 | {Qt::Key_icircumflex, "icircumflex"}, | ||
235 | {Qt::Key_idiaeresis, "idiaeresis"}, | ||
236 | {Qt::Key_eth, "eth"}, | ||
237 | {Qt::Key_ntilde, "ntilde"}, | ||
238 | {Qt::Key_ograve, "ograve"}, | ||
239 | {Qt::Key_oacute, "oacute"}, | ||
240 | {Qt::Key_ocircumflex, "ocircumflex"}, | ||
241 | {Qt::Key_otilde, "otilde"}, | ||
242 | {Qt::Key_odiaeresis, "odiaeresis"}, | ||
243 | {Qt::Key_division, "division"}, | ||
244 | {Qt::Key_oslash, "oslash"}, | ||
245 | {Qt::Key_ugrave, "ugrave"}, | ||
246 | {Qt::Key_uacute, "uacute"}, | ||
247 | {Qt::Key_ucircumflex, "ucircumflex"}, | ||
248 | {Qt::Key_udiaeresis, "udiaeresis"}, | ||
249 | {Qt::Key_yacute, "yacute"}, | ||
250 | {Qt::Key_thorn, "thorn"}, | ||
251 | {Qt::Key_ydiaeresis, "ydiaeresis"}, | ||
252 | {Qt::Key_unknown, "unknown"}, | ||
253 | {0,0}, | ||
254 | }; | ||
255 | |||
256 | void KeyNames::setCodeMap() | ||
257 | { | ||
258 | int i; | ||
259 | |||
260 | codemap.clear(); | ||
261 | for(i=0; stKeyNames[i].code != 0; i++){ | ||
262 | codemap.insert(stKeyNames[i].name, stKeyNames[i].code); | ||
263 | } | ||
264 | } | ||
265 | |||
266 | void KeyNames::setNameMap() | ||
267 | { | ||
268 | int i; | ||
269 | |||
270 | namemap.clear(); | ||
271 | for(i=0; stKeyNames[i].code != 0; i++){ | ||
272 | namemap.insert(stKeyNames[i].code, stKeyNames[i].name); | ||
273 | } | ||
274 | } | ||
diff --git a/noncore/applets/keyhelper/keyhelperconf/KeyNames.h b/noncore/applets/keyhelper/keyhelperconf/KeyNames.h new file mode 100644 index 0000000..edd7dc5 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/KeyNames.h | |||
@@ -0,0 +1,49 @@ | |||
1 | #ifndef _KEY_NAMES_H_ | ||
2 | #define _KEY_NAMES_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qmap.h> | ||
6 | #include <qnamespace.h> | ||
7 | |||
8 | class KeyNames | ||
9 | { | ||
10 | public: | ||
11 | static const QString& getName(int code){ | ||
12 | if(namemap.isEmpty()) setNameMap(); | ||
13 | if(namemap.contains(code)){ | ||
14 | return(namemap[code]); | ||
15 | } else { | ||
16 | return(QString::null); | ||
17 | } | ||
18 | } | ||
19 | static void clearName(){ | ||
20 | namemap.clear(); | ||
21 | } | ||
22 | static int getCode(const QString& s){ | ||
23 | if(codemap.isEmpty()) setCodeMap(); | ||
24 | if(codemap.contains(s)){ | ||
25 | return(codemap[s]); | ||
26 | } else { | ||
27 | return(0); | ||
28 | } | ||
29 | } | ||
30 | static void setCode(const QString& s, int code){ | ||
31 | if(codemap.contains(s) == false){ | ||
32 | codemap.insert(s, code); | ||
33 | } | ||
34 | } | ||
35 | static void clearCode(){ | ||
36 | codemap.clear(); | ||
37 | } | ||
38 | static void reset(){ | ||
39 | clearCode(); | ||
40 | } | ||
41 | private: | ||
42 | static QMap<QString, int> codemap; | ||
43 | static QMap<int, QString> namemap; | ||
44 | |||
45 | static void setCodeMap(); | ||
46 | static void setNameMap(); | ||
47 | }; | ||
48 | |||
49 | #endif /* _KEY_NAMES_H_ */ | ||
diff --git a/noncore/applets/keyhelper/keyhelperconf/keyhelperconf.pro b/noncore/applets/keyhelper/keyhelperconf/keyhelperconf.pro new file mode 100644 index 0000000..f84db3d --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/keyhelperconf.pro | |||
@@ -0,0 +1,13 @@ | |||
1 | CONFIG = qt warn_on quick-app | ||
2 | HEADERS = KHCWidget.h \ | ||
3 | KeyNames.h | ||
4 | SOURCES = KHCWidget.cpp \ | ||
5 | KeyNames.cpp \ | ||
6 | khcmain.cpp | ||
7 | INTERFACES= KHCWidgetBase.ui | ||
8 | DESTDIR =$(OPIEDIR)/bin | ||
9 | INCLUDEPATH += . $(OPIEDIR)/include | ||
10 | DEPENDPATH += $(OPIEDIR)/include | ||
11 | LIBS +=-lqpe | ||
12 | |||
13 | include( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/applets/keyhelper/keyhelperconf/khcmain.cpp b/noncore/applets/keyhelper/keyhelperconf/khcmain.cpp new file mode 100644 index 0000000..757bde0 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperconf/khcmain.cpp | |||
@@ -0,0 +1,11 @@ | |||
1 | #include <qpe/qpeapplication.h> | ||
2 | #include "KHCWidget.h" | ||
3 | |||
4 | int main(int argc, char* argv[]) | ||
5 | { | ||
6 | QPEApplication a(argc, argv); | ||
7 | |||
8 | KHCWidget w; | ||
9 | a.showMainWidget(&w); | ||
10 | return a.exec(); | ||
11 | } | ||
@@ -71,6 +71,7 @@ CONFIG_JUMPX inputmethods/jumpx jumpx.pro | |||
71 | CONFIG_KBILL noncore/games/kbillkbill.pro | 71 | CONFIG_KBILL noncore/games/kbillkbill.pro |
72 | CONFIG_KCHECKERS noncore/games/kcheckerskcheckers.pro | 72 | CONFIG_KCHECKERS noncore/games/kcheckerskcheckers.pro |
73 | CONFIG_KEYBOARD inputmethods/keyboardkeyboard.pro | 73 | CONFIG_KEYBOARD inputmethods/keyboardkeyboard.pro |
74 | CONFIG_KEYHELPER noncore/applets/keyhelper keyhelper.pro | ||
74 | CONFIG_KEYPEBBLE noncore/comm/keypebblekeypebble.pro | 75 | CONFIG_KEYPEBBLE noncore/comm/keypebblekeypebble.pro |
75 | CONFIG_KEYVIEW development/keyviewkeyview.pro | 76 | CONFIG_KEYVIEW development/keyviewkeyview.pro |
76 | CONFIG_KJUMPX inputmethods/kjumpxkjumpx.pro | 77 | CONFIG_KJUMPX inputmethods/kjumpxkjumpx.pro |