author | hash <hash> | 2002-08-22 06:49:40 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-22 06:49:40 (UTC) |
commit | 8eee5a5dc6a43ed3cdd77095c3a91128fe76589e (patch) (unidiff) | |
tree | c6ea5f00744921a0da52111dd7daf8e76374cc63 /inputmethods | |
parent | 4ed706f6a327e06403e1def058b7290dcde3e634 (diff) | |
download | opie-8eee5a5dc6a43ed3cdd77095c3a91128fe76589e.zip opie-8eee5a5dc6a43ed3cdd77095c3a91128fe76589e.tar.gz opie-8eee5a5dc6a43ed3cdd77095c3a91128fe76589e.tar.bz2 |
comments behind shift and meta key map definitions was making it ingore the whole line
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 1c17172..89937cf 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -60,527 +60,529 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | |||
60 | useRepeat = config->readBoolEntry ("useRepeat", "1"); | 60 | useRepeat = config->readBoolEntry ("useRepeat", "1"); |
61 | delete config; | 61 | delete config; |
62 | 62 | ||
63 | 63 | ||
64 | setFont( QFont( familyStr, 10 ) ); | 64 | setFont( QFont( familyStr, 10 ) ); |
65 | 65 | ||
66 | picks = new KeyboardPicks( this ); | 66 | picks = new KeyboardPicks( this ); |
67 | picks->setFont( QFont( familyStr, 10 ) ); | 67 | picks->setFont( QFont( familyStr, 10 ) ); |
68 | picks->initialise(); | 68 | picks->initialise(); |
69 | if (usePicks) { | 69 | if (usePicks) { |
70 | 70 | ||
71 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 71 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
72 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 72 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
73 | 73 | ||
74 | } else picks->hide(); | 74 | } else picks->hide(); |
75 | 75 | ||
76 | loadKeyboardColors(); | 76 | loadKeyboardColors(); |
77 | 77 | ||
78 | keys = new Keys(); | 78 | keys = new Keys(); |
79 | 79 | ||
80 | repeatTimer = new QTimer( this ); | 80 | repeatTimer = new QTimer( this ); |
81 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 81 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | Keyboard::~Keyboard() { | 85 | Keyboard::~Keyboard() { |
86 | 86 | ||
87 | if ( configdlg ) { | 87 | if ( configdlg ) { |
88 | delete (ConfigDlg *) configdlg; | 88 | delete (ConfigDlg *) configdlg; |
89 | configdlg = 0; | 89 | configdlg = 0; |
90 | } | 90 | } |
91 | 91 | ||
92 | } | 92 | } |
93 | 93 | ||
94 | /* Keyboard::resizeEvent {{{1 */ | 94 | /* Keyboard::resizeEvent {{{1 */ |
95 | void Keyboard::resizeEvent(QResizeEvent*) | 95 | void Keyboard::resizeEvent(QResizeEvent*) |
96 | { | 96 | { |
97 | int ph = picks->sizeHint().height(); | 97 | int ph = picks->sizeHint().height(); |
98 | picks->setGeometry( 0, 0, width(), ph ); | 98 | picks->setGeometry( 0, 0, width(), ph ); |
99 | keyHeight = (height()-(usePicks ? ph : 0))/5; | 99 | keyHeight = (height()-(usePicks ? ph : 0))/5; |
100 | 100 | ||
101 | int nk; // number of keys? | 101 | int nk; // number of keys? |
102 | if ( useLargeKeys ) { | 102 | if ( useLargeKeys ) { |
103 | nk = 15; | 103 | nk = 15; |
104 | } else { | 104 | } else { |
105 | nk = 19; | 105 | nk = 19; |
106 | } | 106 | } |
107 | defaultKeyWidth = (width()/nk)/2; | 107 | defaultKeyWidth = (width()/nk)/2; |
108 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 108 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
109 | 109 | ||
110 | } | 110 | } |
111 | 111 | ||
112 | /* KeyboardPicks::initialize {{{1 */ | 112 | /* KeyboardPicks::initialize {{{1 */ |
113 | void KeyboardPicks::initialise() | 113 | void KeyboardPicks::initialise() |
114 | { | 114 | { |
115 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 115 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
116 | mode = 0; | 116 | mode = 0; |
117 | dc = new KeyboardConfig(this); | 117 | dc = new KeyboardConfig(this); |
118 | configs.append(dc); | 118 | configs.append(dc); |
119 | } | 119 | } |
120 | 120 | ||
121 | /* KeyboardPicks::sizeHint {{{1 */ | 121 | /* KeyboardPicks::sizeHint {{{1 */ |
122 | QSize KeyboardPicks::sizeHint() const | 122 | QSize KeyboardPicks::sizeHint() const |
123 | { | 123 | { |
124 | return QSize(240,fontMetrics().lineSpacing()); | 124 | return QSize(240,fontMetrics().lineSpacing()); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | /* KeyboardConfig::generateText {{{1 */ | 128 | /* KeyboardConfig::generateText {{{1 */ |
129 | void KeyboardConfig::generateText(const QString &s) | 129 | void KeyboardConfig::generateText(const QString &s) |
130 | { | 130 | { |
131 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 131 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
132 | for (int i=0; i<(int)backspaces; i++) { | 132 | for (int i=0; i<(int)backspaces; i++) { |
133 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 133 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
134 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 134 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
135 | } | 135 | } |
136 | for (int i=0; i<(int)s.length(); i++) { | 136 | for (int i=0; i<(int)s.length(); i++) { |
137 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 137 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
138 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 138 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
139 | } | 139 | } |
140 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 140 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
141 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 141 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
142 | backspaces = 0; | 142 | backspaces = 0; |
143 | #endif | 143 | #endif |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | 148 | ||
149 | /* Keyboard::paintEvent {{{1 */ | 149 | /* Keyboard::paintEvent {{{1 */ |
150 | void Keyboard::paintEvent(QPaintEvent* e) | 150 | void Keyboard::paintEvent(QPaintEvent* e) |
151 | { | 151 | { |
152 | QPainter painter(this); | 152 | QPainter painter(this); |
153 | painter.setClipRect(e->rect()); | 153 | painter.setClipRect(e->rect()); |
154 | drawKeyboard( painter ); | 154 | drawKeyboard( painter ); |
155 | picks->dc->draw( &painter ); | 155 | picks->dc->draw( &painter ); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | /* Keyboard::drawKeyboard {{{1 */ | 159 | /* Keyboard::drawKeyboard {{{1 */ |
160 | 160 | ||
161 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 161 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
162 | { | 162 | { |
163 | 163 | ||
164 | 164 | ||
165 | if (row != -1 && col != -1) { //just redraw one key | 165 | if (row != -1 && col != -1) { //just redraw one key |
166 | 166 | ||
167 | int x = 0; | 167 | int x = 0; |
168 | for (int i = 0; i < col; i++) { | 168 | for (int i = 0; i < col; i++) { |
169 | 169 | ||
170 | x += keys->width(row, i) * defaultKeyWidth; | 170 | x += keys->width(row, i) * defaultKeyWidth; |
171 | } | 171 | } |
172 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 172 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
173 | 173 | ||
174 | int keyWidth = keys->width(row, col); | 174 | int keyWidth = keys->width(row, col); |
175 | 175 | ||
176 | p.fillRect(x + 1, y + 1, | 176 | p.fillRect(x + 1, y + 1, |
177 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 177 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
178 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 178 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
179 | 179 | ||
180 | QPixmap *pix = keys->pix(row,col); | 180 | QPixmap *pix = keys->pix(row,col); |
181 | 181 | ||
182 | ushort c = keys->uni(row, col); | 182 | ushort c = keys->uni(row, col); |
183 | 183 | ||
184 | p.setPen(textcolor); | 184 | p.setPen(textcolor); |
185 | if (!pix) { | 185 | if (!pix) { |
186 | if (shift || lock) | 186 | if (shift || lock) |
187 | c = keys->shift(c); | 187 | c = keys->shift(c); |
188 | if (meta) { | 188 | if (meta) { |
189 | 189 | ||
190 | c = keys->meta(c); | 190 | c = keys->meta(c); |
191 | } | 191 | } |
192 | p.drawText(x, y, | 192 | p.drawText(x, y, |
193 | defaultKeyWidth * keyWidth + 3, keyHeight, | 193 | defaultKeyWidth * keyWidth + 3, keyHeight, |
194 | AlignCenter, (QChar)c); | 194 | AlignCenter, (QChar)c); |
195 | } | 195 | } |
196 | else | 196 | else |
197 | // center the image in the middle of the key | 197 | // center the image in the middle of the key |
198 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, | 198 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, |
199 | y + (keyHeight - pix->height())/2 + 1, | 199 | y + (keyHeight - pix->height())/2 + 1, |
200 | *pix ); | 200 | *pix ); |
201 | 201 | ||
202 | // this fixes the problem that the very right end of the board's vertical line | 202 | // this fixes the problem that the very right end of the board's vertical line |
203 | // gets painted over, because it's one pixel shorter than all other keys | 203 | // gets painted over, because it's one pixel shorter than all other keys |
204 | p.setPen(keycolor_lines); | 204 | p.setPen(keycolor_lines); |
205 | p.drawLine(width() - 1, 0, width() - 1, height()); | 205 | p.drawLine(width() - 1, 0, width() - 1, height()); |
206 | 206 | ||
207 | } else { | 207 | } else { |
208 | 208 | ||
209 | 209 | ||
210 | p.fillRect(0, 0, width(), height(), keycolor); | 210 | p.fillRect(0, 0, width(), height(), keycolor); |
211 | 211 | ||
212 | for (row = 1; row <= 5; row++) { | 212 | for (row = 1; row <= 5; row++) { |
213 | 213 | ||
214 | int x = 0; | 214 | int x = 0; |
215 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 215 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
216 | 216 | ||
217 | p.setPen(keycolor_lines); | 217 | p.setPen(keycolor_lines); |
218 | p.drawLine(x, y, x + width(), y); | 218 | p.drawLine(x, y, x + width(), y); |
219 | 219 | ||
220 | for (int col = 0; col < keys->numKeys(row); col++) { | 220 | for (int col = 0; col < keys->numKeys(row); col++) { |
221 | 221 | ||
222 | QPixmap *pix = keys->pix(row, col); | 222 | QPixmap *pix = keys->pix(row, col); |
223 | int keyWidth = keys->width(row, col); | 223 | int keyWidth = keys->width(row, col); |
224 | 224 | ||
225 | 225 | ||
226 | int keyWidthPix = defaultKeyWidth * keyWidth; | 226 | int keyWidthPix = defaultKeyWidth * keyWidth; |
227 | 227 | ||
228 | if (keys->pressed(row, col)) | 228 | if (keys->pressed(row, col)) |
229 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 229 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
230 | keyHeight - 1, keycolor_pressed); | 230 | keyHeight - 1, keycolor_pressed); |
231 | 231 | ||
232 | ushort c = keys->uni(row, col); | 232 | ushort c = keys->uni(row, col); |
233 | 233 | ||
234 | if (!pix) { | 234 | if (!pix) { |
235 | if ((shift || lock) && keys->shift(c)) | 235 | if ((shift || lock) && keys->shift(c)) |
236 | c = keys->shift(c); | 236 | c = keys->shift(c); |
237 | else if (meta && keys->meta(c)) | 237 | else if (meta && keys->meta(c)) |
238 | c = keys->meta(c); | 238 | c = keys->meta(c); |
239 | 239 | ||
240 | p.drawText(x, y, | 240 | p.drawText(x, y, |
241 | defaultKeyWidth * keyWidth + 3, keyHeight, | 241 | defaultKeyWidth * keyWidth + 3, keyHeight, |
242 | AlignCenter, (QChar)c); | 242 | AlignCenter, (QChar)c); |
243 | } | 243 | } |
244 | else { | 244 | else { |
245 | // center the image in the middle of the key | 245 | // center the image in the middle of the key |
246 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, | 246 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, |
247 | y + (keyHeight - pix->height())/2 + 1, | 247 | y + (keyHeight - pix->height())/2 + 1, |
248 | QPixmap(*pix) ); | 248 | QPixmap(*pix) ); |
249 | } | 249 | } |
250 | 250 | ||
251 | p.setPen(keycolor_lines); | 251 | p.setPen(keycolor_lines); |
252 | p.drawLine(x, y, x, y + keyHeight); | 252 | p.drawLine(x, y, x, y + keyHeight); |
253 | 253 | ||
254 | x += keyWidthPix; | 254 | x += keyWidthPix; |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | } | 258 | } |
259 | p.drawLine(0, height() - 1, width(), height() - 1); | 259 | p.drawLine(0, height() - 1, width(), height() - 1); |
260 | p.drawLine(width() - 1, 0, width() - 1, height()); | 260 | p.drawLine(width() - 1, 0, width() - 1, height()); |
261 | } | 261 | } |
262 | 262 | ||
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | /* Keyboard::mousePressEvent {{{1 */ | 266 | /* Keyboard::mousePressEvent {{{1 */ |
267 | void Keyboard::mousePressEvent(QMouseEvent *e) | 267 | void Keyboard::mousePressEvent(QMouseEvent *e) |
268 | { | 268 | { |
269 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 269 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
270 | if (row > 5) row = 5; | 270 | if (row > 5) row = 5; |
271 | 271 | ||
272 | // figure out the column | 272 | // figure out the column |
273 | int col = 0; | 273 | int col = 0; |
274 | for (int w = 0; e->x() >= w; col++) | 274 | for (int w = 0; e->x() >= w; col++) |
275 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 275 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
276 | w += keys->width(row,col) * defaultKeyWidth; | 276 | w += keys->width(row,col) * defaultKeyWidth; |
277 | else break; | 277 | else break; |
278 | 278 | ||
279 | if (col <= 0) return; | 279 | if (col <= 0) return; |
280 | 280 | ||
281 | col --; // rewind one... | 281 | col --; // rewind one... |
282 | 282 | ||
283 | qkeycode = keys->qcode(row, col); | 283 | qkeycode = keys->qcode(row, col); |
284 | unicode = keys->uni(row, col); | 284 | unicode = keys->uni(row, col); |
285 | 285 | ||
286 | // might need to repaint if two or more of the same keys. | 286 | // might need to repaint if two or more of the same keys. |
287 | // should be faster if just paint one key even though multiple keys exist. | 287 | // should be faster if just paint one key even though multiple keys exist. |
288 | bool need_repaint = FALSE; | 288 | bool need_repaint = FALSE; |
289 | 289 | ||
290 | if (unicode == 0) { // either Qt char, or nothing | 290 | if (unicode == 0) { // either Qt char, or nothing |
291 | 291 | ||
292 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 292 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
293 | 293 | ||
294 | if ( configdlg ) { | 294 | if ( configdlg ) { |
295 | delete (ConfigDlg *) configdlg; | 295 | delete (ConfigDlg *) configdlg; |
296 | configdlg = 0; | 296 | configdlg = 0; |
297 | } | 297 | } |
298 | else { | 298 | else { |
299 | configdlg = new ConfigDlg (); | 299 | configdlg = new ConfigDlg (); |
300 | connect(configdlg, SIGNAL(setMapToDefault()), | 300 | connect(configdlg, SIGNAL(setMapToDefault()), |
301 | this, SLOT(setMapToDefault())); | 301 | this, SLOT(setMapToDefault())); |
302 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 302 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
303 | this, SLOT(setMapToFile(QString))); | 303 | this, SLOT(setMapToFile(QString))); |
304 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 304 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
305 | this, SLOT(togglePickboard(bool))); | 305 | this, SLOT(togglePickboard(bool))); |
306 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 306 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
307 | this, SLOT(toggleRepeat(bool))); | 307 | this, SLOT(toggleRepeat(bool))); |
308 | connect(configdlg, SIGNAL(reloadKeyboard()), | 308 | connect(configdlg, SIGNAL(reloadKeyboard()), |
309 | this, SLOT(reloadKeyboard())); | 309 | this, SLOT(reloadKeyboard())); |
310 | configdlg->showMaximized(); | 310 | configdlg->showMaximized(); |
311 | configdlg->show(); | 311 | configdlg->show(); |
312 | configdlg->raise(); | 312 | configdlg->raise(); |
313 | } | 313 | } |
314 | 314 | ||
315 | } else if (qkeycode == Qt::Key_Control) { | 315 | } else if (qkeycode == Qt::Key_Control) { |
316 | need_repaint = TRUE; | ||
316 | 317 | ||
317 | if (ctrl) { | 318 | if (ctrl) { |
318 | 319 | ||
319 | *ctrl = 0; | 320 | *ctrl = 0; |
320 | ctrl = 0; | 321 | ctrl = 0; |
321 | 322 | ||
322 | } else { | 323 | } else { |
323 | 324 | ||
324 | ctrl = keys->pressedPtr(row, col); | 325 | ctrl = keys->pressedPtr(row, col); |
325 | need_repaint = TRUE; | 326 | need_repaint = TRUE; |
326 | *ctrl = !keys->pressed(row, col); | 327 | *ctrl = !keys->pressed(row, col); |
327 | 328 | ||
328 | } | 329 | } |
329 | 330 | ||
330 | } else if (qkeycode == Qt::Key_Alt) { | 331 | } else if (qkeycode == Qt::Key_Alt) { |
332 | need_repaint = TRUE; | ||
331 | 333 | ||
332 | if (alt) { | 334 | if (alt) { |
333 | *alt = 0; | 335 | *alt = 0; |
334 | alt = 0; | 336 | alt = 0; |
335 | 337 | ||
336 | } else { | 338 | } else { |
337 | 339 | ||
338 | alt = keys->pressedPtr(row, col); | 340 | alt = keys->pressedPtr(row, col); |
339 | need_repaint = TRUE; | 341 | need_repaint = TRUE; |
340 | *alt = !keys->pressed(row, col); | 342 | *alt = !keys->pressed(row, col); |
341 | } | 343 | } |
342 | 344 | ||
343 | } else if (qkeycode == Qt::Key_Shift) { | 345 | } else if (qkeycode == Qt::Key_Shift) { |
344 | need_repaint = TRUE; | 346 | need_repaint = TRUE; |
345 | 347 | ||
346 | if (shift) { | 348 | if (shift) { |
347 | *shift = 0; | 349 | *shift = 0; |
348 | shift = 0; | 350 | shift = 0; |
349 | } | 351 | } |
350 | else { | 352 | else { |
351 | shift = keys->pressedPtr(row, col); | 353 | shift = keys->pressedPtr(row, col); |
352 | *shift = 1; | 354 | *shift = 1; |
353 | if (lock) { | 355 | if (lock) { |
354 | *lock = 0; | 356 | *lock = 0; |
355 | lock = 0; | 357 | lock = 0; |
356 | } | 358 | } |
357 | } | 359 | } |
358 | if (meta) { | 360 | if (meta) { |
359 | 361 | ||
360 | *meta = 0; | 362 | *meta = 0; |
361 | meta = 0; | 363 | meta = 0; |
362 | } | 364 | } |
363 | 365 | ||
364 | } else if (qkeycode == Qt::Key_CapsLock) { | 366 | } else if (qkeycode == Qt::Key_CapsLock) { |
365 | need_repaint = TRUE; | 367 | need_repaint = TRUE; |
366 | 368 | ||
367 | if (lock) { | 369 | if (lock) { |
368 | *lock = 0; | 370 | *lock = 0; |
369 | lock = 0; | 371 | lock = 0; |
370 | } | 372 | } |
371 | else { | 373 | else { |
372 | lock = keys->pressedPtr(row, col);; | 374 | lock = keys->pressedPtr(row, col);; |
373 | *lock = 1; | 375 | *lock = 1; |
374 | if (shift) { | 376 | if (shift) { |
375 | *shift = 0; | 377 | *shift = 0; |
376 | shift = 0; | 378 | shift = 0; |
377 | } | 379 | } |
378 | } | 380 | } |
379 | if (meta) { | 381 | if (meta) { |
380 | 382 | ||
381 | *meta = 0; | 383 | *meta = 0; |
382 | meta = 0; | 384 | meta = 0; |
383 | } | 385 | } |
384 | 386 | ||
385 | } else if (qkeycode == Qt::Key_Meta) { | 387 | } else if (qkeycode == Qt::Key_Meta) { |
386 | need_repaint = TRUE; | 388 | need_repaint = TRUE; |
387 | 389 | ||
388 | if (meta) { | 390 | if (meta) { |
389 | *meta = 0; | 391 | *meta = 0; |
390 | meta = 0; | 392 | meta = 0; |
391 | 393 | ||
392 | } else { | 394 | } else { |
393 | 395 | ||
394 | meta = keys->pressedPtr(row, col); | 396 | meta = keys->pressedPtr(row, col); |
395 | need_repaint = TRUE; | 397 | need_repaint = TRUE; |
396 | *meta = !keys->pressed(row, col); | 398 | *meta = !keys->pressed(row, col); |
397 | } | 399 | } |
398 | 400 | ||
399 | if (shift) { | 401 | if (shift) { |
400 | 402 | ||
401 | *shift = 0; | 403 | *shift = 0; |
402 | shift = 0; | 404 | shift = 0; |
403 | 405 | ||
404 | } | 406 | } |
405 | if (lock) { | 407 | if (lock) { |
406 | 408 | ||
407 | *lock = 0; | 409 | *lock = 0; |
408 | lock = 0; | 410 | lock = 0; |
409 | 411 | ||
410 | } | 412 | } |
411 | 413 | ||
412 | // dont need to emit this key... acts same as alt | 414 | // dont need to emit this key... acts same as alt |
413 | qkeycode = 0; | 415 | qkeycode = 0; |
414 | } | 416 | } |
415 | 417 | ||
416 | } | 418 | } |
417 | else { // normal char | 419 | else { // normal char |
418 | if ((shift || lock) && keys->shift(unicode)) { | 420 | if ((shift || lock) && keys->shift(unicode)) { |
419 | unicode = keys->shift(unicode); | 421 | unicode = keys->shift(unicode); |
420 | } | 422 | } |
421 | if (meta && keys->meta(unicode)) { | 423 | if (meta && keys->meta(unicode)) { |
422 | unicode = keys->meta(unicode); | 424 | unicode = keys->meta(unicode); |
423 | } | 425 | } |
424 | } | 426 | } |
425 | 427 | ||
426 | // korean parsing | 428 | // korean parsing |
427 | if (keys->lang == "ko") { | 429 | if (keys->lang == "ko") { |
428 | 430 | ||
429 | unicode = parseKoreanInput(unicode); | 431 | unicode = parseKoreanInput(unicode); |
430 | } | 432 | } |
431 | 433 | ||
432 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 434 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
433 | 435 | ||
434 | if ('A' <= unicode && unicode <= 'z' && modifiers) { | 436 | if ('A' <= unicode && unicode <= 'z' && modifiers) { |
435 | 437 | ||
436 | qkeycode = QChar(unicode).upper(); | 438 | qkeycode = QChar(unicode).upper(); |
437 | unicode = qkeycode - '@'; | 439 | unicode = qkeycode - '@'; |
438 | } | 440 | } |
439 | 441 | ||
440 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); | 442 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); |
441 | 443 | ||
442 | // pickboard stuff | 444 | // pickboard stuff |
443 | if (usePicks) { | 445 | if (usePicks) { |
444 | 446 | ||
445 | KeyboardConfig *dc = picks->dc; | 447 | KeyboardConfig *dc = picks->dc; |
446 | 448 | ||
447 | if (dc) { | 449 | if (dc) { |
448 | if (qkeycode == Qt::Key_Backspace) { | 450 | if (qkeycode == Qt::Key_Backspace) { |
449 | dc->input.remove(dc->input.last()); // remove last input | 451 | dc->input.remove(dc->input.last()); // remove last input |
450 | dc->decBackspaces(); | 452 | dc->decBackspaces(); |
451 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 453 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
452 | dc->input.clear(); | 454 | dc->input.clear(); |
453 | dc->resetBackspaces(); | 455 | dc->resetBackspaces(); |
454 | } else { | 456 | } else { |
455 | dc->add(QString(QChar(unicode))); | 457 | dc->add(QString(QChar(unicode))); |
456 | dc->incBackspaces(); | 458 | dc->incBackspaces(); |
457 | } | 459 | } |
458 | } | 460 | } |
459 | picks->repaint(); | 461 | picks->repaint(); |
460 | } | 462 | } |
461 | 463 | ||
462 | 464 | ||
463 | // painting | 465 | // painting |
464 | pressed = TRUE; | 466 | pressed = TRUE; |
465 | 467 | ||
466 | pressedKeyRow = row; | 468 | pressedKeyRow = row; |
467 | pressedKeyCol = col; | 469 | pressedKeyCol = col; |
468 | 470 | ||
469 | if (need_repaint) repaint(FALSE); | 471 | if (need_repaint) repaint(FALSE); |
470 | else { // just paint the one key pressed | 472 | else { // just paint the one key pressed |
471 | 473 | ||
472 | 474 | ||
473 | 475 | ||
474 | QPainter p(this); | 476 | QPainter p(this); |
475 | drawKeyboard(p, row, col); | 477 | drawKeyboard(p, row, col); |
476 | 478 | ||
477 | } | 479 | } |
478 | 480 | ||
479 | if (useRepeat) repeatTimer->start( 800 ); | 481 | if (useRepeat) repeatTimer->start( 800 ); |
480 | //pressTid = startTimer(80); | 482 | //pressTid = startTimer(80); |
481 | 483 | ||
482 | } | 484 | } |
483 | 485 | ||
484 | 486 | ||
485 | /* Keyboard::mouseReleaseEvent {{{1 */ | 487 | /* Keyboard::mouseReleaseEvent {{{1 */ |
486 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 488 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
487 | { | 489 | { |
488 | pressed = FALSE; | 490 | pressed = FALSE; |
489 | //if ( pressTid == 0 ) | 491 | //if ( pressTid == 0 ) |
490 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 492 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
491 | if ( unicode != -1 ) { | 493 | if ( unicode != -1 ) { |
492 | emit key( unicode, qkeycode, modifiers, false, false ); | 494 | emit key( unicode, qkeycode, modifiers, false, false ); |
493 | repeatTimer->stop(); | 495 | repeatTimer->stop(); |
494 | } | 496 | } |
495 | #endif | 497 | #endif |
496 | if (shift && unicode != 0) { | 498 | if (shift && unicode != 0) { |
497 | 499 | ||
498 | 500 | ||
499 | *shift = 0; // unpress shift key | 501 | *shift = 0; // unpress shift key |
500 | shift = 0; // reset the shift pointer | 502 | shift = 0; // reset the shift pointer |
501 | repaint(FALSE); | 503 | repaint(FALSE); |
502 | 504 | ||
503 | } else if (meta && unicode != 0) { | 505 | } else if (meta && unicode != 0) { |
504 | 506 | ||
505 | *meta = 0; | 507 | *meta = 0; |
506 | meta = 0; | 508 | meta = 0; |
507 | repaint(FALSE); | 509 | repaint(FALSE); |
508 | } | 510 | } |
509 | else | 511 | else |
510 | 512 | ||
511 | clearHighlight(); | 513 | clearHighlight(); |
512 | } | 514 | } |
513 | 515 | ||
514 | /* Keyboard::timerEvent {{{1 */ | 516 | /* Keyboard::timerEvent {{{1 */ |
515 | 517 | ||
516 | /* dont know what this does, but i think it is here so that if your screen | 518 | /* dont know what this does, but i think it is here so that if your screen |
517 | * sticks (like on an ipaq) then it will stop repeating if you click another | 519 | * sticks (like on an ipaq) then it will stop repeating if you click another |
518 | * key... but who knows what anything does in this thing anyway? | 520 | * key... but who knows what anything does in this thing anyway? |
519 | 521 | ||
520 | void Keyboard::timerEvent(QTimerEvent* e) | 522 | void Keyboard::timerEvent(QTimerEvent* e) |
521 | { | 523 | { |
522 | if ( e->timerId() == pressTid ) { | 524 | if ( e->timerId() == pressTid ) { |
523 | killTimer(pressTid); | 525 | killTimer(pressTid); |
524 | pressTid = 0; | 526 | pressTid = 0; |
525 | if ( !pressed ) | 527 | if ( !pressed ) |
526 | cout << "calling clearHighlight from timerEvent\n"; | 528 | cout << "calling clearHighlight from timerEvent\n"; |
527 | //clearHighlight(); | 529 | //clearHighlight(); |
528 | } | 530 | } |
529 | } | 531 | } |
530 | */ | 532 | */ |
531 | 533 | ||
532 | void Keyboard::repeat() | 534 | void Keyboard::repeat() |
533 | { | 535 | { |
534 | 536 | ||
535 | repeatTimer->start( 200 ); | 537 | repeatTimer->start( 200 ); |
536 | emit key( unicode, qkeycode, modifiers, true, true ); | 538 | emit key( unicode, qkeycode, modifiers, true, true ); |
537 | } | 539 | } |
538 | 540 | ||
539 | void Keyboard::clearHighlight() | 541 | void Keyboard::clearHighlight() |
540 | { | 542 | { |
541 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 543 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
542 | int tmpRow = pressedKeyRow; | 544 | int tmpRow = pressedKeyRow; |
543 | int tmpCol = pressedKeyCol; | 545 | int tmpCol = pressedKeyCol; |
544 | 546 | ||
545 | pressedKeyRow = -1; | 547 | pressedKeyRow = -1; |
546 | pressedKeyCol = -1; | 548 | pressedKeyCol = -1; |
547 | 549 | ||
548 | QPainter p(this); | 550 | QPainter p(this); |
549 | drawKeyboard(p, tmpRow, tmpCol); | 551 | drawKeyboard(p, tmpRow, tmpCol); |
550 | } | 552 | } |
551 | } | 553 | } |
552 | 554 | ||
553 | 555 | ||
554 | /* Keyboard::sizeHint {{{1 */ | 556 | /* Keyboard::sizeHint {{{1 */ |
555 | QSize Keyboard::sizeHint() const | 557 | QSize Keyboard::sizeHint() const |
556 | { | 558 | { |
557 | QFontMetrics fm=fontMetrics(); | 559 | QFontMetrics fm=fontMetrics(); |
558 | int keyHeight = fm.lineSpacing() + 2; | 560 | int keyHeight = fm.lineSpacing() + 2; |
559 | 561 | ||
560 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); | 562 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); |
561 | } | 563 | } |
562 | 564 | ||
563 | 565 | ||
564 | void Keyboard::resetState() | 566 | void Keyboard::resetState() |
565 | { | 567 | { |
566 | schar = mchar = echar = 0; | 568 | schar = mchar = echar = 0; |
567 | picks->resetState(); | 569 | picks->resetState(); |
568 | } | 570 | } |
569 | 571 | ||
570 | /* Keyboard::togglePickboard {{{1 */ | 572 | /* Keyboard::togglePickboard {{{1 */ |
571 | void Keyboard::togglePickboard(bool on_off) | 573 | void Keyboard::togglePickboard(bool on_off) |
572 | { | 574 | { |
573 | usePicks = on_off; | 575 | usePicks = on_off; |
574 | if (usePicks) { | 576 | if (usePicks) { |
575 | picks->show(); | 577 | picks->show(); |
576 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 578 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
577 | //adjustSize(); | 579 | //adjustSize(); |
578 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 580 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
579 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 581 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
580 | } else { | 582 | } else { |
581 | 583 | ||
582 | picks->hide(); | 584 | picks->hide(); |
583 | picks->resetState(); | 585 | picks->resetState(); |
584 | //move(x(), y() + picks->height()); | 586 | //move(x(), y() + picks->height()); |
585 | //adjustSize(); | 587 | //adjustSize(); |
586 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 588 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |