author | simon <simon> | 2002-11-22 10:56:30 (UTC) |
---|---|---|
committer | simon <simon> | 2002-11-22 10:56:30 (UTC) |
commit | 480284c491e26427c630131a25e56f9ed1d129b2 (patch) (unidiff) | |
tree | 3bdd60afe34e8c466fbea92dcf89fcab381b110d /inputmethods/multikey | |
parent | 772c1321e4e95a415b9de700c3474f81f98b5482 (diff) | |
download | opie-480284c491e26427c630131a25e56f9ed1d129b2.zip opie-480284c491e26427c630131a25e56f9ed1d129b2.tar.gz opie-480284c491e26427c630131a25e56f9ed1d129b2.tar.bz2 |
- properly namespace the input methods. fixes symbols clashes at run-time
with names like 'Keyboard' or 'KeyboardConfig' . the qcom interface
objects are in an anonymous namespace now and the actual keyboard
implementations are in Dvorak, JumpX, etc. namespaces.
What's left is to solve the symbol clashes of the multiply compiled
pickboard classes. I'll leave that one (as part of the patch posted
yesterday) for another day for review. This part (namespacing) sounds like
a safe bet to me though, so comitting now. (got no comments anyway)
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 1 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 5 | ||||
-rw-r--r-- | inputmethods/multikey/keyboardimpl.cpp | 4 | ||||
-rw-r--r-- | inputmethods/multikey/keyboardimpl.h | 13 |
4 files changed, 18 insertions, 5 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 84c0c74..c22fbb1 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,1659 +1,1660 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | #include "configdlg.h" | 22 | #include "configdlg.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | 26 | ||
27 | #include <qwindowsystem_qws.h> | 27 | #include <qwindowsystem_qws.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qfontmetrics.h> | 29 | #include <qfontmetrics.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | 37 | ||
38 | #include <sys/utsname.h> | 38 | #include <sys/utsname.h> |
39 | 39 | ||
40 | using namespace MultiKey; | ||
40 | 41 | ||
41 | /* Keyboard::Keyboard {{{1 */ | 42 | /* Keyboard::Keyboard {{{1 */ |
42 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
43 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), |
44 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), | 45 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), |
45 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), | 46 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), |
46 | pressedKeyRow(-1), pressedKeyCol(-1), | 47 | pressedKeyRow(-1), pressedKeyCol(-1), |
47 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 48 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
48 | configdlg(0) | 49 | configdlg(0) |
49 | 50 | ||
50 | { | 51 | { |
51 | 52 | ||
52 | // get the default font | 53 | // get the default font |
53 | Config *config = new Config( "qpe" ); | 54 | Config *config = new Config( "qpe" ); |
54 | config->setGroup( "Appearance" ); | 55 | config->setGroup( "Appearance" ); |
55 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); | 56 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); |
56 | delete config; | 57 | delete config; |
57 | 58 | ||
58 | config = new Config("multikey"); | 59 | config = new Config("multikey"); |
59 | config->setGroup ("general"); | 60 | config->setGroup ("general"); |
60 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed | 61 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed |
61 | useRepeat = config->readBoolEntry ("useRepeat", 1); | 62 | useRepeat = config->readBoolEntry ("useRepeat", 1); |
62 | delete config; | 63 | delete config; |
63 | 64 | ||
64 | 65 | ||
65 | setFont( QFont( familyStr, 10 ) ); | 66 | setFont( QFont( familyStr, 10 ) ); |
66 | 67 | ||
67 | picks = new KeyboardPicks( this ); | 68 | picks = new KeyboardPicks( this ); |
68 | picks->setFont( QFont( familyStr, 10 ) ); | 69 | picks->setFont( QFont( familyStr, 10 ) ); |
69 | picks->initialise(); | 70 | picks->initialise(); |
70 | if (usePicks) { | 71 | if (usePicks) { |
71 | 72 | ||
72 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 73 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
73 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 74 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
74 | 75 | ||
75 | } else picks->hide(); | 76 | } else picks->hide(); |
76 | 77 | ||
77 | loadKeyboardColors(); | 78 | loadKeyboardColors(); |
78 | 79 | ||
79 | keys = new Keys(); | 80 | keys = new Keys(); |
80 | 81 | ||
81 | repeatTimer = new QTimer( this ); | 82 | repeatTimer = new QTimer( this ); |
82 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 83 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
83 | 84 | ||
84 | } | 85 | } |
85 | 86 | ||
86 | Keyboard::~Keyboard() { | 87 | Keyboard::~Keyboard() { |
87 | 88 | ||
88 | if ( configdlg ) { | 89 | if ( configdlg ) { |
89 | delete (ConfigDlg *) configdlg; | 90 | delete (ConfigDlg *) configdlg; |
90 | configdlg = 0; | 91 | configdlg = 0; |
91 | } | 92 | } |
92 | 93 | ||
93 | } | 94 | } |
94 | 95 | ||
95 | /* Keyboard::resizeEvent {{{1 */ | 96 | /* Keyboard::resizeEvent {{{1 */ |
96 | void Keyboard::resizeEvent(QResizeEvent*) | 97 | void Keyboard::resizeEvent(QResizeEvent*) |
97 | { | 98 | { |
98 | int ph = picks->sizeHint().height(); | 99 | int ph = picks->sizeHint().height(); |
99 | picks->setGeometry( 0, 0, width(), ph ); | 100 | picks->setGeometry( 0, 0, width(), ph ); |
100 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); | 101 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); |
101 | 102 | ||
102 | int nk; // number of keys? | 103 | int nk; // number of keys? |
103 | if ( useLargeKeys ) { | 104 | if ( useLargeKeys ) { |
104 | nk = 15; | 105 | nk = 15; |
105 | } else { | 106 | } else { |
106 | nk = 19; | 107 | nk = 19; |
107 | } | 108 | } |
108 | defaultKeyWidth = (width()/nk)/2; | 109 | defaultKeyWidth = (width()/nk)/2; |
109 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 110 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
110 | 111 | ||
111 | } | 112 | } |
112 | 113 | ||
113 | /* KeyboardPicks::initialize {{{1 */ | 114 | /* KeyboardPicks::initialize {{{1 */ |
114 | void KeyboardPicks::initialise() | 115 | void KeyboardPicks::initialise() |
115 | { | 116 | { |
116 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 117 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
117 | mode = 0; | 118 | mode = 0; |
118 | dc = new KeyboardConfig(this); | 119 | dc = new KeyboardConfig(this); |
119 | configs.append(dc); | 120 | configs.append(dc); |
120 | } | 121 | } |
121 | 122 | ||
122 | /* KeyboardPicks::sizeHint {{{1 */ | 123 | /* KeyboardPicks::sizeHint {{{1 */ |
123 | QSize KeyboardPicks::sizeHint() const | 124 | QSize KeyboardPicks::sizeHint() const |
124 | { | 125 | { |
125 | return QSize(240,fontMetrics().lineSpacing()); | 126 | return QSize(240,fontMetrics().lineSpacing()); |
126 | } | 127 | } |
127 | 128 | ||
128 | 129 | ||
129 | /* KeyboardConfig::generateText {{{1 */ | 130 | /* KeyboardConfig::generateText {{{1 */ |
130 | void KeyboardConfig::generateText(const QString &s) | 131 | void KeyboardConfig::generateText(const QString &s) |
131 | { | 132 | { |
132 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 133 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
133 | for (int i=0; i<(int)backspaces; i++) { | 134 | for (int i=0; i<(int)backspaces; i++) { |
134 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 135 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
135 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 136 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
136 | } | 137 | } |
137 | for (int i=0; i<(int)s.length(); i++) { | 138 | for (int i=0; i<(int)s.length(); i++) { |
138 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 139 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
139 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 140 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
140 | } | 141 | } |
141 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 142 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
142 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 143 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
143 | backspaces = 0; | 144 | backspaces = 0; |
144 | #endif | 145 | #endif |
145 | } | 146 | } |
146 | 147 | ||
147 | 148 | ||
148 | 149 | ||
149 | 150 | ||
150 | /* Keyboard::paintEvent {{{1 */ | 151 | /* Keyboard::paintEvent {{{1 */ |
151 | void Keyboard::paintEvent(QPaintEvent* e) | 152 | void Keyboard::paintEvent(QPaintEvent* e) |
152 | { | 153 | { |
153 | QPainter painter(this); | 154 | QPainter painter(this); |
154 | painter.setClipRect(e->rect()); | 155 | painter.setClipRect(e->rect()); |
155 | drawKeyboard( painter ); | 156 | drawKeyboard( painter ); |
156 | picks->dc->draw( &painter ); | 157 | picks->dc->draw( &painter ); |
157 | } | 158 | } |
158 | 159 | ||
159 | 160 | ||
160 | /* Keyboard::drawKeyboard {{{1 */ | 161 | /* Keyboard::drawKeyboard {{{1 */ |
161 | 162 | ||
162 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 163 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
163 | { | 164 | { |
164 | 165 | ||
165 | 166 | ||
166 | if (row != -1 && col != -1) { //just redraw one key | 167 | if (row != -1 && col != -1) { //just redraw one key |
167 | 168 | ||
168 | int x = 0; | 169 | int x = 0; |
169 | for (int i = 0; i < col; i++) { | 170 | for (int i = 0; i < col; i++) { |
170 | 171 | ||
171 | x += keys->width(row, i) * defaultKeyWidth; | 172 | x += keys->width(row, i) * defaultKeyWidth; |
172 | } | 173 | } |
173 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 174 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
174 | 175 | ||
175 | int keyWidth = keys->width(row, col); | 176 | int keyWidth = keys->width(row, col); |
176 | 177 | ||
177 | p.fillRect(x + 1, y + 1, | 178 | p.fillRect(x + 1, y + 1, |
178 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 179 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
179 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 180 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
180 | 181 | ||
181 | QImage *pix = keys->pix(row,col); | 182 | QImage *pix = keys->pix(row,col); |
182 | 183 | ||
183 | ushort c = keys->uni(row, col); | 184 | ushort c = keys->uni(row, col); |
184 | 185 | ||
185 | p.setPen(textcolor); | 186 | p.setPen(textcolor); |
186 | if (!pix) { | 187 | if (!pix) { |
187 | if ((shift || lock) && keys->shift(c)) | 188 | if ((shift || lock) && keys->shift(c)) |
188 | 189 | ||
189 | if (circumflex && keys->circumflex(keys->shift(c))) | 190 | if (circumflex && keys->circumflex(keys->shift(c))) |
190 | c = keys->circumflex(keys->shift(c)); | 191 | c = keys->circumflex(keys->shift(c)); |
191 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 192 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
192 | c = keys->diaeresis(keys->shift(c)); | 193 | c = keys->diaeresis(keys->shift(c)); |
193 | else if (baccent && keys->baccent(keys->shift(c))) | 194 | else if (baccent && keys->baccent(keys->shift(c))) |
194 | c = keys->baccent(keys->shift(c)); | 195 | c = keys->baccent(keys->shift(c)); |
195 | else if (accent && keys->accent(keys->shift(c))) | 196 | else if (accent && keys->accent(keys->shift(c))) |
196 | c = keys->accent(keys->shift(c)); | 197 | c = keys->accent(keys->shift(c)); |
197 | else if (meta && keys->meta(keys->shift(c))) | 198 | else if (meta && keys->meta(keys->shift(c))) |
198 | c = keys->meta(keys->shift(c)); | 199 | c = keys->meta(keys->shift(c)); |
199 | else | 200 | else |
200 | c = keys->shift(c); | 201 | c = keys->shift(c); |
201 | 202 | ||
202 | else if (meta && keys->meta(c)) | 203 | else if (meta && keys->meta(c)) |
203 | c = keys->meta(c); | 204 | c = keys->meta(c); |
204 | else if (circumflex && keys->circumflex(c)) | 205 | else if (circumflex && keys->circumflex(c)) |
205 | c = keys->circumflex(c); | 206 | c = keys->circumflex(c); |
206 | else if (baccent && keys->baccent(c)) | 207 | else if (baccent && keys->baccent(c)) |
207 | c = keys->baccent(c); | 208 | c = keys->baccent(c); |
208 | else if (accent && keys->accent(c)) | 209 | else if (accent && keys->accent(c)) |
209 | c = keys->accent(c); | 210 | c = keys->accent(c); |
210 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 211 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
211 | 212 | ||
212 | // the diaeresis key itself has to be in the diaeresisMap, | 213 | // the diaeresis key itself has to be in the diaeresisMap, |
213 | // or just do this to make it display the diaeresis char. | 214 | // or just do this to make it display the diaeresis char. |
214 | 215 | ||
215 | if (c == 0x2c6) | 216 | if (c == 0x2c6) |
216 | c = 0xa8; | 217 | c = 0xa8; |
217 | else | 218 | else |
218 | c = keys->diaeresis(c); | 219 | c = keys->diaeresis(c); |
219 | } | 220 | } |
220 | 221 | ||
221 | p.drawText(x, y, | 222 | p.drawText(x, y, |
222 | defaultKeyWidth * keyWidth + 3, keyHeight, | 223 | defaultKeyWidth * keyWidth + 3, keyHeight, |
223 | AlignCenter, (QChar)c); | 224 | AlignCenter, (QChar)c); |
224 | } | 225 | } |
225 | else | 226 | else |
226 | // center the image in the middle of the key | 227 | // center the image in the middle of the key |
227 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, | 228 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, |
228 | y + (keyHeight - pix->height())/2 + 1, | 229 | y + (keyHeight - pix->height())/2 + 1, |
229 | *pix ); | 230 | *pix ); |
230 | 231 | ||
231 | // this fixes the problem that the very right end of the board's vertical line | 232 | // this fixes the problem that the very right end of the board's vertical line |
232 | // gets painted over, because it's one pixel shorter than all other keys | 233 | // gets painted over, because it's one pixel shorter than all other keys |
233 | p.setPen(keycolor_lines); | 234 | p.setPen(keycolor_lines); |
234 | p.drawLine(width() - 1, 0, width() - 1, height()); | 235 | p.drawLine(width() - 1, 0, width() - 1, height()); |
235 | 236 | ||
236 | } else { | 237 | } else { |
237 | 238 | ||
238 | 239 | ||
239 | p.fillRect(0, 0, width(), height(), keycolor); | 240 | p.fillRect(0, 0, width(), height(), keycolor); |
240 | 241 | ||
241 | for (row = 1; row <= keys->rows(); row++) { | 242 | for (row = 1; row <= keys->rows(); row++) { |
242 | 243 | ||
243 | int x = 0; | 244 | int x = 0; |
244 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 245 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
245 | 246 | ||
246 | p.setPen(keycolor_lines); | 247 | p.setPen(keycolor_lines); |
247 | p.drawLine(x, y, x + width(), y); | 248 | p.drawLine(x, y, x + width(), y); |
248 | 249 | ||
249 | for (int col = 0; col < keys->numKeys(row); col++) { | 250 | for (int col = 0; col < keys->numKeys(row); col++) { |
250 | 251 | ||
251 | QImage *pix = keys->pix(row, col); | 252 | QImage *pix = keys->pix(row, col); |
252 | int keyWidth = keys->width(row, col); | 253 | int keyWidth = keys->width(row, col); |
253 | 254 | ||
254 | 255 | ||
255 | int keyWidthPix = defaultKeyWidth * keyWidth; | 256 | int keyWidthPix = defaultKeyWidth * keyWidth; |
256 | 257 | ||
257 | if (keys->pressed(row, col)) | 258 | if (keys->pressed(row, col)) |
258 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 259 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
259 | keyHeight - 1, keycolor_pressed); | 260 | keyHeight - 1, keycolor_pressed); |
260 | 261 | ||
261 | ushort c = keys->uni(row, col); | 262 | ushort c = keys->uni(row, col); |
262 | 263 | ||
263 | p.setPen(textcolor); | 264 | p.setPen(textcolor); |
264 | if (!pix) { | 265 | if (!pix) { |
265 | if ((shift || lock) && keys->shift(c)) | 266 | if ((shift || lock) && keys->shift(c)) |
266 | 267 | ||
267 | if (circumflex && keys->circumflex(keys->shift(c))) | 268 | if (circumflex && keys->circumflex(keys->shift(c))) |
268 | c = keys->circumflex(keys->shift(c)); | 269 | c = keys->circumflex(keys->shift(c)); |
269 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 270 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
270 | c = keys->diaeresis(keys->shift(c)); | 271 | c = keys->diaeresis(keys->shift(c)); |
271 | else if (baccent && keys->baccent(keys->shift(c))) | 272 | else if (baccent && keys->baccent(keys->shift(c))) |
272 | c = keys->baccent(keys->shift(c)); | 273 | c = keys->baccent(keys->shift(c)); |
273 | else if (accent && keys->accent(keys->shift(c))) | 274 | else if (accent && keys->accent(keys->shift(c))) |
274 | c = keys->accent(keys->shift(c)); | 275 | c = keys->accent(keys->shift(c)); |
275 | else if (meta && keys->meta(keys->shift(c))) | 276 | else if (meta && keys->meta(keys->shift(c))) |
276 | c = keys->meta(keys->shift(c)); | 277 | c = keys->meta(keys->shift(c)); |
277 | else | 278 | else |
278 | c = keys->shift(c); | 279 | c = keys->shift(c); |
279 | 280 | ||
280 | else if (meta && keys->meta(c)) | 281 | else if (meta && keys->meta(c)) |
281 | c = keys->meta(c); | 282 | c = keys->meta(c); |
282 | else if (circumflex && keys->circumflex(c)) | 283 | else if (circumflex && keys->circumflex(c)) |
283 | c = keys->circumflex(c); | 284 | c = keys->circumflex(c); |
284 | else if (baccent && keys->baccent(c)) | 285 | else if (baccent && keys->baccent(c)) |
285 | c = keys->baccent(c); | 286 | c = keys->baccent(c); |
286 | else if (accent && keys->accent(c)) | 287 | else if (accent && keys->accent(c)) |
287 | c = keys->accent(c); | 288 | c = keys->accent(c); |
288 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 289 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
289 | 290 | ||
290 | if (c == 0x2c6) | 291 | if (c == 0x2c6) |
291 | c = 0xa8; | 292 | c = 0xa8; |
292 | else | 293 | else |
293 | c = keys->diaeresis(c); | 294 | c = keys->diaeresis(c); |
294 | } | 295 | } |
295 | 296 | ||
296 | p.drawText(x, y, | 297 | p.drawText(x, y, |
297 | keyWidthPix + 3, keyHeight, | 298 | keyWidthPix + 3, keyHeight, |
298 | AlignCenter, (QChar)c); | 299 | AlignCenter, (QChar)c); |
299 | } | 300 | } |
300 | else { | 301 | else { |
301 | // center the image in the middle of the key | 302 | // center the image in the middle of the key |
302 | pix->setColor(1, textcolor.rgb()); | 303 | pix->setColor(1, textcolor.rgb()); |
303 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, | 304 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, |
304 | y + (keyHeight - pix->height())/2 + 1, | 305 | y + (keyHeight - pix->height())/2 + 1, |
305 | QImage(*pix) ); | 306 | QImage(*pix) ); |
306 | } | 307 | } |
307 | 308 | ||
308 | p.setPen(keycolor_lines); | 309 | p.setPen(keycolor_lines); |
309 | p.drawLine(x, y, x, y + keyHeight); | 310 | p.drawLine(x, y, x, y + keyHeight); |
310 | 311 | ||
311 | x += keyWidthPix; | 312 | x += keyWidthPix; |
312 | } | 313 | } |
313 | 314 | ||
314 | 315 | ||
315 | } | 316 | } |
316 | p.setPen(keycolor_lines); | 317 | p.setPen(keycolor_lines); |
317 | p.drawLine(0, height() - 1, width(), height() - 1); | 318 | p.drawLine(0, height() - 1, width(), height() - 1); |
318 | p.drawLine(width() - 1, 0, width() - 1, height()); | 319 | p.drawLine(width() - 1, 0, width() - 1, height()); |
319 | } | 320 | } |
320 | 321 | ||
321 | } | 322 | } |
322 | 323 | ||
323 | 324 | ||
324 | /* Keyboard::mousePressEvent {{{1 */ | 325 | /* Keyboard::mousePressEvent {{{1 */ |
325 | void Keyboard::mousePressEvent(QMouseEvent *e) | 326 | void Keyboard::mousePressEvent(QMouseEvent *e) |
326 | { | 327 | { |
327 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 328 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
328 | if (row > 5) row = 5; | 329 | if (row > 5) row = 5; |
329 | 330 | ||
330 | // figure out the column | 331 | // figure out the column |
331 | int col = 0; | 332 | int col = 0; |
332 | for (int w = 0; e->x() >= w; col++) | 333 | for (int w = 0; e->x() >= w; col++) |
333 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 334 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
334 | w += keys->width(row,col) * defaultKeyWidth; | 335 | w += keys->width(row,col) * defaultKeyWidth; |
335 | else break; | 336 | else break; |
336 | 337 | ||
337 | if (col <= 0) return; | 338 | if (col <= 0) return; |
338 | 339 | ||
339 | col --; // rewind one... | 340 | col --; // rewind one... |
340 | 341 | ||
341 | qkeycode = keys->qcode(row, col); | 342 | qkeycode = keys->qcode(row, col); |
342 | unicode = keys->uni(row, col); | 343 | unicode = keys->uni(row, col); |
343 | 344 | ||
344 | // might need to repaint if two or more of the same keys. | 345 | // might need to repaint if two or more of the same keys. |
345 | // should be faster if just paint one key even though multiple keys exist. | 346 | // should be faster if just paint one key even though multiple keys exist. |
346 | bool need_repaint = FALSE; | 347 | bool need_repaint = FALSE; |
347 | 348 | ||
348 | // circumflex and diaeresis support | 349 | // circumflex and diaeresis support |
349 | // messy to have this here, but too hard to implement any other method | 350 | // messy to have this here, but too hard to implement any other method |
350 | if (unicode == 0x2c6) { | 351 | if (unicode == 0x2c6) { |
351 | 352 | ||
352 | unicode = 0; | 353 | unicode = 0; |
353 | if (shift || lock) { | 354 | if (shift || lock) { |
354 | 355 | ||
355 | // diaeresis | 356 | // diaeresis |
356 | qkeycode = 0x2001; | 357 | qkeycode = 0x2001; |
357 | } | 358 | } |
358 | else { | 359 | else { |
359 | 360 | ||
360 | // circumflex | 361 | // circumflex |
361 | qkeycode = 0x2000; | 362 | qkeycode = 0x2000; |
362 | } | 363 | } |
363 | } | 364 | } |
364 | 365 | ||
365 | // Back accent character support | 366 | // Back accent character support |
366 | 367 | ||
367 | // the keys from 2c6 ~ 2cf should be used instead of the ascii one | 368 | // the keys from 2c6 ~ 2cf should be used instead of the ascii one |
368 | if (unicode == 0x2cb) { | 369 | if (unicode == 0x2cb) { |
369 | 370 | ||
370 | unicode = 0; | 371 | unicode = 0; |
371 | if (shift || lock) { | 372 | if (shift || lock) { |
372 | 373 | ||
373 | // circumblex | 374 | // circumblex |
374 | qkeycode = 0x2000; | 375 | qkeycode = 0x2000; |
375 | } | 376 | } |
376 | else { | 377 | else { |
377 | 378 | ||
378 | // back accent | 379 | // back accent |
379 | qkeycode = 0x2002; | 380 | qkeycode = 0x2002; |
380 | } | 381 | } |
381 | } | 382 | } |
382 | 383 | ||
383 | // Accent character support | 384 | // Accent character support |
384 | 385 | ||
385 | if (unicode == 0x2ca) { | 386 | if (unicode == 0x2ca) { |
386 | 387 | ||
387 | unicode = 0; | 388 | unicode = 0; |
388 | if (shift || lock) { | 389 | if (shift || lock) { |
389 | 390 | ||
390 | // diaeresis | 391 | // diaeresis |
391 | qkeycode = 0x2001; | 392 | qkeycode = 0x2001; |
392 | } | 393 | } |
393 | else { | 394 | else { |
394 | 395 | ||
395 | // accent | 396 | // accent |
396 | qkeycode = 0x2003; | 397 | qkeycode = 0x2003; |
397 | } | 398 | } |
398 | } | 399 | } |
399 | 400 | ||
400 | 401 | ||
401 | if (unicode == 0) { // either Qt char, or nothing | 402 | if (unicode == 0) { // either Qt char, or nothing |
402 | 403 | ||
403 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 404 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
404 | 405 | ||
405 | if ( configdlg ) { | 406 | if ( configdlg ) { |
406 | 407 | ||
407 | delete (ConfigDlg *) configdlg; | 408 | delete (ConfigDlg *) configdlg; |
408 | configdlg = 0; | 409 | configdlg = 0; |
409 | } | 410 | } |
410 | else { | 411 | else { |
411 | configdlg = new ConfigDlg (); | 412 | configdlg = new ConfigDlg (); |
412 | connect(configdlg, SIGNAL(setMapToDefault()), | 413 | connect(configdlg, SIGNAL(setMapToDefault()), |
413 | this, SLOT(setMapToDefault())); | 414 | this, SLOT(setMapToDefault())); |
414 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 415 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
415 | this, SLOT(setMapToFile(QString))); | 416 | this, SLOT(setMapToFile(QString))); |
416 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 417 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
417 | this, SLOT(togglePickboard(bool))); | 418 | this, SLOT(togglePickboard(bool))); |
418 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 419 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
419 | this, SLOT(toggleRepeat(bool))); | 420 | this, SLOT(toggleRepeat(bool))); |
420 | connect(configdlg, SIGNAL(reloadKeyboard()), | 421 | connect(configdlg, SIGNAL(reloadKeyboard()), |
421 | this, SLOT(reloadKeyboard())); | 422 | this, SLOT(reloadKeyboard())); |
422 | connect(configdlg, SIGNAL(configDlgClosed()), | 423 | connect(configdlg, SIGNAL(configDlgClosed()), |
423 | this, SLOT(cleanupConfigDlg())); | 424 | this, SLOT(cleanupConfigDlg())); |
424 | configdlg->showMaximized(); | 425 | configdlg->showMaximized(); |
425 | configdlg->show(); | 426 | configdlg->show(); |
426 | configdlg->raise(); | 427 | configdlg->raise(); |
427 | } | 428 | } |
428 | 429 | ||
429 | } else if (qkeycode == Qt::Key_Control) { | 430 | } else if (qkeycode == Qt::Key_Control) { |
430 | need_repaint = TRUE; | 431 | need_repaint = TRUE; |
431 | 432 | ||
432 | if (ctrl) { | 433 | if (ctrl) { |
433 | 434 | ||
434 | *ctrl = 0; | 435 | *ctrl = 0; |
435 | ctrl = 0; | 436 | ctrl = 0; |
436 | 437 | ||
437 | } else { | 438 | } else { |
438 | 439 | ||
439 | ctrl = keys->pressedPtr(row, col); | 440 | ctrl = keys->pressedPtr(row, col); |
440 | need_repaint = TRUE; | 441 | need_repaint = TRUE; |
441 | *ctrl = !keys->pressed(row, col); | 442 | *ctrl = !keys->pressed(row, col); |
442 | 443 | ||
443 | } | 444 | } |
444 | 445 | ||
445 | } else if (qkeycode == Qt::Key_Alt) { | 446 | } else if (qkeycode == Qt::Key_Alt) { |
446 | need_repaint = TRUE; | 447 | need_repaint = TRUE; |
447 | 448 | ||
448 | if (alt) { | 449 | if (alt) { |
449 | *alt = 0; | 450 | *alt = 0; |
450 | alt = 0; | 451 | alt = 0; |
451 | 452 | ||
452 | } else { | 453 | } else { |
453 | 454 | ||
454 | alt = keys->pressedPtr(row, col); | 455 | alt = keys->pressedPtr(row, col); |
455 | need_repaint = TRUE; | 456 | need_repaint = TRUE; |
456 | *alt = !keys->pressed(row, col); | 457 | *alt = !keys->pressed(row, col); |
457 | } | 458 | } |
458 | 459 | ||
459 | } else if (qkeycode == Qt::Key_Shift) { | 460 | } else if (qkeycode == Qt::Key_Shift) { |
460 | need_repaint = TRUE; | 461 | need_repaint = TRUE; |
461 | 462 | ||
462 | if (shift) { | 463 | if (shift) { |
463 | *shift = 0; | 464 | *shift = 0; |
464 | shift = 0; | 465 | shift = 0; |
465 | } | 466 | } |
466 | else { | 467 | else { |
467 | shift = keys->pressedPtr(row, col); | 468 | shift = keys->pressedPtr(row, col); |
468 | *shift = 1; | 469 | *shift = 1; |
469 | if (lock) { | 470 | if (lock) { |
470 | *lock = 0; | 471 | *lock = 0; |
471 | lock = 0; | 472 | lock = 0; |
472 | } | 473 | } |
473 | } | 474 | } |
474 | 475 | ||
475 | 476 | ||
476 | /* | 477 | /* |
477 | * want to be able to hit circumflex/diaeresis -> shift | 478 | * want to be able to hit circumflex/diaeresis -> shift |
478 | * to type in shifted circumflex/diaeresis chars. | 479 | * to type in shifted circumflex/diaeresis chars. |
479 | * same thing with meta | 480 | * same thing with meta |
480 | 481 | ||
481 | if (meta) { *meta = 0; meta = 0; } | 482 | if (meta) { *meta = 0; meta = 0; } |
482 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 483 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
483 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 484 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
484 | 485 | ||
485 | */ | 486 | */ |
486 | 487 | ||
487 | } else if (qkeycode == Qt::Key_CapsLock) { | 488 | } else if (qkeycode == Qt::Key_CapsLock) { |
488 | need_repaint = TRUE; | 489 | need_repaint = TRUE; |
489 | 490 | ||
490 | if (lock) { | 491 | if (lock) { |
491 | *lock = 0; | 492 | *lock = 0; |
492 | lock = 0; | 493 | lock = 0; |
493 | } | 494 | } |
494 | else { | 495 | else { |
495 | lock = keys->pressedPtr(row, col);; | 496 | lock = keys->pressedPtr(row, col);; |
496 | *lock = true;; | 497 | *lock = true;; |
497 | if (shift) { | 498 | if (shift) { |
498 | *shift = 0; | 499 | *shift = 0; |
499 | shift = 0; | 500 | shift = 0; |
500 | } | 501 | } |
501 | } | 502 | } |
502 | 503 | ||
503 | /* | 504 | /* |
504 | if (meta) { *meta = 0; meta = 0; } | 505 | if (meta) { *meta = 0; meta = 0; } |
505 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 506 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
506 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 507 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
507 | */ | 508 | */ |
508 | 509 | ||
509 | } else if (qkeycode == Qt::Key_Meta) { | 510 | } else if (qkeycode == Qt::Key_Meta) { |
510 | need_repaint = TRUE; | 511 | need_repaint = TRUE; |
511 | 512 | ||
512 | if (meta) { | 513 | if (meta) { |
513 | *meta = 0; | 514 | *meta = 0; |
514 | meta = 0; | 515 | meta = 0; |
515 | 516 | ||
516 | } else { | 517 | } else { |
517 | 518 | ||
518 | meta = keys->pressedPtr(row, col); | 519 | meta = keys->pressedPtr(row, col); |
519 | *meta = true; | 520 | *meta = true; |
520 | } | 521 | } |
521 | 522 | ||
522 | // reset all the other keys | 523 | // reset all the other keys |
523 | if (shift) { *shift = 0; shift = 0; } | 524 | if (shift) { *shift = 0; shift = 0; } |
524 | if (lock) { *lock = 0; lock = 0; } | 525 | if (lock) { *lock = 0; lock = 0; } |
525 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 526 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
526 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 527 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
527 | if (baccent) { *baccent = 0; baccent = 0; } | 528 | if (baccent) { *baccent = 0; baccent = 0; } |
528 | if (accent) { *accent = 0; accent = 0; } | 529 | if (accent) { *accent = 0; accent = 0; } |
529 | 530 | ||
530 | // dont need to emit this key... acts same as alt | 531 | // dont need to emit this key... acts same as alt |
531 | qkeycode = 0; | 532 | qkeycode = 0; |
532 | 533 | ||
533 | // circumflex | 534 | // circumflex |
534 | } else if (qkeycode == 0x2000) { | 535 | } else if (qkeycode == 0x2000) { |
535 | need_repaint = TRUE; | 536 | need_repaint = TRUE; |
536 | 537 | ||
537 | if (circumflex) { | 538 | if (circumflex) { |
538 | 539 | ||
539 | *circumflex = 0; | 540 | *circumflex = 0; |
540 | circumflex = 0; | 541 | circumflex = 0; |
541 | 542 | ||
542 | } else { | 543 | } else { |
543 | 544 | ||
544 | circumflex = keys->pressedPtr(row, col); | 545 | circumflex = keys->pressedPtr(row, col); |
545 | *circumflex = true; | 546 | *circumflex = true; |
546 | } | 547 | } |
547 | 548 | ||
548 | /* no need to turn off shift or lock if circumflex | 549 | /* no need to turn off shift or lock if circumflex |
549 | * keys are pressed | 550 | * keys are pressed |
550 | 551 | ||
551 | if (shift) { *shift = 0; shift = 0; } | 552 | if (shift) { *shift = 0; shift = 0; } |
552 | if (lock) { *lock = 0; lock = 0; } | 553 | if (lock) { *lock = 0; lock = 0; } |
553 | 554 | ||
554 | */ | 555 | */ |
555 | 556 | ||
556 | // have to reset all the other keys | 557 | // have to reset all the other keys |
557 | if (meta) { *meta = 0; meta = 0; } | 558 | if (meta) { *meta = 0; meta = 0; } |
558 | if (diaeresis) { | 559 | if (diaeresis) { |
559 | 560 | ||
560 | // *diaeresis and *circumflex point to the same thing | 561 | // *diaeresis and *circumflex point to the same thing |
561 | // when diaeresis is enabled and you hit the circumflex | 562 | // when diaeresis is enabled and you hit the circumflex |
562 | // since they are the same key, it should turn off the | 563 | // since they are the same key, it should turn off the |
563 | // key | 564 | // key |
564 | 565 | ||
565 | *diaeresis = 0; | 566 | *diaeresis = 0; |
566 | diaeresis = 0; | 567 | diaeresis = 0; |
567 | circumflex = 0; | 568 | circumflex = 0; |
568 | } | 569 | } |
569 | 570 | ||
570 | qkeycode = 0; | 571 | qkeycode = 0; |
571 | 572 | ||
572 | // diaeresis | 573 | // diaeresis |
573 | } else if (qkeycode == 0x2001) { | 574 | } else if (qkeycode == 0x2001) { |
574 | need_repaint = TRUE; | 575 | need_repaint = TRUE; |
575 | 576 | ||
576 | if (diaeresis) { | 577 | if (diaeresis) { |
577 | 578 | ||
578 | *diaeresis = 0; | 579 | *diaeresis = 0; |
579 | diaeresis = 0; | 580 | diaeresis = 0; |
580 | 581 | ||
581 | } else { | 582 | } else { |
582 | 583 | ||
583 | diaeresis = keys->pressedPtr(row, col); | 584 | diaeresis = keys->pressedPtr(row, col); |
584 | *diaeresis = true; | 585 | *diaeresis = true; |
585 | } | 586 | } |
586 | 587 | ||
587 | 588 | ||
588 | if (shift) { *shift = 0; shift = 0; } | 589 | if (shift) { *shift = 0; shift = 0; } |
589 | 590 | ||
590 | /* | 591 | /* |
591 | * | 592 | * |
592 | if (lock) { *lock = 0; lock = 0; } | 593 | if (lock) { *lock = 0; lock = 0; } |
593 | * | 594 | * |
594 | */ | 595 | */ |
595 | 596 | ||
596 | if (meta) { *meta = 0; meta = 0; } | 597 | if (meta) { *meta = 0; meta = 0; } |
597 | if (circumflex) { | 598 | if (circumflex) { |
598 | 599 | ||
599 | // *circumflex = 0; | 600 | // *circumflex = 0; |
600 | // | 601 | // |
601 | // same thing the diaeresis pointer points too | 602 | // same thing the diaeresis pointer points too |
602 | 603 | ||
603 | circumflex = 0; | 604 | circumflex = 0; |
604 | } | 605 | } |
605 | 606 | ||
606 | 607 | ||
607 | qkeycode = 0; | 608 | qkeycode = 0; |
608 | 609 | ||
609 | // Back accent | 610 | // Back accent |
610 | } else if (qkeycode == 0x2002) { | 611 | } else if (qkeycode == 0x2002) { |
611 | need_repaint = TRUE; | 612 | need_repaint = TRUE; |
612 | 613 | ||
613 | if (baccent) { | 614 | if (baccent) { |
614 | 615 | ||
615 | *baccent = 0; | 616 | *baccent = 0; |
616 | baccent = 0; | 617 | baccent = 0; |
617 | 618 | ||
618 | } else { | 619 | } else { |
619 | 620 | ||
620 | baccent = keys->pressedPtr(row, col); | 621 | baccent = keys->pressedPtr(row, col); |
621 | *baccent = true; | 622 | *baccent = true; |
622 | } | 623 | } |
623 | 624 | ||
624 | 625 | ||
625 | if (shift) { *shift = 0; shift = 0; } | 626 | if (shift) { *shift = 0; shift = 0; } |
626 | if (meta) { *meta = 0; meta = 0; } | 627 | if (meta) { *meta = 0; meta = 0; } |
627 | if (accent) { *accent = 0; accent = 0; } | 628 | if (accent) { *accent = 0; accent = 0; } |
628 | 629 | ||
629 | qkeycode = 0; | 630 | qkeycode = 0; |
630 | 631 | ||
631 | // Accent | 632 | // Accent |
632 | } else if (qkeycode == 0x2003) { | 633 | } else if (qkeycode == 0x2003) { |
633 | need_repaint = TRUE; | 634 | need_repaint = TRUE; |
634 | 635 | ||
635 | if (accent) { | 636 | if (accent) { |
636 | 637 | ||
637 | *accent = 0; | 638 | *accent = 0; |
638 | accent = 0; | 639 | accent = 0; |
639 | 640 | ||
640 | } else { | 641 | } else { |
641 | 642 | ||
642 | accent = keys->pressedPtr(row, col); | 643 | accent = keys->pressedPtr(row, col); |
643 | *accent = true; | 644 | *accent = true; |
644 | } | 645 | } |
645 | 646 | ||
646 | 647 | ||
647 | if (shift) { *shift = 0; shift = 0; } | 648 | if (shift) { *shift = 0; shift = 0; } |
648 | if (meta) { *meta = 0; meta = 0; } | 649 | if (meta) { *meta = 0; meta = 0; } |
649 | if (baccent) { *baccent = 0; } | 650 | if (baccent) { *baccent = 0; } |
650 | 651 | ||
651 | qkeycode = 0; | 652 | qkeycode = 0; |
652 | } | 653 | } |
653 | 654 | ||
654 | } | 655 | } |
655 | else { // normal char | 656 | else { // normal char |
656 | if ((shift || lock) && keys->shift(unicode)) { | 657 | if ((shift || lock) && keys->shift(unicode)) { |
657 | 658 | ||
658 | // make diaeresis/circumflex -> shift input shifted | 659 | // make diaeresis/circumflex -> shift input shifted |
659 | // diaeresis/circumflex chars | 660 | // diaeresis/circumflex chars |
660 | 661 | ||
661 | if (circumflex && keys->circumflex(keys->shift(unicode))) | 662 | if (circumflex && keys->circumflex(keys->shift(unicode))) |
662 | unicode = keys->circumflex(keys->shift(unicode)); | 663 | unicode = keys->circumflex(keys->shift(unicode)); |
663 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) | 664 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) |
664 | unicode = keys->diaeresis(keys->shift(unicode)); | 665 | unicode = keys->diaeresis(keys->shift(unicode)); |
665 | else if (baccent && keys->baccent(keys->shift(unicode))) | 666 | else if (baccent && keys->baccent(keys->shift(unicode))) |
666 | unicode = keys->baccent(keys->shift(unicode)); | 667 | unicode = keys->baccent(keys->shift(unicode)); |
667 | else if (accent && keys->accent(keys->shift(unicode))) | 668 | else if (accent && keys->accent(keys->shift(unicode))) |
668 | unicode = keys->accent(keys->shift(unicode)); | 669 | unicode = keys->accent(keys->shift(unicode)); |
669 | else if (meta && keys->meta(keys->shift(unicode))) | 670 | else if (meta && keys->meta(keys->shift(unicode))) |
670 | unicode = keys->meta(keys->shift(unicode)); | 671 | unicode = keys->meta(keys->shift(unicode)); |
671 | else | 672 | else |
672 | unicode = keys->shift(unicode); | 673 | unicode = keys->shift(unicode); |
673 | } | 674 | } |
674 | else if (meta && keys->meta(unicode)) { | 675 | else if (meta && keys->meta(unicode)) { |
675 | unicode = keys->meta(unicode); | 676 | unicode = keys->meta(unicode); |
676 | } | 677 | } |
677 | else if (circumflex && keys->circumflex(unicode)) { | 678 | else if (circumflex && keys->circumflex(unicode)) { |
678 | unicode = keys->circumflex(unicode); | 679 | unicode = keys->circumflex(unicode); |
679 | } | 680 | } |
680 | else if (diaeresis && keys->diaeresis(unicode)) { | 681 | else if (diaeresis && keys->diaeresis(unicode)) { |
681 | 682 | ||
682 | unicode = keys->diaeresis(unicode); | 683 | unicode = keys->diaeresis(unicode); |
683 | } | 684 | } |
684 | else if (baccent && keys->baccent(unicode)) { | 685 | else if (baccent && keys->baccent(unicode)) { |
685 | unicode = keys->baccent(unicode); | 686 | unicode = keys->baccent(unicode); |
686 | } | 687 | } |
687 | else if (accent && keys->accent(unicode)) { | 688 | else if (accent && keys->accent(unicode)) { |
688 | unicode = keys->accent(unicode); | 689 | unicode = keys->accent(unicode); |
689 | } | 690 | } |
690 | } | 691 | } |
691 | 692 | ||
692 | // korean parsing | 693 | // korean parsing |
693 | if (keys->lang == "ko") { | 694 | if (keys->lang == "ko") { |
694 | 695 | ||
695 | unicode = parseKoreanInput(unicode); | 696 | unicode = parseKoreanInput(unicode); |
696 | } | 697 | } |
697 | 698 | ||
698 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 699 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
699 | 700 | ||
700 | if ('A' <= unicode && unicode <= 'z' && modifiers) { | 701 | if ('A' <= unicode && unicode <= 'z' && modifiers) { |
701 | 702 | ||
702 | qkeycode = QChar(unicode).upper(); | 703 | qkeycode = QChar(unicode).upper(); |
703 | unicode = qkeycode - '@'; | 704 | unicode = qkeycode - '@'; |
704 | } | 705 | } |
705 | 706 | ||
706 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); | 707 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); |
707 | 708 | ||
708 | // pickboard stuff | 709 | // pickboard stuff |
709 | if (usePicks) { | 710 | if (usePicks) { |
710 | 711 | ||
711 | KeyboardConfig *dc = picks->dc; | 712 | KeyboardConfig *dc = picks->dc; |
712 | 713 | ||
713 | if (dc) { | 714 | if (dc) { |
714 | if (qkeycode == Qt::Key_Backspace) { | 715 | if (qkeycode == Qt::Key_Backspace) { |
715 | dc->input.remove(dc->input.last()); // remove last input | 716 | dc->input.remove(dc->input.last()); // remove last input |
716 | dc->decBackspaces(); | 717 | dc->decBackspaces(); |
717 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 718 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
718 | dc->input.clear(); | 719 | dc->input.clear(); |
719 | dc->resetBackspaces(); | 720 | dc->resetBackspaces(); |
720 | } else { | 721 | } else { |
721 | dc->add(QString(QChar(unicode))); | 722 | dc->add(QString(QChar(unicode))); |
722 | dc->incBackspaces(); | 723 | dc->incBackspaces(); |
723 | } | 724 | } |
724 | } | 725 | } |
725 | picks->repaint(); | 726 | picks->repaint(); |
726 | } | 727 | } |
727 | 728 | ||
728 | 729 | ||
729 | // painting | 730 | // painting |
730 | pressed = TRUE; | 731 | pressed = TRUE; |
731 | 732 | ||
732 | pressedKeyRow = row; | 733 | pressedKeyRow = row; |
733 | pressedKeyCol = col; | 734 | pressedKeyCol = col; |
734 | 735 | ||
735 | if (need_repaint) repaint(FALSE); | 736 | if (need_repaint) repaint(FALSE); |
736 | else { // just paint the one key pressed | 737 | else { // just paint the one key pressed |
737 | 738 | ||
738 | 739 | ||
739 | 740 | ||
740 | QPainter p(this); | 741 | QPainter p(this); |
741 | drawKeyboard(p, row, col); | 742 | drawKeyboard(p, row, col); |
742 | 743 | ||
743 | } | 744 | } |
744 | 745 | ||
745 | if (useRepeat) repeatTimer->start( 800 ); | 746 | if (useRepeat) repeatTimer->start( 800 ); |
746 | //pressTid = startTimer(80); | 747 | //pressTid = startTimer(80); |
747 | 748 | ||
748 | } | 749 | } |
749 | 750 | ||
750 | 751 | ||
751 | /* Keyboard::mouseReleaseEvent {{{1 */ | 752 | /* Keyboard::mouseReleaseEvent {{{1 */ |
752 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 753 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
753 | { | 754 | { |
754 | pressed = FALSE; | 755 | pressed = FALSE; |
755 | //if ( pressTid == 0 ) | 756 | //if ( pressTid == 0 ) |
756 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 757 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
757 | if ( unicode != -1 ) { | 758 | if ( unicode != -1 ) { |
758 | emit key( unicode, qkeycode, modifiers, false, false ); | 759 | emit key( unicode, qkeycode, modifiers, false, false ); |
759 | repeatTimer->stop(); | 760 | repeatTimer->stop(); |
760 | } | 761 | } |
761 | #endif | 762 | #endif |
762 | if (shift && unicode != 0) { | 763 | if (shift && unicode != 0) { |
763 | 764 | ||
764 | 765 | ||
765 | *shift = 0; // unpress shift key | 766 | *shift = 0; // unpress shift key |
766 | shift = 0; // reset the shift pointer | 767 | shift = 0; // reset the shift pointer |
767 | repaint(FALSE); | 768 | repaint(FALSE); |
768 | 769 | ||
769 | } | 770 | } |
770 | if (ctrl && unicode != 0) { | 771 | if (ctrl && unicode != 0) { |
771 | 772 | ||
772 | *ctrl = 0; | 773 | *ctrl = 0; |
773 | ctrl = 0; | 774 | ctrl = 0; |
774 | repaint(FALSE); | 775 | repaint(FALSE); |
775 | 776 | ||
776 | } | 777 | } |
777 | if (alt && alt != 0) { | 778 | if (alt && alt != 0) { |
778 | 779 | ||
779 | *alt = 0; | 780 | *alt = 0; |
780 | alt = 0; | 781 | alt = 0; |
781 | repaint(FALSE); | 782 | repaint(FALSE); |
782 | 783 | ||
783 | } | 784 | } |
784 | 785 | ||
785 | /* | 786 | /* |
786 | * do not make the meta key release after being pressed | 787 | * do not make the meta key release after being pressed |
787 | * | 788 | * |
788 | 789 | ||
789 | else if (meta && unicode != 0) { | 790 | else if (meta && unicode != 0) { |
790 | 791 | ||
791 | *meta = 0; | 792 | *meta = 0; |
792 | meta = 0; | 793 | meta = 0; |
793 | repaint(FALSE); | 794 | repaint(FALSE); |
794 | } | 795 | } |
795 | 796 | ||
796 | */ | 797 | */ |
797 | 798 | ||
798 | else clearHighlight(); | 799 | else clearHighlight(); |
799 | } | 800 | } |
800 | 801 | ||
801 | /* Keyboard::timerEvent {{{1 */ | 802 | /* Keyboard::timerEvent {{{1 */ |
802 | 803 | ||
803 | /* dont know what this does, but i think it is here so that if your screen | 804 | /* dont know what this does, but i think it is here so that if your screen |
804 | * sticks (like on an ipaq) then it will stop repeating if you click another | 805 | * sticks (like on an ipaq) then it will stop repeating if you click another |
805 | * key... but who knows what anything does in this thing anyway? | 806 | * key... but who knows what anything does in this thing anyway? |
806 | 807 | ||
807 | void Keyboard::timerEvent(QTimerEvent* e) | 808 | void Keyboard::timerEvent(QTimerEvent* e) |
808 | { | 809 | { |
809 | if ( e->timerId() == pressTid ) { | 810 | if ( e->timerId() == pressTid ) { |
810 | killTimer(pressTid); | 811 | killTimer(pressTid); |
811 | pressTid = 0; | 812 | pressTid = 0; |
812 | if ( !pressed ) | 813 | if ( !pressed ) |
813 | cout << "calling clearHighlight from timerEvent\n"; | 814 | cout << "calling clearHighlight from timerEvent\n"; |
814 | //clearHighlight(); | 815 | //clearHighlight(); |
815 | } | 816 | } |
816 | } | 817 | } |
817 | */ | 818 | */ |
818 | 819 | ||
819 | void Keyboard::repeat() | 820 | void Keyboard::repeat() |
820 | { | 821 | { |
821 | 822 | ||
822 | repeatTimer->start( 200 ); | 823 | repeatTimer->start( 200 ); |
823 | emit key( unicode, qkeycode, modifiers, true, true ); | 824 | emit key( unicode, qkeycode, modifiers, true, true ); |
824 | } | 825 | } |
825 | 826 | ||
826 | void Keyboard::clearHighlight() | 827 | void Keyboard::clearHighlight() |
827 | { | 828 | { |
828 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 829 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
829 | int tmpRow = pressedKeyRow; | 830 | int tmpRow = pressedKeyRow; |
830 | int tmpCol = pressedKeyCol; | 831 | int tmpCol = pressedKeyCol; |
831 | 832 | ||
832 | pressedKeyRow = -1; | 833 | pressedKeyRow = -1; |
833 | pressedKeyCol = -1; | 834 | pressedKeyCol = -1; |
834 | 835 | ||
835 | QPainter p(this); | 836 | QPainter p(this); |
836 | drawKeyboard(p, tmpRow, tmpCol); | 837 | drawKeyboard(p, tmpRow, tmpCol); |
837 | } | 838 | } |
838 | } | 839 | } |
839 | 840 | ||
840 | 841 | ||
841 | /* Keyboard::sizeHint {{{1 */ | 842 | /* Keyboard::sizeHint {{{1 */ |
842 | QSize Keyboard::sizeHint() const | 843 | QSize Keyboard::sizeHint() const |
843 | { | 844 | { |
844 | QFontMetrics fm=fontMetrics(); | 845 | QFontMetrics fm=fontMetrics(); |
845 | int keyHeight = fm.lineSpacing() + 2; | 846 | int keyHeight = fm.lineSpacing() + 2; |
846 | 847 | ||
847 | return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); | 848 | return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); |
848 | } | 849 | } |
849 | 850 | ||
850 | 851 | ||
851 | void Keyboard::resetState() | 852 | void Keyboard::resetState() |
852 | { | 853 | { |
853 | if (shift) { *shift = 0; shift = 0; } | 854 | if (shift) { *shift = 0; shift = 0; } |
854 | if (lock) {*lock = 0; lock = 0; } | 855 | if (lock) {*lock = 0; lock = 0; } |
855 | if (meta) { *meta = 0; meta = 0; } | 856 | if (meta) { *meta = 0; meta = 0; } |
856 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 857 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
857 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 858 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
858 | if (baccent) { *baccent = 0; baccent = 0; } | 859 | if (baccent) { *baccent = 0; baccent = 0; } |
859 | if (accent) { *accent = 0; accent = 0; } | 860 | if (accent) { *accent = 0; accent = 0; } |
860 | 861 | ||
861 | schar = mchar = echar = 0; | 862 | schar = mchar = echar = 0; |
862 | picks->resetState(); | 863 | picks->resetState(); |
863 | } | 864 | } |
864 | 865 | ||
865 | /* Keyboard::togglePickboard {{{1 */ | 866 | /* Keyboard::togglePickboard {{{1 */ |
866 | void Keyboard::togglePickboard(bool on_off) | 867 | void Keyboard::togglePickboard(bool on_off) |
867 | { | 868 | { |
868 | usePicks = on_off; | 869 | usePicks = on_off; |
869 | if (usePicks) { | 870 | if (usePicks) { |
870 | picks->show(); | 871 | picks->show(); |
871 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 872 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
872 | //adjustSize(); | 873 | //adjustSize(); |
873 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 874 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
874 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 875 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
875 | } else { | 876 | } else { |
876 | 877 | ||
877 | picks->hide(); | 878 | picks->hide(); |
878 | picks->resetState(); | 879 | picks->resetState(); |
879 | //move(x(), y() + picks->height()); | 880 | //move(x(), y() + picks->height()); |
880 | //adjustSize(); | 881 | //adjustSize(); |
881 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 882 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
882 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 883 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
883 | 884 | ||
884 | } | 885 | } |
885 | /* | 886 | /* |
886 | * this closes && opens the input method | 887 | * this closes && opens the input method |
887 | */ | 888 | */ |
888 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 889 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
889 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 890 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
890 | } | 891 | } |
891 | 892 | ||
892 | void Keyboard::toggleRepeat(bool on) { | 893 | void Keyboard::toggleRepeat(bool on) { |
893 | 894 | ||
894 | useRepeat = on; | 895 | useRepeat = on; |
895 | //cout << "setting useRepeat to: " << useRepeat << "\n"; | 896 | //cout << "setting useRepeat to: " << useRepeat << "\n"; |
896 | } | 897 | } |
897 | 898 | ||
898 | void Keyboard::cleanupConfigDlg() { | 899 | void Keyboard::cleanupConfigDlg() { |
899 | 900 | ||
900 | if ( configdlg ) { | 901 | if ( configdlg ) { |
901 | delete (ConfigDlg *) configdlg; | 902 | delete (ConfigDlg *) configdlg; |
902 | configdlg = 0; | 903 | configdlg = 0; |
903 | } | 904 | } |
904 | } | 905 | } |
905 | 906 | ||
906 | /* Keyboard::setMapTo ... {{{1 */ | 907 | /* Keyboard::setMapTo ... {{{1 */ |
907 | void Keyboard::setMapToDefault() { | 908 | void Keyboard::setMapToDefault() { |
908 | 909 | ||
909 | 910 | ||
910 | /* load current locale language map */ | 911 | /* load current locale language map */ |
911 | Config *config = new Config("locale"); | 912 | Config *config = new Config("locale"); |
912 | config->setGroup( "Language" ); | 913 | config->setGroup( "Language" ); |
913 | QString l = config->readEntry( "Language" , "en" ); | 914 | QString l = config->readEntry( "Language" , "en" ); |
914 | delete config; | 915 | delete config; |
915 | 916 | ||
916 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" | 917 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" |
917 | + l + ".keymap"; | 918 | + l + ".keymap"; |
918 | 919 | ||
919 | /* save change to multikey config file */ | 920 | /* save change to multikey config file */ |
920 | config = new Config("multikey"); | 921 | config = new Config("multikey"); |
921 | config->setGroup ("keymaps"); | 922 | config->setGroup ("keymaps"); |
922 | config->writeEntry ("current", key_map); // default closed | 923 | config->writeEntry ("current", key_map); // default closed |
923 | delete config; | 924 | delete config; |
924 | 925 | ||
925 | int prevRows = keys->rows(); | 926 | int prevRows = keys->rows(); |
926 | 927 | ||
927 | delete keys; | 928 | delete keys; |
928 | keys = new Keys(key_map); | 929 | keys = new Keys(key_map); |
929 | 930 | ||
930 | // have to repaint the keyboard | 931 | // have to repaint the keyboard |
931 | if (prevRows != keys->rows()) { | 932 | if (prevRows != keys->rows()) { |
932 | 933 | ||
933 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 934 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
934 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 935 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
935 | 936 | ||
936 | } else repaint(FALSE); | 937 | } else repaint(FALSE); |
937 | 938 | ||
938 | resetState(); | 939 | resetState(); |
939 | } | 940 | } |
940 | 941 | ||
941 | void Keyboard::setMapToFile(QString map) { | 942 | void Keyboard::setMapToFile(QString map) { |
942 | 943 | ||
943 | /* save change to multikey config file */ | 944 | /* save change to multikey config file */ |
944 | Config *config = new Config("multikey"); | 945 | Config *config = new Config("multikey"); |
945 | config->setGroup ("keymaps"); | 946 | config->setGroup ("keymaps"); |
946 | config->writeEntry ("current", map); // default closed | 947 | config->writeEntry ("current", map); // default closed |
947 | 948 | ||
948 | delete config; | 949 | delete config; |
949 | 950 | ||
950 | int prevRows = keys->rows(); | 951 | int prevRows = keys->rows(); |
951 | 952 | ||
952 | delete keys; | 953 | delete keys; |
953 | if (QFile(map).exists()) | 954 | if (QFile(map).exists()) |
954 | keys = new Keys(map); | 955 | keys = new Keys(map); |
955 | else | 956 | else |
956 | keys = new Keys(); | 957 | keys = new Keys(); |
957 | 958 | ||
958 | if (keys->rows() != prevRows) { | 959 | if (keys->rows() != prevRows) { |
959 | 960 | ||
960 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 961 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
961 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 962 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
962 | } | 963 | } |
963 | else repaint(FALSE); | 964 | else repaint(FALSE); |
964 | 965 | ||
965 | resetState(); | 966 | resetState(); |
966 | } | 967 | } |
967 | 968 | ||
968 | /* Keybaord::reloadKeyboard {{{1 */ | 969 | /* Keybaord::reloadKeyboard {{{1 */ |
969 | void Keyboard::reloadKeyboard() { | 970 | void Keyboard::reloadKeyboard() { |
970 | 971 | ||
971 | // reload colors and redraw | 972 | // reload colors and redraw |
972 | loadKeyboardColors(); | 973 | loadKeyboardColors(); |
973 | repaint(); | 974 | repaint(); |
974 | 975 | ||
975 | } | 976 | } |
976 | 977 | ||
977 | void Keyboard::loadKeyboardColors() { | 978 | void Keyboard::loadKeyboardColors() { |
978 | 979 | ||
979 | Config config ("multikey"); | 980 | Config config ("multikey"); |
980 | config.setGroup("colors"); | 981 | config.setGroup("colors"); |
981 | 982 | ||
982 | QStringList color; | 983 | QStringList color; |
983 | color = config.readListEntry("keycolor", QChar(',')); | 984 | color = config.readListEntry("keycolor", QChar(',')); |
984 | if (color.isEmpty()) { | 985 | if (color.isEmpty()) { |
985 | color = QStringList::split(",", "240,240,240"); | 986 | color = QStringList::split(",", "240,240,240"); |
986 | config.writeEntry("keycolor", color.join(",")); | 987 | config.writeEntry("keycolor", color.join(",")); |
987 | 988 | ||
988 | } | 989 | } |
989 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 990 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
990 | 991 | ||
991 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 992 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
992 | if (color.isEmpty()) { | 993 | if (color.isEmpty()) { |
993 | color = QStringList::split(",", "171,183,198"); | 994 | color = QStringList::split(",", "171,183,198"); |
994 | config.writeEntry("keycolor_pressed", color.join(",")); | 995 | config.writeEntry("keycolor_pressed", color.join(",")); |
995 | 996 | ||
996 | } | 997 | } |
997 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 998 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
998 | 999 | ||
999 | color = config.readListEntry("keycolor_lines", QChar(',')); | 1000 | color = config.readListEntry("keycolor_lines", QChar(',')); |
1000 | if (color.isEmpty()) { | 1001 | if (color.isEmpty()) { |
1001 | color = QStringList::split(",", "138,148,160"); | 1002 | color = QStringList::split(",", "138,148,160"); |
1002 | config.writeEntry("keycolor_lines", color.join(",")); | 1003 | config.writeEntry("keycolor_lines", color.join(",")); |
1003 | 1004 | ||
1004 | } | 1005 | } |
1005 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 1006 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
1006 | 1007 | ||
1007 | color = config.readListEntry("textcolor", QChar(',')); | 1008 | color = config.readListEntry("textcolor", QChar(',')); |
1008 | if (color.isEmpty()) { | 1009 | if (color.isEmpty()) { |
1009 | color = QStringList::split(",", "43,54,68"); | 1010 | color = QStringList::split(",", "43,54,68"); |
1010 | config.writeEntry("textcolor", color.join(",")); | 1011 | config.writeEntry("textcolor", color.join(",")); |
1011 | 1012 | ||
1012 | } | 1013 | } |
1013 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 1014 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
1014 | 1015 | ||
1015 | } | 1016 | } |
1016 | 1017 | ||
1017 | /* korean input functions {{{1 | 1018 | /* korean input functions {{{1 |
1018 | * | 1019 | * |
1019 | * TODO | 1020 | * TODO |
1020 | * one major problem with this implementation is that you can't move the | 1021 | * one major problem with this implementation is that you can't move the |
1021 | * cursor after inputing korean chars, otherwise it will eat up and replace | 1022 | * cursor after inputing korean chars, otherwise it will eat up and replace |
1022 | * the char before the cursor you move to. fix that | 1023 | * the char before the cursor you move to. fix that |
1023 | * | 1024 | * |
1024 | * make backspace delete one single char, not the whole thing if still | 1025 | * make backspace delete one single char, not the whole thing if still |
1025 | * editing. | 1026 | * editing. |
1026 | * | 1027 | * |
1027 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 1028 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
1028 | * | 1029 | * |
1029 | * how korean input works | 1030 | * how korean input works |
1030 | * | 1031 | * |
1031 | * all following chars means unicode char value and are in hex | 1032 | * all following chars means unicode char value and are in hex |
1032 | * | 1033 | * |
1033 | * 초음 = schar (start char) | 1034 | * 초음 = schar (start char) |
1034 | * 중음 = mchar (middle char) | 1035 | * 중음 = mchar (middle char) |
1035 | * 끝음 = echar (end char) | 1036 | * 끝음 = echar (end char) |
1036 | * | 1037 | * |
1037 | * there are 19 schars. unicode position is at 1100 - 1112 | 1038 | * there are 19 schars. unicode position is at 1100 - 1112 |
1038 | * there are 21 mchars. unicode position is at 1161 - 1175 | 1039 | * there are 21 mchars. unicode position is at 1161 - 1175 |
1039 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 1040 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
1040 | * | 1041 | * |
1041 | * the map with everything combined is at ac00 - d7a3 | 1042 | * the map with everything combined is at ac00 - d7a3 |
1042 | * | 1043 | * |
1043 | */ | 1044 | */ |
1044 | 1045 | ||
1045 | ushort Keyboard::parseKoreanInput (ushort c) { | 1046 | ushort Keyboard::parseKoreanInput (ushort c) { |
1046 | 1047 | ||
1047 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) | 1048 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) |
1048 | || | 1049 | || |
1049 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode | 1050 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode |
1050 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { | 1051 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { |
1051 | 1052 | ||
1052 | schar = 0, mchar = 0, echar = 0; | 1053 | schar = 0, mchar = 0, echar = 0; |
1053 | return c; | 1054 | return c; |
1054 | } | 1055 | } |
1055 | 1056 | ||
1056 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input | 1057 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input |
1057 | 1058 | ||
1058 | if (schar == 0 || (schar != 0 && mchar == 0)) { | 1059 | if (schar == 0 || (schar != 0 && mchar == 0)) { |
1059 | schar = c; mchar = 0; echar = 0; | 1060 | schar = c; mchar = 0; echar = 0; |
1060 | return c; | 1061 | return c; |
1061 | } | 1062 | } |
1062 | else if (mchar != 0) { | 1063 | else if (mchar != 0) { |
1063 | 1064 | ||
1064 | if (echar == 0) { | 1065 | if (echar == 0) { |
1065 | 1066 | ||
1066 | if (!(echar = constoe(c))) { | 1067 | if (!(echar = constoe(c))) { |
1067 | 1068 | ||
1068 | schar = c; mchar = 0; echar = 0; | 1069 | schar = c; mchar = 0; echar = 0; |
1069 | return c; | 1070 | return c; |
1070 | } | 1071 | } |
1071 | 1072 | ||
1072 | } | 1073 | } |
1073 | else { // must figure out what the echar is | 1074 | else { // must figure out what the echar is |
1074 | 1075 | ||
1075 | if (echar == 0x11a8) { // ㄱ | 1076 | if (echar == 0x11a8) { // ㄱ |
1076 | 1077 | ||
1077 | if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ | 1078 | if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ |
1078 | else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ | 1079 | else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ |
1079 | else { | 1080 | else { |
1080 | schar = c; mchar = 0; echar = 0; | 1081 | schar = c; mchar = 0; echar = 0; |
1081 | return c; | 1082 | return c; |
1082 | } | 1083 | } |
1083 | 1084 | ||
1084 | } else if (echar == 0x11ab) { // ㄴ | 1085 | } else if (echar == 0x11ab) { // ㄴ |
1085 | 1086 | ||
1086 | if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ | 1087 | if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ |
1087 | else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ | 1088 | else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ |
1088 | else { | 1089 | else { |
1089 | schar = c; mchar = 0; echar = 0; | 1090 | schar = c; mchar = 0; echar = 0; |
1090 | return c; | 1091 | return c; |
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | } else if (echar == 0x11af) { // ㄹ | 1094 | } else if (echar == 0x11af) { // ㄹ |
1094 | 1095 | ||
1095 | if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ | 1096 | if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ |
1096 | else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ | 1097 | else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ |
1097 | else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ | 1098 | else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ |
1098 | else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ | 1099 | else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ |
1099 | else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ | 1100 | else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ |
1100 | else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ | 1101 | else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ |
1101 | else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ | 1102 | else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ |
1102 | else { | 1103 | else { |
1103 | schar = c; mchar = 0; echar = 0; | 1104 | schar = c; mchar = 0; echar = 0; |
1104 | return c; | 1105 | return c; |
1105 | } | 1106 | } |
1106 | 1107 | ||
1107 | } else if (echar == 0x11b8) { // ㅂ | 1108 | } else if (echar == 0x11b8) { // ㅂ |
1108 | 1109 | ||
1109 | if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ | 1110 | if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ |
1110 | else { | 1111 | else { |
1111 | schar = c; mchar = 0; echar = 0; | 1112 | schar = c; mchar = 0; echar = 0; |
1112 | return c; | 1113 | return c; |
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | } else if (echar == 0x11ba) { // ㅅ | 1116 | } else if (echar == 0x11ba) { // ㅅ |
1116 | 1117 | ||
1117 | if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ | 1118 | if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ |
1118 | else { | 1119 | else { |
1119 | schar = c; mchar = 0; echar = 0; | 1120 | schar = c; mchar = 0; echar = 0; |
1120 | return c; | 1121 | return c; |
1121 | } | 1122 | } |
1122 | 1123 | ||
1123 | } else { // if any other char, cannot combine chars | 1124 | } else { // if any other char, cannot combine chars |
1124 | 1125 | ||
1125 | schar = c; mchar = 0; echar = 0; | 1126 | schar = c; mchar = 0; echar = 0; |
1126 | return c; | 1127 | return c; |
1127 | } | 1128 | } |
1128 | 1129 | ||
1129 | unicode = echar; | 1130 | unicode = echar; |
1130 | } | 1131 | } |
1131 | } | 1132 | } |
1132 | 1133 | ||
1133 | } | 1134 | } |
1134 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input | 1135 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input |
1135 | 1136 | ||
1136 | if (schar != 0 && mchar == 0) { mchar = c; } | 1137 | if (schar != 0 && mchar == 0) { mchar = c; } |
1137 | 1138 | ||
1138 | else if (schar != 0 && mchar != 0 && echar == 0) { | 1139 | else if (schar != 0 && mchar != 0 && echar == 0) { |
1139 | 1140 | ||
1140 | switch (mchar) { | 1141 | switch (mchar) { |
1141 | case 0x1169: | 1142 | case 0x1169: |
1142 | if (c == 0x1161) mchar = 0x116a; | 1143 | if (c == 0x1161) mchar = 0x116a; |
1143 | else if (c == 0x1162) mchar = 0x116b; | 1144 | else if (c == 0x1162) mchar = 0x116b; |
1144 | else if (c == 0x1175) mchar = 0x116c; | 1145 | else if (c == 0x1175) mchar = 0x116c; |
1145 | else { | 1146 | else { |
1146 | schar = 0; mchar = 0; echar = 0; | 1147 | schar = 0; mchar = 0; echar = 0; |
1147 | return c; | 1148 | return c; |
1148 | } | 1149 | } |
1149 | break; | 1150 | break; |
1150 | case 0x116e: | 1151 | case 0x116e: |
1151 | if (c == 0x1165) mchar = 0x116f; | 1152 | if (c == 0x1165) mchar = 0x116f; |
1152 | else if (c == 0x1166) mchar = 0x1170; | 1153 | else if (c == 0x1166) mchar = 0x1170; |
1153 | else if (c == 0x1175) mchar = 0x1171; | 1154 | else if (c == 0x1175) mchar = 0x1171; |
1154 | else { | 1155 | else { |
1155 | schar = 0; mchar = 0; echar = 0; | 1156 | schar = 0; mchar = 0; echar = 0; |
1156 | return c; | 1157 | return c; |
1157 | } | 1158 | } |
1158 | break; | 1159 | break; |
1159 | case 0x1173: | 1160 | case 0x1173: |
1160 | if (c == 0x1175) mchar = 0x1174; | 1161 | if (c == 0x1175) mchar = 0x1174; |
1161 | else { | 1162 | else { |
1162 | schar = 0; mchar = 0; echar = 0; | 1163 | schar = 0; mchar = 0; echar = 0; |
1163 | return c; | 1164 | return c; |
1164 | } | 1165 | } |
1165 | break; | 1166 | break; |
1166 | default: | 1167 | default: |
1167 | schar = 0; mchar = 0; echar = 0; | 1168 | schar = 0; mchar = 0; echar = 0; |
1168 | return c; | 1169 | return c; |
1169 | } | 1170 | } |
1170 | } | 1171 | } |
1171 | else if (schar != 0 && mchar != 0 && echar != 0) { | 1172 | else if (schar != 0 && mchar != 0 && echar != 0) { |
1172 | 1173 | ||
1173 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1174 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1174 | 1175 | ||
1175 | ushort prev = 0; | 1176 | ushort prev = 0; |
1176 | switch (echar) { | 1177 | switch (echar) { |
1177 | /* | 1178 | /* |
1178 | case 0x11a9: | 1179 | case 0x11a9: |
1179 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1180 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1180 | schar = 0x1100; | 1181 | schar = 0x1100; |
1181 | break; | 1182 | break; |
1182 | */ | 1183 | */ |
1183 | case 0x11aa: | 1184 | case 0x11aa: |
1184 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1185 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1185 | schar = 0x1109; | 1186 | schar = 0x1109; |
1186 | break; | 1187 | break; |
1187 | case 0x11ac: | 1188 | case 0x11ac: |
1188 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1189 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1189 | schar = 0x110c; | 1190 | schar = 0x110c; |
1190 | break; | 1191 | break; |
1191 | case 0x11ad: | 1192 | case 0x11ad: |
1192 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1193 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1193 | schar = 0x1112; | 1194 | schar = 0x1112; |
1194 | break; | 1195 | break; |
1195 | case 0x11b0: | 1196 | case 0x11b0: |
1196 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1197 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1197 | schar = 0x1100; | 1198 | schar = 0x1100; |
1198 | break; | 1199 | break; |
1199 | case 0x11b1: | 1200 | case 0x11b1: |
1200 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1201 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1201 | schar = 0x1106; | 1202 | schar = 0x1106; |
1202 | break; | 1203 | break; |
1203 | case 0x11b2: | 1204 | case 0x11b2: |
1204 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1205 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1205 | schar = 0x1107; | 1206 | schar = 0x1107; |
1206 | break; | 1207 | break; |
1207 | case 0x11b3: | 1208 | case 0x11b3: |
1208 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1209 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1209 | schar = 0x1109; | 1210 | schar = 0x1109; |
1210 | break; | 1211 | break; |
1211 | case 0x11b4: | 1212 | case 0x11b4: |
1212 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1213 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1213 | schar = 0x1110; | 1214 | schar = 0x1110; |
1214 | break; | 1215 | break; |
1215 | case 0x11b9: | 1216 | case 0x11b9: |
1216 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 1217 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
1217 | schar = 0x1109; | 1218 | schar = 0x1109; |
1218 | break; | 1219 | break; |
1219 | /* | 1220 | /* |
1220 | case 0x11bb: | 1221 | case 0x11bb: |
1221 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 1222 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
1222 | schar = 0x1109; | 1223 | schar = 0x1109; |
1223 | break; | 1224 | break; |
1224 | */ | 1225 | */ |
1225 | default: | 1226 | default: |
1226 | 1227 | ||
1227 | if (constoe(echar)) { | 1228 | if (constoe(echar)) { |
1228 | 1229 | ||
1229 | prev = combineKoreanChars(schar, mchar, 0); | 1230 | prev = combineKoreanChars(schar, mchar, 0); |
1230 | schar = constoe(echar); | 1231 | schar = constoe(echar); |
1231 | } | 1232 | } |
1232 | break; | 1233 | break; |
1233 | } | 1234 | } |
1234 | 1235 | ||
1235 | emit key( prev, prev, 0, true, false ); | 1236 | emit key( prev, prev, 0, true, false ); |
1236 | 1237 | ||
1237 | mchar = c; echar = 0; | 1238 | mchar = c; echar = 0; |
1238 | 1239 | ||
1239 | return combineKoreanChars(schar, mchar, 0); | 1240 | return combineKoreanChars(schar, mchar, 0); |
1240 | 1241 | ||
1241 | } | 1242 | } |
1242 | else { | 1243 | else { |
1243 | schar = 0; mchar = 0; echar = 0; | 1244 | schar = 0; mchar = 0; echar = 0; |
1244 | return c; | 1245 | return c; |
1245 | } | 1246 | } |
1246 | 1247 | ||
1247 | } | 1248 | } |
1248 | else /*if (c == ' ')*/ return c; | 1249 | else /*if (c == ' ')*/ return c; |
1249 | 1250 | ||
1250 | 1251 | ||
1251 | // and now... finally delete previous char, and return new char | 1252 | // and now... finally delete previous char, and return new char |
1252 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1253 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1253 | 1254 | ||
1254 | 1255 | ||
1255 | return combineKoreanChars( schar, mchar, echar); | 1256 | return combineKoreanChars( schar, mchar, echar); |
1256 | 1257 | ||
1257 | } | 1258 | } |
1258 | 1259 | ||
1259 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 1260 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
1260 | 1261 | ||
1261 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 1262 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
1262 | 1263 | ||
1263 | } | 1264 | } |
1264 | 1265 | ||
1265 | ushort Keyboard::constoe(const ushort c) { | 1266 | ushort Keyboard::constoe(const ushort c) { |
1266 | 1267 | ||
1267 | // converts schars to echars if possible | 1268 | // converts schars to echars if possible |
1268 | 1269 | ||
1269 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 1270 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
1270 | 1271 | ||
1271 | switch (c) { | 1272 | switch (c) { |
1272 | case 0x1100: return 0x11a8; | 1273 | case 0x1100: return 0x11a8; |
1273 | case 0x1101: return 0x11a9; | 1274 | case 0x1101: return 0x11a9; |
1274 | case 0x1102: return 0x11ab; | 1275 | case 0x1102: return 0x11ab; |
1275 | case 0x1103: return 0x11ae; | 1276 | case 0x1103: return 0x11ae; |
1276 | case 0x1105: return 0x11af; | 1277 | case 0x1105: return 0x11af; |
1277 | case 0x1106: return 0x11b7; | 1278 | case 0x1106: return 0x11b7; |
1278 | case 0x1107: return 0x11b8; | 1279 | case 0x1107: return 0x11b8; |
1279 | case 0x1109: return 0x11ba; | 1280 | case 0x1109: return 0x11ba; |
1280 | case 0x110a: return 0x11bb; | 1281 | case 0x110a: return 0x11bb; |
1281 | case 0x110b: return 0x11bc; | 1282 | case 0x110b: return 0x11bc; |
1282 | case 0x110c: return 0x11bd; | 1283 | case 0x110c: return 0x11bd; |
1283 | case 0x110e: return 0x11be; | 1284 | case 0x110e: return 0x11be; |
1284 | case 0x110f: return 0x11bf; | 1285 | case 0x110f: return 0x11bf; |
1285 | case 0x1110: return 0x11c0; | 1286 | case 0x1110: return 0x11c0; |
1286 | case 0x1111: return 0x11c1; | 1287 | case 0x1111: return 0x11c1; |
1287 | case 0x1112: return 0x11c2; | 1288 | case 0x1112: return 0x11c2; |
1288 | default: return 0; | 1289 | default: return 0; |
1289 | 1290 | ||
1290 | } | 1291 | } |
1291 | 1292 | ||
1292 | } else { //echar to schar | 1293 | } else { //echar to schar |
1293 | 1294 | ||
1294 | switch (c) { | 1295 | switch (c) { |
1295 | case 0x11a8: return 0x1100; | 1296 | case 0x11a8: return 0x1100; |
1296 | case 0x11a9: return 0x1101; | 1297 | case 0x11a9: return 0x1101; |
1297 | case 0x11ab: return 0x1102; | 1298 | case 0x11ab: return 0x1102; |
1298 | case 0x11ae: return 0x1103; | 1299 | case 0x11ae: return 0x1103; |
1299 | case 0x11af: return 0x1105; | 1300 | case 0x11af: return 0x1105; |
1300 | case 0x11b7: return 0x1106; | 1301 | case 0x11b7: return 0x1106; |
1301 | case 0x11b8: return 0x1107; | 1302 | case 0x11b8: return 0x1107; |
1302 | case 0x11ba: return 0x1109; | 1303 | case 0x11ba: return 0x1109; |
1303 | case 0x11bb: return 0x110a; | 1304 | case 0x11bb: return 0x110a; |
1304 | case 0x11bc: return 0x110b; | 1305 | case 0x11bc: return 0x110b; |
1305 | case 0x11bd: return 0x110c; | 1306 | case 0x11bd: return 0x110c; |
1306 | case 0x11be: return 0x110e; | 1307 | case 0x11be: return 0x110e; |
1307 | case 0x11bf: return 0x110f; | 1308 | case 0x11bf: return 0x110f; |
1308 | case 0x11c0: return 0x1110; | 1309 | case 0x11c0: return 0x1110; |
1309 | case 0x11c1: return 0x1111; | 1310 | case 0x11c1: return 0x1111; |
1310 | case 0x11c2: return 0x1112; | 1311 | case 0x11c2: return 0x1112; |
1311 | default: return 0; | 1312 | default: return 0; |
1312 | 1313 | ||
1313 | } | 1314 | } |
1314 | 1315 | ||
1315 | } | 1316 | } |
1316 | } | 1317 | } |
1317 | 1318 | ||
1318 | 1319 | ||
1319 | // Keys::Keys {{{1 | 1320 | // Keys::Keys {{{1 |
1320 | 1321 | ||
1321 | Keys::Keys() { | 1322 | Keys::Keys() { |
1322 | 1323 | ||
1323 | Config *config = new Config ("multikey"); | 1324 | Config *config = new Config ("multikey"); |
1324 | config->setGroup( "keymaps" ); | 1325 | config->setGroup( "keymaps" ); |
1325 | QString map = config->readEntry( "current" ); | 1326 | QString map = config->readEntry( "current" ); |
1326 | delete config; | 1327 | delete config; |
1327 | 1328 | ||
1328 | if (map.isNull() || !(QFile(map).exists())) { | 1329 | if (map.isNull() || !(QFile(map).exists())) { |
1329 | 1330 | ||
1330 | Config *config = new Config("locale"); | 1331 | Config *config = new Config("locale"); |
1331 | config->setGroup( "Language" ); | 1332 | config->setGroup( "Language" ); |
1332 | QString l = config->readEntry( "Language" , "en" ); | 1333 | QString l = config->readEntry( "Language" , "en" ); |
1333 | delete config; | 1334 | delete config; |
1334 | 1335 | ||
1335 | map = QPEApplication::qpeDir() + "/share/multikey/" | 1336 | map = QPEApplication::qpeDir() + "/share/multikey/" |
1336 | + l + ".keymap"; | 1337 | + l + ".keymap"; |
1337 | 1338 | ||
1338 | } | 1339 | } |
1339 | if (map.isNull() || !(QFile(map).exists())) { | 1340 | if (map.isNull() || !(QFile(map).exists())) { |
1340 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; | 1341 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; |
1341 | } | 1342 | } |
1342 | 1343 | ||
1343 | setKeysFromFile(map); | 1344 | setKeysFromFile(map); |
1344 | } | 1345 | } |
1345 | 1346 | ||
1346 | Keys::Keys(const char * filename) { | 1347 | Keys::Keys(const char * filename) { |
1347 | 1348 | ||
1348 | setKeysFromFile(filename); | 1349 | setKeysFromFile(filename); |
1349 | } | 1350 | } |
1350 | 1351 | ||
1351 | // Keys::setKeysFromFile {{{2 | 1352 | // Keys::setKeysFromFile {{{2 |
1352 | void Keys::setKeysFromFile(const char * filename) { | 1353 | void Keys::setKeysFromFile(const char * filename) { |
1353 | 1354 | ||
1354 | QFile f(filename); | 1355 | QFile f(filename); |
1355 | 1356 | ||
1356 | if (f.open(IO_ReadOnly)) { | 1357 | if (f.open(IO_ReadOnly)) { |
1357 | 1358 | ||
1358 | QTextStream t(&f); | 1359 | QTextStream t(&f); |
1359 | int row; | 1360 | int row; |
1360 | int qcode; | 1361 | int qcode; |
1361 | ushort unicode; | 1362 | ushort unicode; |
1362 | int width; | 1363 | int width; |
1363 | QString buf; | 1364 | QString buf; |
1364 | QString comment; | 1365 | QString comment; |
1365 | char * xpm[256]; //couldnt be larger than that... could it? | 1366 | char * xpm[256]; //couldnt be larger than that... could it? |
1366 | QImage *xpm2pix = 0; | 1367 | QImage *xpm2pix = 0; |
1367 | 1368 | ||
1368 | buf = t.readLine(); | 1369 | buf = t.readLine(); |
1369 | while (buf) { | 1370 | while (buf) { |
1370 | 1371 | ||
1371 | // get rid of comments | 1372 | // get rid of comments |
1372 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); | 1373 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); |
1373 | 1374 | ||
1374 | // key definition | 1375 | // key definition |
1375 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 1376 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
1376 | // no $1 type referencing!!! this implementation of regexp sucks | 1377 | // no $1 type referencing!!! this implementation of regexp sucks |
1377 | 1378 | ||
1378 | // dont know of any sscanf() type funcs in Qt lib | 1379 | // dont know of any sscanf() type funcs in Qt lib |
1379 | QTextStream tmp (buf, IO_ReadOnly); | 1380 | QTextStream tmp (buf, IO_ReadOnly); |
1380 | tmp >> row >> qcode >> unicode >> width >> comment; | 1381 | tmp >> row >> qcode >> unicode >> width >> comment; |
1381 | 1382 | ||
1382 | buf = t.readLine(); | 1383 | buf = t.readLine(); |
1383 | int xpmLineCount = 0; | 1384 | int xpmLineCount = 0; |
1384 | xpm2pix = 0; | 1385 | xpm2pix = 0; |
1385 | 1386 | ||
1386 | // erase blank space | 1387 | // erase blank space |
1387 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 1388 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
1388 | 1389 | ||
1389 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 1390 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
1390 | 1391 | ||
1391 | QString xpmBuf = buf.stripWhiteSpace(); | 1392 | QString xpmBuf = buf.stripWhiteSpace(); |
1392 | 1393 | ||
1393 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 1394 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |
1394 | 1395 | ||
1395 | int j = 0; | 1396 | int j = 0; |
1396 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 1397 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
1397 | if (xpmBuf[i].latin1() != '"') { | 1398 | if (xpmBuf[i].latin1() != '"') { |
1398 | 1399 | ||
1399 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 1400 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
1400 | j++; | 1401 | j++; |
1401 | } | 1402 | } |
1402 | 1403 | ||
1403 | } | 1404 | } |
1404 | // have to close that facker up | 1405 | // have to close that facker up |
1405 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 1406 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
1406 | 1407 | ||
1407 | xpmLineCount++; | 1408 | xpmLineCount++; |
1408 | buf = t.readLine(); | 1409 | buf = t.readLine(); |
1409 | } | 1410 | } |
1410 | if (xpmLineCount) { | 1411 | if (xpmLineCount) { |
1411 | 1412 | ||
1412 | xpm2pix = new QImage((const char **)xpm); | 1413 | xpm2pix = new QImage((const char **)xpm); |
1413 | for (int i = 0; i < xpmLineCount; i++) | 1414 | for (int i = 0; i < xpmLineCount; i++) |
1414 | 1415 | ||
1415 | delete [] (xpm[i]); | 1416 | delete [] (xpm[i]); |
1416 | 1417 | ||
1417 | } | 1418 | } |
1418 | setKey(row, qcode, unicode, width, xpm2pix); | 1419 | setKey(row, qcode, unicode, width, xpm2pix); |
1419 | } | 1420 | } |
1420 | 1421 | ||
1421 | // shift map | 1422 | // shift map |
1422 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1423 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1423 | 1424 | ||
1424 | QTextStream tmp (buf, IO_ReadOnly); | 1425 | QTextStream tmp (buf, IO_ReadOnly); |
1425 | ushort lower, shift; | 1426 | ushort lower, shift; |
1426 | tmp >> lower >> shift; | 1427 | tmp >> lower >> shift; |
1427 | 1428 | ||
1428 | shiftMap.insert(lower, shift); | 1429 | shiftMap.insert(lower, shift); |
1429 | 1430 | ||
1430 | buf = t.readLine(); | 1431 | buf = t.readLine(); |
1431 | } | 1432 | } |
1432 | 1433 | ||
1433 | // meta key map | 1434 | // meta key map |
1434 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1435 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1435 | 1436 | ||
1436 | QTextStream tmp (buf, IO_ReadOnly); | 1437 | QTextStream tmp (buf, IO_ReadOnly); |
1437 | ushort lower, shift; | 1438 | ushort lower, shift; |
1438 | QChar m; | 1439 | QChar m; |
1439 | tmp >> m >> lower >> shift; | 1440 | tmp >> m >> lower >> shift; |
1440 | 1441 | ||
1441 | metaMap.insert(lower, shift); | 1442 | metaMap.insert(lower, shift); |
1442 | 1443 | ||
1443 | buf = t.readLine(); | 1444 | buf = t.readLine(); |
1444 | } | 1445 | } |
1445 | 1446 | ||
1446 | // circumflex | 1447 | // circumflex |
1447 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1448 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1448 | 1449 | ||
1449 | QTextStream tmp (buf, IO_ReadOnly); | 1450 | QTextStream tmp (buf, IO_ReadOnly); |
1450 | ushort lower, shift; | 1451 | ushort lower, shift; |
1451 | QChar c; | 1452 | QChar c; |
1452 | tmp >> c >> lower >> shift; | 1453 | tmp >> c >> lower >> shift; |
1453 | 1454 | ||
1454 | circumflexMap.insert(lower, shift); | 1455 | circumflexMap.insert(lower, shift); |
1455 | 1456 | ||
1456 | buf = t.readLine(); | 1457 | buf = t.readLine(); |
1457 | } | 1458 | } |
1458 | // diaeresis | 1459 | // diaeresis |
1459 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1460 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1460 | 1461 | ||
1461 | QTextStream tmp (buf, IO_ReadOnly); | 1462 | QTextStream tmp (buf, IO_ReadOnly); |
1462 | ushort lower, shift; | 1463 | ushort lower, shift; |
1463 | QChar d; | 1464 | QChar d; |
1464 | tmp >> d >> lower >> shift; | 1465 | tmp >> d >> lower >> shift; |
1465 | 1466 | ||
1466 | diaeresisMap.insert(lower, shift); | 1467 | diaeresisMap.insert(lower, shift); |
1467 | 1468 | ||
1468 | buf = t.readLine(); | 1469 | buf = t.readLine(); |
1469 | } | 1470 | } |
1470 | // back accent | 1471 | // back accent |
1471 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1472 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1472 | 1473 | ||
1473 | QTextStream tmp (buf, IO_ReadOnly); | 1474 | QTextStream tmp (buf, IO_ReadOnly); |
1474 | ushort lower, shift; | 1475 | ushort lower, shift; |
1475 | QChar d; | 1476 | QChar d; |
1476 | tmp >> d >> lower >> shift; | 1477 | tmp >> d >> lower >> shift; |
1477 | 1478 | ||
1478 | baccentMap.insert(lower, shift); | 1479 | baccentMap.insert(lower, shift); |
1479 | 1480 | ||
1480 | qDebug ("Estoy aadiendo %i con %i", lower, shift); | 1481 | qDebug ("Estoy aadiendo %i con %i", lower, shift); |
1481 | buf = t.readLine(); | 1482 | buf = t.readLine(); |
1482 | } | 1483 | } |
1483 | // accent | 1484 | // accent |
1484 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1485 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1485 | 1486 | ||
1486 | QTextStream tmp (buf, IO_ReadOnly); | 1487 | QTextStream tmp (buf, IO_ReadOnly); |
1487 | ushort lower, shift; | 1488 | ushort lower, shift; |
1488 | QChar d; | 1489 | QChar d; |
1489 | tmp >> d >> lower >> shift; | 1490 | tmp >> d >> lower >> shift; |
1490 | 1491 | ||
1491 | accentMap.insert(lower, shift); | 1492 | accentMap.insert(lower, shift); |
1492 | 1493 | ||
1493 | buf = t.readLine(); | 1494 | buf = t.readLine(); |
1494 | } | 1495 | } |
1495 | 1496 | ||
1496 | // other variables like lang & title | 1497 | // other variables like lang & title |
1497 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 1498 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
1498 | 1499 | ||
1499 | QTextStream tmp (buf, IO_ReadOnly); | 1500 | QTextStream tmp (buf, IO_ReadOnly); |
1500 | QString name, equals, value; | 1501 | QString name, equals, value; |
1501 | 1502 | ||
1502 | tmp >> name >> equals >> value; | 1503 | tmp >> name >> equals >> value; |
1503 | 1504 | ||
1504 | if (name == "lang") { | 1505 | if (name == "lang") { |
1505 | 1506 | ||
1506 | lang = value; | 1507 | lang = value; |
1507 | 1508 | ||
1508 | } | 1509 | } |
1509 | 1510 | ||
1510 | buf = t.readLine(); | 1511 | buf = t.readLine(); |
1511 | } | 1512 | } |
1512 | // comments | 1513 | // comments |
1513 | else if (buf.contains(QRegExp("^\\s*#"))) { | 1514 | else if (buf.contains(QRegExp("^\\s*#"))) { |
1514 | 1515 | ||
1515 | buf = t.readLine(); | 1516 | buf = t.readLine(); |
1516 | 1517 | ||
1517 | } else { // blank line, or garbage | 1518 | } else { // blank line, or garbage |
1518 | 1519 | ||
1519 | buf = t.readLine(); | 1520 | buf = t.readLine(); |
1520 | 1521 | ||
1521 | } | 1522 | } |
1522 | 1523 | ||
1523 | } | 1524 | } |
1524 | f.close(); | 1525 | f.close(); |
1525 | } | 1526 | } |
1526 | 1527 | ||
1527 | } | 1528 | } |
1528 | 1529 | ||
1529 | // Keys::setKey {{{2 | 1530 | // Keys::setKey {{{2 |
1530 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 1531 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
1531 | const int width, QImage *pix) { | 1532 | const int width, QImage *pix) { |
1532 | 1533 | ||
1533 | Key * key; | 1534 | Key * key; |
1534 | key = new Key; | 1535 | key = new Key; |
1535 | key->qcode = qcode; | 1536 | key->qcode = qcode; |
1536 | key->unicode = unicode; | 1537 | key->unicode = unicode; |
1537 | key->width = width; | 1538 | key->width = width; |
1538 | 1539 | ||
1539 | // share key->pressed between same keys | 1540 | // share key->pressed between same keys |
1540 | bool found = 0; | 1541 | bool found = 0; |
1541 | for (int i = 1; i <= 5; i++) { | 1542 | for (int i = 1; i <= 5; i++) { |
1542 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1543 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1543 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1544 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
1544 | 1545 | ||
1545 | key->pressed = keys[i].at(j)->pressed; | 1546 | key->pressed = keys[i].at(j)->pressed; |
1546 | found = 1; | 1547 | found = 1; |
1547 | } | 1548 | } |
1548 | 1549 | ||
1549 | } | 1550 | } |
1550 | if (!found) { | 1551 | if (!found) { |
1551 | 1552 | ||
1552 | key->pressed = new bool; | 1553 | key->pressed = new bool; |
1553 | *(key->pressed) = 0; | 1554 | *(key->pressed) = 0; |
1554 | } | 1555 | } |
1555 | 1556 | ||
1556 | key->pix = pix; | 1557 | key->pix = pix; |
1557 | 1558 | ||
1558 | 1559 | ||
1559 | keys[row].append(key); | 1560 | keys[row].append(key); |
1560 | } | 1561 | } |
1561 | 1562 | ||
1562 | // Keys::~Keys {{{2 | 1563 | // Keys::~Keys {{{2 |
1563 | Keys::~Keys() { | 1564 | Keys::~Keys() { |
1564 | 1565 | ||
1565 | for (int i = 1; i <= 5; i++) | 1566 | for (int i = 1; i <= 5; i++) |
1566 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1567 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1567 | delete keys[i].at(j); | 1568 | delete keys[i].at(j); |
1568 | 1569 | ||
1569 | } | 1570 | } |
1570 | 1571 | ||
1571 | // Keys:: other functions {{{2 | 1572 | // Keys:: other functions {{{2 |
1572 | int Keys::width(const int row, const int col) { | 1573 | int Keys::width(const int row, const int col) { |
1573 | 1574 | ||
1574 | return keys[row].at(col)->width; | 1575 | return keys[row].at(col)->width; |
1575 | 1576 | ||
1576 | } | 1577 | } |
1577 | 1578 | ||
1578 | int Keys::rows() { | 1579 | int Keys::rows() { |
1579 | 1580 | ||
1580 | for (int i = 1; i <= 5; i++) { | 1581 | for (int i = 1; i <= 5; i++) { |
1581 | 1582 | ||
1582 | if (keys[i].count() == 0) | 1583 | if (keys[i].count() == 0) |
1583 | return i - 1; | 1584 | return i - 1; |
1584 | 1585 | ||
1585 | } | 1586 | } |
1586 | return 5; | 1587 | return 5; |
1587 | } | 1588 | } |
1588 | 1589 | ||
1589 | ushort Keys::uni(const int row, const int col) { | 1590 | ushort Keys::uni(const int row, const int col) { |
1590 | 1591 | ||
1591 | return keys[row].at(col)->unicode; | 1592 | return keys[row].at(col)->unicode; |
1592 | 1593 | ||
1593 | } | 1594 | } |
1594 | 1595 | ||
1595 | int Keys::qcode(const int row, const int col) { | 1596 | int Keys::qcode(const int row, const int col) { |
1596 | 1597 | ||
1597 | return keys[row].at(col)->qcode; | 1598 | return keys[row].at(col)->qcode; |
1598 | } | 1599 | } |
1599 | 1600 | ||
1600 | QImage *Keys::pix(const int row, const int col) { | 1601 | QImage *Keys::pix(const int row, const int col) { |
1601 | 1602 | ||
1602 | return keys[row].at(col)->pix; | 1603 | return keys[row].at(col)->pix; |
1603 | 1604 | ||
1604 | } | 1605 | } |
1605 | bool Keys::pressed(const int row, const int col) { | 1606 | bool Keys::pressed(const int row, const int col) { |
1606 | 1607 | ||
1607 | return *(keys[row].at(col)->pressed); | 1608 | return *(keys[row].at(col)->pressed); |
1608 | } | 1609 | } |
1609 | 1610 | ||
1610 | int Keys::numKeys(const int row) { | 1611 | int Keys::numKeys(const int row) { |
1611 | 1612 | ||
1612 | return keys[row].count(); | 1613 | return keys[row].count(); |
1613 | } | 1614 | } |
1614 | 1615 | ||
1615 | void Keys::setPressed(const int row, const int col, const bool pressed) { | 1616 | void Keys::setPressed(const int row, const int col, const bool pressed) { |
1616 | 1617 | ||
1617 | *(keys[row].at(col)->pressed) = pressed; | 1618 | *(keys[row].at(col)->pressed) = pressed; |
1618 | } | 1619 | } |
1619 | 1620 | ||
1620 | ushort Keys::shift(const ushort uni) { | 1621 | ushort Keys::shift(const ushort uni) { |
1621 | 1622 | ||
1622 | if (shiftMap[uni]) return shiftMap[uni]; | 1623 | if (shiftMap[uni]) return shiftMap[uni]; |
1623 | else return 0; | 1624 | else return 0; |
1624 | } | 1625 | } |
1625 | 1626 | ||
1626 | ushort Keys::meta(const ushort uni) { | 1627 | ushort Keys::meta(const ushort uni) { |
1627 | 1628 | ||
1628 | if (metaMap[uni]) return metaMap[uni]; | 1629 | if (metaMap[uni]) return metaMap[uni]; |
1629 | else return 0; | 1630 | else return 0; |
1630 | } | 1631 | } |
1631 | 1632 | ||
1632 | ushort Keys::circumflex(const ushort uni) { | 1633 | ushort Keys::circumflex(const ushort uni) { |
1633 | 1634 | ||
1634 | if (circumflexMap[uni]) return circumflexMap[uni]; | 1635 | if (circumflexMap[uni]) return circumflexMap[uni]; |
1635 | else return 0; | 1636 | else return 0; |
1636 | } | 1637 | } |
1637 | 1638 | ||
1638 | ushort Keys::diaeresis(const ushort uni) { | 1639 | ushort Keys::diaeresis(const ushort uni) { |
1639 | 1640 | ||
1640 | if(diaeresisMap[uni]) return diaeresisMap[uni]; | 1641 | if(diaeresisMap[uni]) return diaeresisMap[uni]; |
1641 | else return 0; | 1642 | else return 0; |
1642 | } | 1643 | } |
1643 | 1644 | ||
1644 | ushort Keys::baccent(const ushort uni) { | 1645 | ushort Keys::baccent(const ushort uni) { |
1645 | 1646 | ||
1646 | if(baccentMap[uni]) return baccentMap[uni]; | 1647 | if(baccentMap[uni]) return baccentMap[uni]; |
1647 | else return 0; | 1648 | else return 0; |
1648 | } | 1649 | } |
1649 | 1650 | ||
1650 | ushort Keys::accent(const ushort uni) { | 1651 | ushort Keys::accent(const ushort uni) { |
1651 | 1652 | ||
1652 | if(accentMap[uni]) return accentMap[uni]; | 1653 | if(accentMap[uni]) return accentMap[uni]; |
1653 | else return 0; | 1654 | else return 0; |
1654 | } | 1655 | } |
1655 | 1656 | ||
1656 | bool *Keys::pressedPtr(const int row, const int col) { | 1657 | bool *Keys::pressedPtr(const int row, const int col) { |
1657 | 1658 | ||
1658 | return keys[row].at(col)->pressed; | 1659 | return keys[row].at(col)->pressed; |
1659 | } | 1660 | } |
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index bc74e71..20c5cee 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -1,188 +1,191 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qframe.h> | 20 | #include <qframe.h> |
21 | #include <qmap.h> | 21 | #include <qmap.h> |
22 | #include "../pickboard/pickboardcfg.h" | 22 | #include "../pickboard/pickboardcfg.h" |
23 | #include "../pickboard/pickboardpicks.h" | 23 | #include "../pickboard/pickboardpicks.h" |
24 | #include "configdlg.h" | 24 | #include "configdlg.h" |
25 | 25 | ||
26 | class QTimer; | 26 | class QTimer; |
27 | 27 | ||
28 | namespace MultiKey | ||
29 | { | ||
30 | |||
28 | class KeyboardConfig : public DictFilterConfig | 31 | class KeyboardConfig : public DictFilterConfig |
29 | { | 32 | { |
30 | public: | 33 | public: |
31 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } | 34 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } |
32 | virtual void generateText(const QString &s); | 35 | virtual void generateText(const QString &s); |
33 | void decBackspaces() { if (backspaces) backspaces--; } | 36 | void decBackspaces() { if (backspaces) backspaces--; } |
34 | void incBackspaces() { backspaces++; } | 37 | void incBackspaces() { backspaces++; } |
35 | void resetBackspaces() { backspaces = 0; } | 38 | void resetBackspaces() { backspaces = 0; } |
36 | private: | 39 | private: |
37 | int backspaces; | 40 | int backspaces; |
38 | }; | 41 | }; |
39 | 42 | ||
40 | 43 | ||
41 | class KeyboardPicks : public PickboardPicks | 44 | class KeyboardPicks : public PickboardPicks |
42 | { | 45 | { |
43 | Q_OBJECT | 46 | Q_OBJECT |
44 | public: | 47 | public: |
45 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) | 48 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) |
46 | : PickboardPicks(parent, name, f) { } | 49 | : PickboardPicks(parent, name, f) { } |
47 | void initialise(); | 50 | void initialise(); |
48 | virtual QSize sizeHint() const; | 51 | virtual QSize sizeHint() const; |
49 | KeyboardConfig *dc; | 52 | KeyboardConfig *dc; |
50 | }; | 53 | }; |
51 | 54 | ||
52 | 55 | ||
53 | class Keys { | 56 | class Keys { |
54 | public: | 57 | public: |
55 | 58 | ||
56 | Keys(); | 59 | Keys(); |
57 | Keys(const char * filename); | 60 | Keys(const char * filename); |
58 | ~Keys(); | 61 | ~Keys(); |
59 | int width(const int row, const int col); | 62 | int width(const int row, const int col); |
60 | int rows(); | 63 | int rows(); |
61 | ushort uni(const int row, const int col); | 64 | ushort uni(const int row, const int col); |
62 | int qcode(const int row, const int col); | 65 | int qcode(const int row, const int col); |
63 | bool pressed(const int row, const int col); | 66 | bool pressed(const int row, const int col); |
64 | bool *pressedPtr(const int row, const int col); | 67 | bool *pressedPtr(const int row, const int col); |
65 | ushort shift(const ushort); | 68 | ushort shift(const ushort); |
66 | ushort meta(const ushort); | 69 | ushort meta(const ushort); |
67 | ushort circumflex(const ushort); | 70 | ushort circumflex(const ushort); |
68 | ushort diaeresis(const ushort); | 71 | ushort diaeresis(const ushort); |
69 | ushort baccent(const ushort); | 72 | ushort baccent(const ushort); |
70 | ushort accent(const ushort); | 73 | ushort accent(const ushort); |
71 | QImage *pix(const int row, const int col); | 74 | QImage *pix(const int row, const int col); |
72 | int numKeys(const int row); | 75 | int numKeys(const int row); |
73 | void setKeysFromFile(const char *filename); | 76 | void setKeysFromFile(const char *filename); |
74 | void setKey(const int row, const int qcode, const ushort unicode, | 77 | void setKey(const int row, const int qcode, const ushort unicode, |
75 | const int width, QImage *pix); | 78 | const int width, QImage *pix); |
76 | void setPressed(const int row, const int col, const bool pressed); | 79 | void setPressed(const int row, const int col, const bool pressed); |
77 | QString lang; | 80 | QString lang; |
78 | QString label; | 81 | QString label; |
79 | 82 | ||
80 | private: | 83 | private: |
81 | 84 | ||
82 | typedef struct Key { | 85 | typedef struct Key { |
83 | int qcode; // are qt key codes just unicode values? | 86 | int qcode; // are qt key codes just unicode values? |
84 | ushort unicode; | 87 | ushort unicode; |
85 | int width; // not pixels but relative key width. normal key is 2 | 88 | int width; // not pixels but relative key width. normal key is 2 |
86 | 89 | ||
87 | // only needed for keys like ctrl that can have multiple keys pressed at once | 90 | // only needed for keys like ctrl that can have multiple keys pressed at once |
88 | bool *pressed; | 91 | bool *pressed; |
89 | QImage *pix; | 92 | QImage *pix; |
90 | }; | 93 | }; |
91 | 94 | ||
92 | QList<Key> keys[6]; | 95 | QList<Key> keys[6]; |
93 | QMap<ushort,ushort> shiftMap; | 96 | QMap<ushort,ushort> shiftMap; |
94 | QMap<ushort,ushort> metaMap; | 97 | QMap<ushort,ushort> metaMap; |
95 | QMap<ushort,ushort> circumflexMap; | 98 | QMap<ushort,ushort> circumflexMap; |
96 | QMap<ushort,ushort> diaeresisMap; | 99 | QMap<ushort,ushort> diaeresisMap; |
97 | QMap<ushort,ushort> baccentMap; | 100 | QMap<ushort,ushort> baccentMap; |
98 | QMap<ushort,ushort> accentMap; | 101 | QMap<ushort,ushort> accentMap; |
99 | 102 | ||
100 | }; | 103 | }; |
101 | 104 | ||
102 | class Keyboard : public QFrame | 105 | class Keyboard : public QFrame |
103 | { | 106 | { |
104 | Q_OBJECT | 107 | Q_OBJECT |
105 | public: | 108 | public: |
106 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 109 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
107 | ~Keyboard(); | 110 | ~Keyboard(); |
108 | 111 | ||
109 | void resetState(); | 112 | void resetState(); |
110 | 113 | ||
111 | void mousePressEvent(QMouseEvent*); | 114 | void mousePressEvent(QMouseEvent*); |
112 | void mouseReleaseEvent(QMouseEvent*); | 115 | void mouseReleaseEvent(QMouseEvent*); |
113 | void resizeEvent(QResizeEvent*); | 116 | void resizeEvent(QResizeEvent*); |
114 | void paintEvent(QPaintEvent* e); | 117 | void paintEvent(QPaintEvent* e); |
115 | //void timerEvent(QTimerEvent* e); | 118 | //void timerEvent(QTimerEvent* e); |
116 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); | 119 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); |
117 | 120 | ||
118 | QSize sizeHint() const; | 121 | QSize sizeHint() const; |
119 | 122 | ||
120 | signals: | 123 | signals: |
121 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 124 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
122 | 125 | ||
123 | private slots: | 126 | private slots: |
124 | void repeat(); | 127 | void repeat(); |
125 | void togglePickboard(bool on_off); | 128 | void togglePickboard(bool on_off); |
126 | void toggleRepeat(bool on_off); | 129 | void toggleRepeat(bool on_off); |
127 | void setMapToDefault(); | 130 | void setMapToDefault(); |
128 | void setMapToFile(QString map); | 131 | void setMapToFile(QString map); |
129 | void cleanupConfigDlg(); | 132 | void cleanupConfigDlg(); |
130 | 133 | ||
131 | // used to redraw keyboard after edited colors | 134 | // used to redraw keyboard after edited colors |
132 | void reloadKeyboard(); | 135 | void reloadKeyboard(); |
133 | 136 | ||
134 | private: | 137 | private: |
135 | int getKey( int &w, int j = -1 ); | 138 | int getKey( int &w, int j = -1 ); |
136 | void clearHighlight(); | 139 | void clearHighlight(); |
137 | 140 | ||
138 | bool *shift; | 141 | bool *shift; |
139 | bool *lock; | 142 | bool *lock; |
140 | bool *ctrl; | 143 | bool *ctrl; |
141 | bool *alt; | 144 | bool *alt; |
142 | bool *meta; | 145 | bool *meta; |
143 | bool *circumflex; | 146 | bool *circumflex; |
144 | bool *diaeresis; | 147 | bool *diaeresis; |
145 | bool *baccent; | 148 | bool *baccent; |
146 | bool *accent; | 149 | bool *accent; |
147 | 150 | ||
148 | uint useLargeKeys:1; | 151 | uint useLargeKeys:1; |
149 | uint usePicks:1; | 152 | uint usePicks:1; |
150 | uint useRepeat:1; | 153 | uint useRepeat:1; |
151 | 154 | ||
152 | int pressedKeyRow; | 155 | int pressedKeyRow; |
153 | int pressedKeyCol; | 156 | int pressedKeyCol; |
154 | 157 | ||
155 | KeyboardPicks *picks; | 158 | KeyboardPicks *picks; |
156 | 159 | ||
157 | int keyHeight; | 160 | int keyHeight; |
158 | int defaultKeyWidth; | 161 | int defaultKeyWidth; |
159 | int xoffs; | 162 | int xoffs; |
160 | 163 | ||
161 | int unicode; | 164 | int unicode; |
162 | int qkeycode; | 165 | int qkeycode; |
163 | int modifiers; | 166 | int modifiers; |
164 | 167 | ||
165 | int pressTid; | 168 | int pressTid; |
166 | bool pressed; | 169 | bool pressed; |
167 | 170 | ||
168 | Keys *keys; | 171 | Keys *keys; |
169 | 172 | ||
170 | /* for korean input */ | 173 | /* for korean input */ |
171 | ushort schar, mchar, echar; | 174 | ushort schar, mchar, echar; |
172 | ushort parseKoreanInput(ushort c); | 175 | ushort parseKoreanInput(ushort c); |
173 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); | 176 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); |
174 | ushort constoe(const ushort c); | 177 | ushort constoe(const ushort c); |
175 | 178 | ||
176 | QTimer *repeatTimer; | 179 | QTimer *repeatTimer; |
177 | 180 | ||
178 | /* colors */ | 181 | /* colors */ |
179 | void loadKeyboardColors(); | 182 | void loadKeyboardColors(); |
180 | QColor keycolor; | 183 | QColor keycolor; |
181 | QColor keycolor_pressed; | 184 | QColor keycolor_pressed; |
182 | QColor keycolor_lines; | 185 | QColor keycolor_lines; |
183 | QColor textcolor; | 186 | QColor textcolor; |
184 | 187 | ||
185 | ConfigDlg *configdlg; | 188 | ConfigDlg *configdlg; |
186 | }; | 189 | }; |
187 | 190 | ||
188 | 191 | } // namespace MultiKey | |
diff --git a/inputmethods/multikey/keyboardimpl.cpp b/inputmethods/multikey/keyboardimpl.cpp index cebd43d..4cfbcd5 100644 --- a/inputmethods/multikey/keyboardimpl.cpp +++ b/inputmethods/multikey/keyboardimpl.cpp | |||
@@ -1,107 +1,107 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | #include "keyboard.h" | 22 | #include "keyboard.h" |
23 | #include "keyboardimpl.h" | 23 | #include "keyboardimpl.h" |
24 | 24 | ||
25 | /* XPM */ | 25 | /* XPM */ |
26 | static const char * kb_xpm[] = { | 26 | static const char * const kb_xpm[] = { |
27 | "28 13 4 1", | 27 | "28 13 4 1", |
28 | " c None", | 28 | " c None", |
29 | ". c #4C4C4C", | 29 | ". c #4C4C4C", |
30 | "+ c #FFF7DD", | 30 | "+ c #FFF7DD", |
31 | "@ c #D6CFBA", | 31 | "@ c #D6CFBA", |
32 | " .......................... ", | 32 | " .......................... ", |
33 | " .+++.+++.+++.+++.+++.++++. ", | 33 | " .+++.+++.+++.+++.+++.++++. ", |
34 | " .+@@.+@@.+@@.+@@.+@@.+@@@. ", | 34 | " .+@@.+@@.+@@.+@@.+@@.+@@@. ", |
35 | " .......................... ", | 35 | " .......................... ", |
36 | " .+++++.+++.+++.+++.++++++. ", | 36 | " .+++++.+++.+++.+++.++++++. ", |
37 | " .+@@@@.+@@.+@@.+@@.+@@@@@. ", | 37 | " .+@@@@.+@@.+@@.+@@.+@@@@@. ", |
38 | " .......................... ", | 38 | " .......................... ", |
39 | " .++++++.+++.+++.+++.+++++. ", | 39 | " .++++++.+++.+++.+++.+++++. ", |
40 | " .+@@@@@.+@@.+@@.+@@.+@@@@. ", | 40 | " .+@@@@@.+@@.+@@.+@@.+@@@@. ", |
41 | " .......................... ", | 41 | " .......................... ", |
42 | " .++++.++++++++++++++.++++. ", | 42 | " .++++.++++++++++++++.++++. ", |
43 | " .+@@@.+@@@@@@@@@@@@@.+@@@. ", | 43 | " .+@@@.+@@@@@@@@@@@@@.+@@@. ", |
44 | " .......................... "}; | 44 | " .......................... "}; |
45 | 45 | ||
46 | 46 | ||
47 | KeyboardImpl::KeyboardImpl() | 47 | KeyboardImpl::KeyboardImpl() |
48 | : input(0), icn(0), ref(0) | 48 | : input(0), icn(0), ref(0) |
49 | { | 49 | { |
50 | } | 50 | } |
51 | 51 | ||
52 | KeyboardImpl::~KeyboardImpl() | 52 | KeyboardImpl::~KeyboardImpl() |
53 | { | 53 | { |
54 | delete input; | 54 | delete input; |
55 | delete icn; | 55 | delete icn; |
56 | } | 56 | } |
57 | 57 | ||
58 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) | 58 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) |
59 | { | 59 | { |
60 | if ( !input ) | 60 | if ( !input ) |
61 | input = new Keyboard( parent, "Keyboard", f ); | 61 | input = new MultiKey::Keyboard( parent, "Keyboard", f ); |
62 | return input; | 62 | return input; |
63 | } | 63 | } |
64 | 64 | ||
65 | void KeyboardImpl::resetState() | 65 | void KeyboardImpl::resetState() |
66 | { | 66 | { |
67 | if ( input ) | 67 | if ( input ) |
68 | input->resetState(); | 68 | input->resetState(); |
69 | } | 69 | } |
70 | 70 | ||
71 | QPixmap *KeyboardImpl::icon() | 71 | QPixmap *KeyboardImpl::icon() |
72 | { | 72 | { |
73 | if ( !icn ) | 73 | if ( !icn ) |
74 | icn = new QPixmap( (const char **)kb_xpm ); | 74 | icn = new QPixmap( (const char **)kb_xpm ); |
75 | return icn; | 75 | return icn; |
76 | } | 76 | } |
77 | 77 | ||
78 | QString KeyboardImpl::name() | 78 | QString KeyboardImpl::name() |
79 | { | 79 | { |
80 | return qApp->translate( "InputMethods", "Multikey" ); | 80 | return qApp->translate( "InputMethods", "Multikey" ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) | 83 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) |
84 | { | 84 | { |
85 | if ( input ) | 85 | if ( input ) |
86 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); | 86 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); |
87 | } | 87 | } |
88 | 88 | ||
89 | #ifndef QT_NO_COMPONENT | 89 | #ifndef QT_NO_COMPONENT |
90 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 90 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
91 | { | 91 | { |
92 | *iface = 0; | 92 | *iface = 0; |
93 | if ( uuid == IID_QUnknown ) | 93 | if ( uuid == IID_QUnknown ) |
94 | *iface = this; | 94 | *iface = this; |
95 | else if ( uuid == IID_InputMethod ) | 95 | else if ( uuid == IID_InputMethod ) |
96 | *iface = this; | 96 | *iface = this; |
97 | 97 | ||
98 | if ( *iface ) | 98 | if ( *iface ) |
99 | (*iface)->addRef(); | 99 | (*iface)->addRef(); |
100 | return QS_OK; | 100 | return QS_OK; |
101 | } | 101 | } |
102 | 102 | ||
103 | Q_EXPORT_INTERFACE() | 103 | Q_EXPORT_INTERFACE() |
104 | { | 104 | { |
105 | Q_CREATE_INSTANCE( KeyboardImpl ) | 105 | Q_CREATE_INSTANCE( KeyboardImpl ) |
106 | } | 106 | } |
107 | #endif | 107 | #endif |
diff --git a/inputmethods/multikey/keyboardimpl.h b/inputmethods/multikey/keyboardimpl.h index e756364..76a2955 100644 --- a/inputmethods/multikey/keyboardimpl.h +++ b/inputmethods/multikey/keyboardimpl.h | |||
@@ -1,51 +1,60 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef KEYBOARDIMPL_H | 20 | #ifndef KEYBOARDIMPL_H |
21 | #define KEYBOARDIMPL_H | 21 | #define KEYBOARDIMPL_H |
22 | 22 | ||
23 | #include <qpe/inputmethodinterface.h> | 23 | #include <qpe/inputmethodinterface.h> |
24 | 24 | ||
25 | class Keyboard; | 25 | namespace MultiKey |
26 | { | ||
27 | class Keyboard; | ||
28 | } | ||
29 | |||
26 | class QPixmap; | 30 | class QPixmap; |
27 | 31 | ||
32 | namespace | ||
33 | { | ||
34 | |||
28 | class KeyboardImpl : public InputMethodInterface | 35 | class KeyboardImpl : public InputMethodInterface |
29 | { | 36 | { |
30 | public: | 37 | public: |
31 | KeyboardImpl(); | 38 | KeyboardImpl(); |
32 | virtual ~KeyboardImpl(); | 39 | virtual ~KeyboardImpl(); |
33 | 40 | ||
34 | #ifndef QT_NO_COMPONENT | 41 | #ifndef QT_NO_COMPONENT |
35 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 42 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
36 | Q_REFCOUNT | 43 | Q_REFCOUNT |
37 | #endif | 44 | #endif |
38 | 45 | ||
39 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); | 46 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); |
40 | virtual void resetState(); | 47 | virtual void resetState(); |
41 | virtual QPixmap *icon(); | 48 | virtual QPixmap *icon(); |
42 | virtual QString name(); | 49 | virtual QString name(); |
43 | virtual void onKeyPress( QObject *receiver, const char *slot ); | 50 | virtual void onKeyPress( QObject *receiver, const char *slot ); |
44 | 51 | ||
45 | private: | 52 | private: |
46 | Keyboard *input; | 53 | MultiKey::Keyboard *input; |
47 | QPixmap *icn; | 54 | QPixmap *icn; |
48 | ulong ref; | 55 | ulong ref; |
49 | }; | 56 | }; |
50 | 57 | ||
58 | } // anonymous namespace | ||
59 | |||
51 | #endif | 60 | #endif |