Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/config') (more/less context) (ignore whitespace changes)
14 files changed, 816 insertions, 0 deletions
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_ */ | ||