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/config/ModifiersHandler.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/config/ModifiersHandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/config/ModifiersHandler.cpp | 99 |
1 files changed, 99 insertions, 0 deletions
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 | } | ||