author | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
commit | 2b64a84d39eeed5681d0ee5068c7d11a01527750 (patch) (unidiff) | |
tree | c8693340dbc5ef5e2f9afa90b690829ddff2c4bd /noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp | |
parent | 61fa699140c5efbb6ba0bf2a62f7e8fbf62976be (diff) | |
download | opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.zip opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.gz opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.bz2 |
other keymapping tool - not working this moment, I have to check it out
- the reason is that the config file is somewhat easier to understand than
from zkbapplet and has a nice config tool.
Please don't put it into any repositories this moment.
Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp | 112 |
1 files changed, 112 insertions, 0 deletions
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 | } | ||