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