-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp | 2 | ||||
-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp index 4afdc1f..4723699 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp +++ b/noncore/applets/keyhelper/keyhelperapplet/applet/KeyHelper.cpp | |||
@@ -1,112 +1,114 @@ | |||
1 | #include "KeyHelper.h" | 1 | #include "KeyHelper.h" |
2 | #include <opie2/okeyfilter.h> | 2 | #include <opie2/okeyfilter.h> |
3 | #include <opie2/odebug.h> | ||
3 | 4 | ||
4 | KeyHelper::KeyHelper() | 5 | KeyHelper::KeyHelper() |
5 | { | 6 | { |
6 | qDebug("KeyHelper::KeyHelper()"); | 7 | qDebug("KeyHelper::KeyHelper()"); |
7 | load(); | 8 | load(); |
8 | 9 | ||
9 | m_oAction.setKeyModifiers(&m_oModifiers); | 10 | m_oAction.setKeyModifiers(&m_oModifiers); |
10 | m_oAction.setKeyMappings(&m_oMappings); | 11 | m_oAction.setKeyMappings(&m_oMappings); |
11 | m_oAction.setKeyExtensions(&m_oExtensions); | 12 | m_oAction.setKeyExtensions(&m_oExtensions); |
12 | m_oAction.setKeyRepeater(&m_oRepeater); | 13 | m_oAction.setKeyRepeater(&m_oRepeater); |
13 | m_oExtensions.setKeyModifiers(&m_oModifiers); | 14 | m_oExtensions.setKeyModifiers(&m_oModifiers); |
14 | } | 15 | } |
15 | 16 | ||
16 | KeyHelper::~KeyHelper() | 17 | KeyHelper::~KeyHelper() |
17 | { | 18 | { |
18 | unset(); | 19 | unset(); |
19 | qDebug("KeyHelper::~KeyHelper()"); | 20 | qDebug("KeyHelper::~KeyHelper()"); |
20 | } | 21 | } |
21 | 22 | ||
22 | bool KeyHelper::filter(int unicode, int keycode, int modifiers, | 23 | bool KeyHelper::filter(int unicode, int keycode, int modifiers, |
23 | bool isPress, bool autoRepeat) | 24 | bool isPress, bool autoRepeat) |
24 | { | 25 | { |
26 | odebug << "KeyHelper <<< "<<unicode<<" - "<<keycode<<" - "<<modifiers<<"\n"; | ||
25 | m_oAction.setAction(unicode, keycode, modifiers, | 27 | m_oAction.setAction(unicode, keycode, modifiers, |
26 | isPress, autoRepeat); | 28 | isPress, autoRepeat); |
27 | return(m_oAction.doAction()); | 29 | return(m_oAction.doAction()); |
28 | } | 30 | } |
29 | 31 | ||
30 | void KeyHelper::unset() | 32 | void KeyHelper::unset() |
31 | { | 33 | { |
32 | Opie::Core::OKeyFilter::inst()->remHandler(this);; | 34 | Opie::Core::OKeyFilter::inst()->remHandler(this);; |
33 | } | 35 | } |
34 | 36 | ||
35 | void KeyHelper::set() | 37 | void KeyHelper::set() |
36 | { | 38 | { |
37 | Opie::Core::OKeyFilter::inst()->addHandler(this); | 39 | Opie::Core::OKeyFilter::inst()->addHandler(this); |
38 | m_oModifiers.resetStates(); | 40 | m_oModifiers.resetStates(); |
39 | } | 41 | } |
40 | 42 | ||
41 | void KeyHelper::enable() | 43 | void KeyHelper::enable() |
42 | { | 44 | { |
43 | m_oAction.enable(); | 45 | m_oAction.enable(); |
44 | } | 46 | } |
45 | 47 | ||
46 | void KeyHelper::disable() | 48 | void KeyHelper::disable() |
47 | { | 49 | { |
48 | m_oAction.disable(); | 50 | m_oAction.disable(); |
49 | m_oRepeater.stop(); | 51 | m_oRepeater.stop(); |
50 | } | 52 | } |
51 | 53 | ||
52 | bool KeyHelper::load(const QString& file) | 54 | bool KeyHelper::load(const QString& file) |
53 | { | 55 | { |
54 | KeycfgReader oReader; | 56 | KeycfgReader oReader; |
55 | oReader.setKeyModifiers(&m_oModifiers); | 57 | oReader.setKeyModifiers(&m_oModifiers); |
56 | oReader.setKeyMappings(&m_oMappings); | 58 | oReader.setKeyMappings(&m_oMappings); |
57 | oReader.setKeyExtensions(&m_oExtensions); | 59 | oReader.setKeyExtensions(&m_oExtensions); |
58 | oReader.setKeyRepeater(&m_oRepeater); | 60 | oReader.setKeyRepeater(&m_oRepeater); |
59 | 61 | ||
60 | bool success; | 62 | bool success; |
61 | if(file.length() == 0){ | 63 | if(file.length() == 0){ |
62 | success = oReader.load(); | 64 | success = oReader.load(); |
63 | } else if(file[0] == '/'){ | 65 | } else if(file[0] == '/'){ |
64 | success = oReader.load(file); | 66 | success = oReader.load(file); |
65 | } else { | 67 | } else { |
66 | //QString filepath = QString(::getenv("HOME")) + "/Settings/" + file; | 68 | //QString filepath = QString(::getenv("HOME")) + "/Settings/" + file; |
67 | QString filepath = QDir::homeDirPath() + "/Settings/" + file; | 69 | QString filepath = QDir::homeDirPath() + "/Settings/" + file; |
68 | success = oReader.load(filepath); | 70 | success = oReader.load(filepath); |
69 | } | 71 | } |
70 | if(success == false){ | 72 | if(success == false){ |
71 | qDebug("config xml load error"); | 73 | qDebug("config xml load error"); |
72 | setDefault(); | 74 | setDefault(); |
73 | } | 75 | } |
74 | return(success); | 76 | return(success); |
75 | } | 77 | } |
76 | 78 | ||
77 | bool KeyHelper::reload(const QString& file) | 79 | bool KeyHelper::reload(const QString& file) |
78 | { | 80 | { |
79 | m_oModifiers.reset(); | 81 | m_oModifiers.reset(); |
80 | m_oMappings.reset(); | 82 | m_oMappings.reset(); |
81 | m_oExtensions.reset(); | 83 | m_oExtensions.reset(); |
82 | m_oRepeater.reset(); | 84 | m_oRepeater.reset(); |
83 | 85 | ||
84 | return(load(file)); | 86 | return(load(file)); |
85 | } | 87 | } |
86 | 88 | ||
87 | void KeyHelper::setDefault() | 89 | void KeyHelper::setDefault() |
88 | { | 90 | { |
89 | /* default settings */ | 91 | /* default settings */ |
90 | m_oExtensions.assign("switch", Qt::Key_F12, | 92 | m_oExtensions.assign("switch", Qt::Key_F12, |
91 | m_oModifiers.getMask("Shift"), KeyNames::getCode("Shift")); | 93 | m_oModifiers.getMask("Shift"), KeyNames::getCode("Shift")); |
92 | m_oExtensions.assign("select", Qt::Key_F11, | 94 | m_oExtensions.assign("select", Qt::Key_F11, |
93 | m_oModifiers.getMask("Shift"), KeyNames::getCode("Shift")); | 95 | m_oModifiers.getMask("Shift"), KeyNames::getCode("Shift")); |
94 | } | 96 | } |
95 | 97 | ||
96 | void KeyHelper::statistics() | 98 | void KeyHelper::statistics() |
97 | { | 99 | { |
98 | m_oModifiers.statistics(); | 100 | m_oModifiers.statistics(); |
99 | m_oMappings.statistics(); | 101 | m_oMappings.statistics(); |
100 | m_oExtensions.statistics(); | 102 | m_oExtensions.statistics(); |
101 | m_oRepeater.statistics(); | 103 | m_oRepeater.statistics(); |
102 | } | 104 | } |
103 | 105 | ||
104 | void KeyHelper::dumpkeymap() | 106 | void KeyHelper::dumpkeymap() |
105 | { | 107 | { |
106 | const QWSServer::KeyMap* m = QWSServer::keyMap(); | 108 | const QWSServer::KeyMap* m = QWSServer::keyMap(); |
107 | qWarning("KeyHelper::dumpkeymap()"); | 109 | qWarning("KeyHelper::dumpkeymap()"); |
108 | while(m->key_code != 0){ | 110 | while(m->key_code != 0){ |
109 | qWarning(" [%04x][%04x][%04x][%04x]", m->key_code, m->unicode, m->shift_unicode, m->ctrl_unicode); | 111 | qWarning(" [%04x][%04x][%04x][%04x]", m->key_code, m->unicode, m->shift_unicode, m->ctrl_unicode); |
110 | m++; | 112 | m++; |
111 | } | 113 | } |
112 | } | 114 | } |
diff --git a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp index 44b4b2f..14e8a37 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp +++ b/noncore/applets/keyhelper/keyhelperapplet/config/KeycfgReader.cpp | |||
@@ -1,70 +1,70 @@ | |||
1 | #include "KeycfgReader.h" | 1 | #include "KeycfgReader.h" |
2 | 2 | ||
3 | KeycfgReader::KeycfgReader() | 3 | KeycfgReader::KeycfgReader() |
4 | { | 4 | { |
5 | qDebug("KeycfgReader::KeycfgReader()"); | 5 | qDebug("KeycfgReader::KeycfgReader()"); |
6 | } | 6 | } |
7 | 7 | ||
8 | KeycfgReader::~KeycfgReader() | 8 | KeycfgReader::~KeycfgReader() |
9 | { | 9 | { |
10 | qDebug("KeycfgReader::~KeycfgReader()"); | 10 | qDebug("KeycfgReader::~KeycfgReader()"); |
11 | } | 11 | } |
12 | 12 | ||
13 | bool KeycfgReader::load() | 13 | bool KeycfgReader::load() |
14 | { | 14 | { |
15 | QString file; | 15 | QString file; |
16 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); | 16 | ConfigEx& cfg = ConfigEx::getInstance("keyhelper"); |
17 | 17 | ||
18 | cfg.setGroup("Global"); | 18 | cfg.setGroup("Global"); |
19 | 19 | ||
20 | file = cfg.readEntry("XmlFile"); | 20 | file = cfg.readEntry("XmlFile"); |
21 | if(file.length() == 0 || !QFile::exists(file)){ | 21 | if(file.length() == 0 || !QFile::exists(file)){ |
22 | /* default */ | 22 | /* default */ |
23 | file = QDir::homeDirPath() + "/Settings/keyhelper.xml"; | 23 | file = QString(getenv( "HOME" )) + QString("/Settings/keyhelper.xml"); |
24 | } | 24 | } |
25 | return(load(file)); | 25 | return(load(file)); |
26 | } | 26 | } |
27 | 27 | ||
28 | bool KeycfgReader::load(const QString& path) | 28 | bool KeycfgReader::load(const QString& path) |
29 | { | 29 | { |
30 | bool success = false; | 30 | bool success = false; |
31 | 31 | ||
32 | KeyNames::reset(); | 32 | KeyNames::reset(); |
33 | 33 | ||
34 | QXmlSimpleReader parser; | 34 | QXmlSimpleReader parser; |
35 | KeycfgHandler handler(&parser); | 35 | KeycfgHandler handler(&parser); |
36 | KeycfgErrorHandler errhandler; | 36 | KeycfgErrorHandler errhandler; |
37 | QFile file(path); | 37 | QFile file(path); |
38 | 38 | ||
39 | qWarning("KeycfgReader::load()[%s]", path.latin1()); | 39 | qWarning("KeycfgReader::load()[%s]", path.latin1()); |
40 | 40 | ||
41 | if(file.exists()){ | 41 | if(file.exists()){ |
42 | QXmlInputSource source(file); | 42 | QXmlInputSource source(file); |
43 | 43 | ||
44 | handler.setKeyModifiers(m_pModifiers); | 44 | handler.setKeyModifiers(m_pModifiers); |
45 | handler.setKeyMappings(m_pMappings); | 45 | handler.setKeyMappings(m_pMappings); |
46 | handler.setKeyExtensions(m_pExtensions); | 46 | handler.setKeyExtensions(m_pExtensions); |
47 | handler.setKeyRepeater(m_pRepeater); | 47 | handler.setKeyRepeater(m_pRepeater); |
48 | 48 | ||
49 | parser.setContentHandler(&handler); | 49 | parser.setContentHandler(&handler); |
50 | parser.setErrorHandler(&errhandler); | 50 | parser.setErrorHandler(&errhandler); |
51 | success = parser.parse(source); | 51 | success = parser.parse(source); |
52 | 52 | ||
53 | file.close(); | 53 | file.close(); |
54 | } | 54 | } |
55 | 55 | ||
56 | if(success){ | 56 | if(success){ |
57 | m_pModifiers->statistics(); | 57 | m_pModifiers->statistics(); |
58 | m_pMappings->statistics(); | 58 | m_pMappings->statistics(); |
59 | m_pExtensions->statistics(); | 59 | m_pExtensions->statistics(); |
60 | m_pRepeater->statistics(); | 60 | m_pRepeater->statistics(); |
61 | } else { | 61 | } else { |
62 | m_pModifiers->reset(); | 62 | m_pModifiers->reset(); |
63 | m_pMappings->reset(); | 63 | m_pMappings->reset(); |
64 | m_pExtensions->reset(); | 64 | m_pExtensions->reset(); |
65 | m_pRepeater->reset(); | 65 | m_pRepeater->reset(); |
66 | } | 66 | } |
67 | KeyNames::clearCode(); | 67 | KeyNames::clearCode(); |
68 | 68 | ||
69 | return(success); | 69 | return(success); |
70 | } | 70 | } |