summaryrefslogtreecommitdiff
authorhash <hash>2002-11-08 05:48:13 (UTC)
committer hash <hash>2002-11-08 05:48:13 (UTC)
commit585e766bcb974079957dabcbaf487c21211caa8b (patch) (unidiff)
tree672f8670a0ec70b3e7ff3a079800bc12d9f82f8e
parent6cb72a24dead3f2f1a122cbe6e9dcc43be86443a (diff)
downloadopie-585e766bcb974079957dabcbaf487c21211caa8b.zip
opie-585e766bcb974079957dabcbaf487c21211caa8b.tar.gz
opie-585e766bcb974079957dabcbaf487c21211caa8b.tar.bz2
alt shouldnt stick either
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 08318bd..84c0c74 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -175,795 +175,801 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
175 int keyWidth = keys->width(row, col); 175 int keyWidth = keys->width(row, col);
176 176
177 p.fillRect(x + 1, y + 1, 177 p.fillRect(x + 1, y + 1,
178 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 178 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
180 180
181 QImage *pix = keys->pix(row,col); 181 QImage *pix = keys->pix(row,col);
182 182
183 ushort c = keys->uni(row, col); 183 ushort c = keys->uni(row, col);
184 184
185 p.setPen(textcolor); 185 p.setPen(textcolor);
186 if (!pix) { 186 if (!pix) {
187 if ((shift || lock) && keys->shift(c)) 187 if ((shift || lock) && keys->shift(c))
188 188
189 if (circumflex && keys->circumflex(keys->shift(c))) 189 if (circumflex && keys->circumflex(keys->shift(c)))
190 c = keys->circumflex(keys->shift(c)); 190 c = keys->circumflex(keys->shift(c));
191 else if (diaeresis && keys->diaeresis(keys->shift(c))) 191 else if (diaeresis && keys->diaeresis(keys->shift(c)))
192 c = keys->diaeresis(keys->shift(c)); 192 c = keys->diaeresis(keys->shift(c));
193 else if (baccent && keys->baccent(keys->shift(c))) 193 else if (baccent && keys->baccent(keys->shift(c)))
194 c = keys->baccent(keys->shift(c)); 194 c = keys->baccent(keys->shift(c));
195 else if (accent && keys->accent(keys->shift(c))) 195 else if (accent && keys->accent(keys->shift(c)))
196 c = keys->accent(keys->shift(c)); 196 c = keys->accent(keys->shift(c));
197 else if (meta && keys->meta(keys->shift(c))) 197 else if (meta && keys->meta(keys->shift(c)))
198 c = keys->meta(keys->shift(c)); 198 c = keys->meta(keys->shift(c));
199 else 199 else
200 c = keys->shift(c); 200 c = keys->shift(c);
201 201
202 else if (meta && keys->meta(c)) 202 else if (meta && keys->meta(c))
203 c = keys->meta(c); 203 c = keys->meta(c);
204 else if (circumflex && keys->circumflex(c)) 204 else if (circumflex && keys->circumflex(c))
205 c = keys->circumflex(c); 205 c = keys->circumflex(c);
206 else if (baccent && keys->baccent(c)) 206 else if (baccent && keys->baccent(c))
207 c = keys->baccent(c); 207 c = keys->baccent(c);
208 else if (accent && keys->accent(c)) 208 else if (accent && keys->accent(c))
209 c = keys->accent(c); 209 c = keys->accent(c);
210 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 210 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
211 211
212 // the diaeresis key itself has to be in the diaeresisMap, 212 // the diaeresis key itself has to be in the diaeresisMap,
213 // or just do this to make it display the diaeresis char. 213 // or just do this to make it display the diaeresis char.
214 214
215 if (c == 0x2c6) 215 if (c == 0x2c6)
216 c = 0xa8; 216 c = 0xa8;
217 else 217 else
218 c = keys->diaeresis(c); 218 c = keys->diaeresis(c);
219 } 219 }
220 220
221 p.drawText(x, y, 221 p.drawText(x, y,
222 defaultKeyWidth * keyWidth + 3, keyHeight, 222 defaultKeyWidth * keyWidth + 3, keyHeight,
223 AlignCenter, (QChar)c); 223 AlignCenter, (QChar)c);
224 } 224 }
225 else 225 else
226 // center the image in the middle of the key 226 // center the image in the middle of the key
227 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, 227 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
228 y + (keyHeight - pix->height())/2 + 1, 228 y + (keyHeight - pix->height())/2 + 1,
229 *pix ); 229 *pix );
230 230
231 // this fixes the problem that the very right end of the board's vertical line 231 // 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 232 // gets painted over, because it's one pixel shorter than all other keys
233 p.setPen(keycolor_lines); 233 p.setPen(keycolor_lines);
234 p.drawLine(width() - 1, 0, width() - 1, height()); 234 p.drawLine(width() - 1, 0, width() - 1, height());
235 235
236 } else { 236 } else {
237 237
238 238
239 p.fillRect(0, 0, width(), height(), keycolor); 239 p.fillRect(0, 0, width(), height(), keycolor);
240 240
241 for (row = 1; row <= keys->rows(); row++) { 241 for (row = 1; row <= keys->rows(); row++) {
242 242
243 int x = 0; 243 int x = 0;
244 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 244 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
245 245
246 p.setPen(keycolor_lines); 246 p.setPen(keycolor_lines);
247 p.drawLine(x, y, x + width(), y); 247 p.drawLine(x, y, x + width(), y);
248 248
249 for (int col = 0; col < keys->numKeys(row); col++) { 249 for (int col = 0; col < keys->numKeys(row); col++) {
250 250
251 QImage *pix = keys->pix(row, col); 251 QImage *pix = keys->pix(row, col);
252 int keyWidth = keys->width(row, col); 252 int keyWidth = keys->width(row, col);
253 253
254 254
255 int keyWidthPix = defaultKeyWidth * keyWidth; 255 int keyWidthPix = defaultKeyWidth * keyWidth;
256 256
257 if (keys->pressed(row, col)) 257 if (keys->pressed(row, col))
258 p.fillRect(x+1, y+1, keyWidthPix - 1, 258 p.fillRect(x+1, y+1, keyWidthPix - 1,
259 keyHeight - 1, keycolor_pressed); 259 keyHeight - 1, keycolor_pressed);
260 260
261 ushort c = keys->uni(row, col); 261 ushort c = keys->uni(row, col);
262 262
263 p.setPen(textcolor); 263 p.setPen(textcolor);
264 if (!pix) { 264 if (!pix) {
265 if ((shift || lock) && keys->shift(c)) 265 if ((shift || lock) && keys->shift(c))
266 266
267 if (circumflex && keys->circumflex(keys->shift(c))) 267 if (circumflex && keys->circumflex(keys->shift(c)))
268 c = keys->circumflex(keys->shift(c)); 268 c = keys->circumflex(keys->shift(c));
269 else if (diaeresis && keys->diaeresis(keys->shift(c))) 269 else if (diaeresis && keys->diaeresis(keys->shift(c)))
270 c = keys->diaeresis(keys->shift(c)); 270 c = keys->diaeresis(keys->shift(c));
271 else if (baccent && keys->baccent(keys->shift(c))) 271 else if (baccent && keys->baccent(keys->shift(c)))
272 c = keys->baccent(keys->shift(c)); 272 c = keys->baccent(keys->shift(c));
273 else if (accent && keys->accent(keys->shift(c))) 273 else if (accent && keys->accent(keys->shift(c)))
274 c = keys->accent(keys->shift(c)); 274 c = keys->accent(keys->shift(c));
275 else if (meta && keys->meta(keys->shift(c))) 275 else if (meta && keys->meta(keys->shift(c)))
276 c = keys->meta(keys->shift(c)); 276 c = keys->meta(keys->shift(c));
277 else 277 else
278 c = keys->shift(c); 278 c = keys->shift(c);
279 279
280 else if (meta && keys->meta(c)) 280 else if (meta && keys->meta(c))
281 c = keys->meta(c); 281 c = keys->meta(c);
282 else if (circumflex && keys->circumflex(c)) 282 else if (circumflex && keys->circumflex(c))
283 c = keys->circumflex(c); 283 c = keys->circumflex(c);
284 else if (baccent && keys->baccent(c)) 284 else if (baccent && keys->baccent(c))
285 c = keys->baccent(c); 285 c = keys->baccent(c);
286 else if (accent && keys->accent(c)) 286 else if (accent && keys->accent(c))
287 c = keys->accent(c); 287 c = keys->accent(c);
288 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 288 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
289 289
290 if (c == 0x2c6) 290 if (c == 0x2c6)
291 c = 0xa8; 291 c = 0xa8;
292 else 292 else
293 c = keys->diaeresis(c); 293 c = keys->diaeresis(c);
294 } 294 }
295 295
296 p.drawText(x, y, 296 p.drawText(x, y,
297 keyWidthPix + 3, keyHeight, 297 keyWidthPix + 3, keyHeight,
298 AlignCenter, (QChar)c); 298 AlignCenter, (QChar)c);
299 } 299 }
300 else { 300 else {
301 // center the image in the middle of the key 301 // center the image in the middle of the key
302 pix->setColor(1, textcolor.rgb()); 302 pix->setColor(1, textcolor.rgb());
303 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, 303 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
304 y + (keyHeight - pix->height())/2 + 1, 304 y + (keyHeight - pix->height())/2 + 1,
305 QImage(*pix) ); 305 QImage(*pix) );
306 } 306 }
307 307
308 p.setPen(keycolor_lines); 308 p.setPen(keycolor_lines);
309 p.drawLine(x, y, x, y + keyHeight); 309 p.drawLine(x, y, x, y + keyHeight);
310 310
311 x += keyWidthPix; 311 x += keyWidthPix;
312 } 312 }
313 313
314 314
315 } 315 }
316 p.setPen(keycolor_lines); 316 p.setPen(keycolor_lines);
317 p.drawLine(0, height() - 1, width(), height() - 1); 317 p.drawLine(0, height() - 1, width(), height() - 1);
318 p.drawLine(width() - 1, 0, width() - 1, height()); 318 p.drawLine(width() - 1, 0, width() - 1, height());
319 } 319 }
320 320
321} 321}
322 322
323 323
324/* Keyboard::mousePressEvent {{{1 */ 324/* Keyboard::mousePressEvent {{{1 */
325void Keyboard::mousePressEvent(QMouseEvent *e) 325void Keyboard::mousePressEvent(QMouseEvent *e)
326{ 326{
327 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 327 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
328 if (row > 5) row = 5; 328 if (row > 5) row = 5;
329 329
330 // figure out the column 330 // figure out the column
331 int col = 0; 331 int col = 0;
332 for (int w = 0; e->x() >= w; col++) 332 for (int w = 0; e->x() >= w; col++)
333 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 333 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
334 w += keys->width(row,col) * defaultKeyWidth; 334 w += keys->width(row,col) * defaultKeyWidth;
335 else break; 335 else break;
336 336
337 if (col <= 0) return; 337 if (col <= 0) return;
338 338
339 col --; // rewind one... 339 col --; // rewind one...
340 340
341 qkeycode = keys->qcode(row, col); 341 qkeycode = keys->qcode(row, col);
342 unicode = keys->uni(row, col); 342 unicode = keys->uni(row, col);
343 343
344 // might need to repaint if two or more of the same keys. 344 // 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. 345 // should be faster if just paint one key even though multiple keys exist.
346 bool need_repaint = FALSE; 346 bool need_repaint = FALSE;
347 347
348 // circumflex and diaeresis support 348 // circumflex and diaeresis support
349 // messy to have this here, but too hard to implement any other method 349 // messy to have this here, but too hard to implement any other method
350 if (unicode == 0x2c6) { 350 if (unicode == 0x2c6) {
351 351
352 unicode = 0; 352 unicode = 0;
353 if (shift || lock) { 353 if (shift || lock) {
354 354
355 // diaeresis 355 // diaeresis
356 qkeycode = 0x2001; 356 qkeycode = 0x2001;
357 } 357 }
358 else { 358 else {
359 359
360 // circumflex 360 // circumflex
361 qkeycode = 0x2000; 361 qkeycode = 0x2000;
362 } 362 }
363 } 363 }
364 364
365 // Back accent character support 365 // Back accent character support
366 366
367 //if (unicode == 0x60) { // the keys from 2c6 ~ 2cf should be used instead of the ascii one 367 // the keys from 2c6 ~ 2cf should be used instead of the ascii one
368 if (unicode == 0x2cb) { 368 if (unicode == 0x2cb) {
369 369
370 unicode = 0; 370 unicode = 0;
371 if (shift || lock) { 371 if (shift || lock) {
372 372
373 // circumblex 373 // circumblex
374 qkeycode = 0x2000; 374 qkeycode = 0x2000;
375 } 375 }
376 else { 376 else {
377 377
378 // back accent 378 // back accent
379 qkeycode = 0x2002; 379 qkeycode = 0x2002;
380 } 380 }
381 } 381 }
382 382
383 // Accent character support 383 // Accent character support
384 384
385 //if (unicode == 0xb4) {
386 if (unicode == 0x2ca) { 385 if (unicode == 0x2ca) {
387 386
388 unicode = 0; 387 unicode = 0;
389 if (shift || lock) { 388 if (shift || lock) {
390 389
391 // diaeresis 390 // diaeresis
392 qkeycode = 0x2001; 391 qkeycode = 0x2001;
393 } 392 }
394 else { 393 else {
395 394
396 // accent 395 // accent
397 qkeycode = 0x2003; 396 qkeycode = 0x2003;
398 } 397 }
399 } 398 }
400 399
401 400
402 if (unicode == 0) { // either Qt char, or nothing 401 if (unicode == 0) { // either Qt char, or nothing
403 402
404 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 403 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
405 404
406 if ( configdlg ) { 405 if ( configdlg ) {
407 406
408 delete (ConfigDlg *) configdlg; 407 delete (ConfigDlg *) configdlg;
409 configdlg = 0; 408 configdlg = 0;
410 } 409 }
411 else { 410 else {
412 configdlg = new ConfigDlg (); 411 configdlg = new ConfigDlg ();
413 connect(configdlg, SIGNAL(setMapToDefault()), 412 connect(configdlg, SIGNAL(setMapToDefault()),
414 this, SLOT(setMapToDefault())); 413 this, SLOT(setMapToDefault()));
415 connect(configdlg, SIGNAL(setMapToFile(QString)), 414 connect(configdlg, SIGNAL(setMapToFile(QString)),
416 this, SLOT(setMapToFile(QString))); 415 this, SLOT(setMapToFile(QString)));
417 connect(configdlg, SIGNAL(pickboardToggled(bool)), 416 connect(configdlg, SIGNAL(pickboardToggled(bool)),
418 this, SLOT(togglePickboard(bool))); 417 this, SLOT(togglePickboard(bool)));
419 connect(configdlg, SIGNAL(repeatToggled(bool)), 418 connect(configdlg, SIGNAL(repeatToggled(bool)),
420 this, SLOT(toggleRepeat(bool))); 419 this, SLOT(toggleRepeat(bool)));
421 connect(configdlg, SIGNAL(reloadKeyboard()), 420 connect(configdlg, SIGNAL(reloadKeyboard()),
422 this, SLOT(reloadKeyboard())); 421 this, SLOT(reloadKeyboard()));
423 connect(configdlg, SIGNAL(configDlgClosed()), 422 connect(configdlg, SIGNAL(configDlgClosed()),
424 this, SLOT(cleanupConfigDlg())); 423 this, SLOT(cleanupConfigDlg()));
425 configdlg->showMaximized(); 424 configdlg->showMaximized();
426 configdlg->show(); 425 configdlg->show();
427 configdlg->raise(); 426 configdlg->raise();
428 } 427 }
429 428
430 } else if (qkeycode == Qt::Key_Control) { 429 } else if (qkeycode == Qt::Key_Control) {
431 need_repaint = TRUE; 430 need_repaint = TRUE;
432 431
433 if (ctrl) { 432 if (ctrl) {
434 433
435 *ctrl = 0; 434 *ctrl = 0;
436 ctrl = 0; 435 ctrl = 0;
437 436
438 } else { 437 } else {
439 438
440 ctrl = keys->pressedPtr(row, col); 439 ctrl = keys->pressedPtr(row, col);
441 need_repaint = TRUE; 440 need_repaint = TRUE;
442 *ctrl = !keys->pressed(row, col); 441 *ctrl = !keys->pressed(row, col);
443 442
444 } 443 }
445 444
446 } else if (qkeycode == Qt::Key_Alt) { 445 } else if (qkeycode == Qt::Key_Alt) {
447 need_repaint = TRUE; 446 need_repaint = TRUE;
448 447
449 if (alt) { 448 if (alt) {
450 *alt = 0; 449 *alt = 0;
451 alt = 0; 450 alt = 0;
452 451
453 } else { 452 } else {
454 453
455 alt = keys->pressedPtr(row, col); 454 alt = keys->pressedPtr(row, col);
456 need_repaint = TRUE; 455 need_repaint = TRUE;
457 *alt = !keys->pressed(row, col); 456 *alt = !keys->pressed(row, col);
458 } 457 }
459 458
460 } else if (qkeycode == Qt::Key_Shift) { 459 } else if (qkeycode == Qt::Key_Shift) {
461 need_repaint = TRUE; 460 need_repaint = TRUE;
462 461
463 if (shift) { 462 if (shift) {
464 *shift = 0; 463 *shift = 0;
465 shift = 0; 464 shift = 0;
466 } 465 }
467 else { 466 else {
468 shift = keys->pressedPtr(row, col); 467 shift = keys->pressedPtr(row, col);
469 *shift = 1; 468 *shift = 1;
470 if (lock) { 469 if (lock) {
471 *lock = 0; 470 *lock = 0;
472 lock = 0; 471 lock = 0;
473 } 472 }
474 } 473 }
475 474
476 475
477 /* 476 /*
478 * want to be able to hit circumflex/diaeresis -> shift 477 * want to be able to hit circumflex/diaeresis -> shift
479 * to type in shifted circumflex/diaeresis chars. 478 * to type in shifted circumflex/diaeresis chars.
480 * same thing with meta 479 * same thing with meta
481 480
482 if (meta) { *meta = 0; meta = 0; } 481 if (meta) { *meta = 0; meta = 0; }
483 if (circumflex) { *circumflex = 0; circumflex = 0; } 482 if (circumflex) { *circumflex = 0; circumflex = 0; }
484 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 483 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
485 484
486 */ 485 */
487 486
488 } else if (qkeycode == Qt::Key_CapsLock) { 487 } else if (qkeycode == Qt::Key_CapsLock) {
489 need_repaint = TRUE; 488 need_repaint = TRUE;
490 489
491 if (lock) { 490 if (lock) {
492 *lock = 0; 491 *lock = 0;
493 lock = 0; 492 lock = 0;
494 } 493 }
495 else { 494 else {
496 lock = keys->pressedPtr(row, col);; 495 lock = keys->pressedPtr(row, col);;
497 *lock = true;; 496 *lock = true;;
498 if (shift) { 497 if (shift) {
499 *shift = 0; 498 *shift = 0;
500 shift = 0; 499 shift = 0;
501 } 500 }
502 } 501 }
503 502
504 /* 503 /*
505 if (meta) { *meta = 0; meta = 0; } 504 if (meta) { *meta = 0; meta = 0; }
506 if (circumflex) { *circumflex = 0; circumflex = 0; } 505 if (circumflex) { *circumflex = 0; circumflex = 0; }
507 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 506 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
508 */ 507 */
509 508
510 } else if (qkeycode == Qt::Key_Meta) { 509 } else if (qkeycode == Qt::Key_Meta) {
511 need_repaint = TRUE; 510 need_repaint = TRUE;
512 511
513 if (meta) { 512 if (meta) {
514 *meta = 0; 513 *meta = 0;
515 meta = 0; 514 meta = 0;
516 515
517 } else { 516 } else {
518 517
519 meta = keys->pressedPtr(row, col); 518 meta = keys->pressedPtr(row, col);
520 *meta = true; 519 *meta = true;
521 } 520 }
522 521
523 // reset all the other keys 522 // reset all the other keys
524 if (shift) { *shift = 0; shift = 0; } 523 if (shift) { *shift = 0; shift = 0; }
525 if (lock) { *lock = 0; lock = 0; } 524 if (lock) { *lock = 0; lock = 0; }
526 if (circumflex) { *circumflex = 0; circumflex = 0; } 525 if (circumflex) { *circumflex = 0; circumflex = 0; }
527 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 526 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
528 if (baccent) { *baccent = 0; baccent = 0; } 527 if (baccent) { *baccent = 0; baccent = 0; }
529 if (accent) { *accent = 0; accent = 0; } 528 if (accent) { *accent = 0; accent = 0; }
530 529
531 // dont need to emit this key... acts same as alt 530 // dont need to emit this key... acts same as alt
532 qkeycode = 0; 531 qkeycode = 0;
533 532
534 // circumflex 533 // circumflex
535 } else if (qkeycode == 0x2000) { 534 } else if (qkeycode == 0x2000) {
536 need_repaint = TRUE; 535 need_repaint = TRUE;
537 536
538 if (circumflex) { 537 if (circumflex) {
539 538
540 *circumflex = 0; 539 *circumflex = 0;
541 circumflex = 0; 540 circumflex = 0;
542 541
543 } else { 542 } else {
544 543
545 circumflex = keys->pressedPtr(row, col); 544 circumflex = keys->pressedPtr(row, col);
546 *circumflex = true; 545 *circumflex = true;
547 } 546 }
548 547
549 /* no need to turn off shift or lock if circumflex 548 /* no need to turn off shift or lock if circumflex
550 * keys are pressed 549 * keys are pressed
551 550
552 if (shift) { *shift = 0; shift = 0; } 551 if (shift) { *shift = 0; shift = 0; }
553 if (lock) { *lock = 0; lock = 0; } 552 if (lock) { *lock = 0; lock = 0; }
554 553
555 */ 554 */
556 555
557 // have to reset all the other keys 556 // have to reset all the other keys
558 if (meta) { *meta = 0; meta = 0; } 557 if (meta) { *meta = 0; meta = 0; }
559 if (diaeresis) { 558 if (diaeresis) {
560 559
561 // *diaeresis and *circumflex point to the same thing 560 // *diaeresis and *circumflex point to the same thing
562 // when diaeresis is enabled and you hit the circumflex 561 // when diaeresis is enabled and you hit the circumflex
563 // since they are the same key, it should turn off the 562 // since they are the same key, it should turn off the
564 // key 563 // key
565 564
566 *diaeresis = 0; 565 *diaeresis = 0;
567 diaeresis = 0; 566 diaeresis = 0;
568 circumflex = 0; 567 circumflex = 0;
569 } 568 }
570 569
571 qkeycode = 0; 570 qkeycode = 0;
572 571
573 // diaeresis 572 // diaeresis
574 } else if (qkeycode == 0x2001) { 573 } else if (qkeycode == 0x2001) {
575 need_repaint = TRUE; 574 need_repaint = TRUE;
576 575
577 if (diaeresis) { 576 if (diaeresis) {
578 577
579 *diaeresis = 0; 578 *diaeresis = 0;
580 diaeresis = 0; 579 diaeresis = 0;
581 580
582 } else { 581 } else {
583 582
584 diaeresis = keys->pressedPtr(row, col); 583 diaeresis = keys->pressedPtr(row, col);
585 *diaeresis = true; 584 *diaeresis = true;
586 } 585 }
587 586
588 587
589 if (shift) { *shift = 0; shift = 0; } 588 if (shift) { *shift = 0; shift = 0; }
590 589
591 /* 590 /*
592 * 591 *
593 if (lock) { *lock = 0; lock = 0; } 592 if (lock) { *lock = 0; lock = 0; }
594 * 593 *
595 */ 594 */
596 595
597 if (meta) { *meta = 0; meta = 0; } 596 if (meta) { *meta = 0; meta = 0; }
598 if (circumflex) { 597 if (circumflex) {
599 598
600 // *circumflex = 0; 599 // *circumflex = 0;
601 // 600 //
602 // same thing the diaeresis pointer points too 601 // same thing the diaeresis pointer points too
603 602
604 circumflex = 0; 603 circumflex = 0;
605 } 604 }
606 605
607 606
608 qkeycode = 0; 607 qkeycode = 0;
609 608
610 // Back accent 609 // Back accent
611 } else if (qkeycode == 0x2002) { 610 } else if (qkeycode == 0x2002) {
612 need_repaint = TRUE; 611 need_repaint = TRUE;
613 612
614 if (baccent) { 613 if (baccent) {
615 614
616 *baccent = 0; 615 *baccent = 0;
617 baccent = 0; 616 baccent = 0;
618 617
619 } else { 618 } else {
620 619
621 baccent = keys->pressedPtr(row, col); 620 baccent = keys->pressedPtr(row, col);
622 *baccent = true; 621 *baccent = true;
623 } 622 }
624 623
625 624
626 if (shift) { *shift = 0; shift = 0; } 625 if (shift) { *shift = 0; shift = 0; }
627 if (meta) { *meta = 0; meta = 0; } 626 if (meta) { *meta = 0; meta = 0; }
628 if (accent) { *accent = 0; accent = 0; } 627 if (accent) { *accent = 0; accent = 0; }
629 628
630 qkeycode = 0; 629 qkeycode = 0;
631 630
632 // Accent 631 // Accent
633 } else if (qkeycode == 0x2003) { 632 } else if (qkeycode == 0x2003) {
634 need_repaint = TRUE; 633 need_repaint = TRUE;
635 634
636 if (accent) { 635 if (accent) {
637 636
638 *accent = 0; 637 *accent = 0;
639 accent = 0; 638 accent = 0;
640 639
641 } else { 640 } else {
642 641
643 accent = keys->pressedPtr(row, col); 642 accent = keys->pressedPtr(row, col);
644 *accent = true; 643 *accent = true;
645 } 644 }
646 645
647 646
648 if (shift) { *shift = 0; shift = 0; } 647 if (shift) { *shift = 0; shift = 0; }
649 if (meta) { *meta = 0; meta = 0; } 648 if (meta) { *meta = 0; meta = 0; }
650 if (baccent) { *baccent = 0; } 649 if (baccent) { *baccent = 0; }
651 650
652 qkeycode = 0; 651 qkeycode = 0;
653 } 652 }
654 653
655 } 654 }
656 else { // normal char 655 else { // normal char
657 if ((shift || lock) && keys->shift(unicode)) { 656 if ((shift || lock) && keys->shift(unicode)) {
658 657
659 // make diaeresis/circumflex -> shift input shifted 658 // make diaeresis/circumflex -> shift input shifted
660 // diaeresis/circumflex chars 659 // diaeresis/circumflex chars
661 660
662 if (circumflex && keys->circumflex(keys->shift(unicode))) 661 if (circumflex && keys->circumflex(keys->shift(unicode)))
663 unicode = keys->circumflex(keys->shift(unicode)); 662 unicode = keys->circumflex(keys->shift(unicode));
664 else if (diaeresis && keys->diaeresis(keys->shift(unicode))) 663 else if (diaeresis && keys->diaeresis(keys->shift(unicode)))
665 unicode = keys->diaeresis(keys->shift(unicode)); 664 unicode = keys->diaeresis(keys->shift(unicode));
666 else if (baccent && keys->baccent(keys->shift(unicode))) 665 else if (baccent && keys->baccent(keys->shift(unicode)))
667 unicode = keys->baccent(keys->shift(unicode)); 666 unicode = keys->baccent(keys->shift(unicode));
668 else if (accent && keys->accent(keys->shift(unicode))) 667 else if (accent && keys->accent(keys->shift(unicode)))
669 unicode = keys->accent(keys->shift(unicode)); 668 unicode = keys->accent(keys->shift(unicode));
670 else if (meta && keys->meta(keys->shift(unicode))) 669 else if (meta && keys->meta(keys->shift(unicode)))
671 unicode = keys->meta(keys->shift(unicode)); 670 unicode = keys->meta(keys->shift(unicode));
672 else 671 else
673 unicode = keys->shift(unicode); 672 unicode = keys->shift(unicode);
674 } 673 }
675 else if (meta && keys->meta(unicode)) { 674 else if (meta && keys->meta(unicode)) {
676 unicode = keys->meta(unicode); 675 unicode = keys->meta(unicode);
677 } 676 }
678 else if (circumflex && keys->circumflex(unicode)) { 677 else if (circumflex && keys->circumflex(unicode)) {
679 unicode = keys->circumflex(unicode); 678 unicode = keys->circumflex(unicode);
680 } 679 }
681 else if (diaeresis && keys->diaeresis(unicode)) { 680 else if (diaeresis && keys->diaeresis(unicode)) {
682 681
683 unicode = keys->diaeresis(unicode); 682 unicode = keys->diaeresis(unicode);
684 } 683 }
685 else if (baccent && keys->baccent(unicode)) { 684 else if (baccent && keys->baccent(unicode)) {
686 unicode = keys->baccent(unicode); 685 unicode = keys->baccent(unicode);
687 } 686 }
688 else if (accent && keys->accent(unicode)) { 687 else if (accent && keys->accent(unicode)) {
689 unicode = keys->accent(unicode); 688 unicode = keys->accent(unicode);
690 } 689 }
691 } 690 }
692 691
693 // korean parsing 692 // korean parsing
694 if (keys->lang == "ko") { 693 if (keys->lang == "ko") {
695 694
696 unicode = parseKoreanInput(unicode); 695 unicode = parseKoreanInput(unicode);
697 } 696 }
698 697
699 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 698 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
700 699
701 if ('A' <= unicode && unicode <= 'z' && modifiers) { 700 if ('A' <= unicode && unicode <= 'z' && modifiers) {
702 701
703 qkeycode = QChar(unicode).upper(); 702 qkeycode = QChar(unicode).upper();
704 unicode = qkeycode - '@'; 703 unicode = qkeycode - '@';
705 } 704 }
706 705
707 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); 706 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false);
708 707
709 // pickboard stuff 708 // pickboard stuff
710 if (usePicks) { 709 if (usePicks) {
711 710
712 KeyboardConfig *dc = picks->dc; 711 KeyboardConfig *dc = picks->dc;
713 712
714 if (dc) { 713 if (dc) {
715 if (qkeycode == Qt::Key_Backspace) { 714 if (qkeycode == Qt::Key_Backspace) {
716 dc->input.remove(dc->input.last()); // remove last input 715 dc->input.remove(dc->input.last()); // remove last input
717 dc->decBackspaces(); 716 dc->decBackspaces();
718 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { 717 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
719 dc->input.clear(); 718 dc->input.clear();
720 dc->resetBackspaces(); 719 dc->resetBackspaces();
721 } else { 720 } else {
722 dc->add(QString(QChar(unicode))); 721 dc->add(QString(QChar(unicode)));
723 dc->incBackspaces(); 722 dc->incBackspaces();
724 } 723 }
725 } 724 }
726 picks->repaint(); 725 picks->repaint();
727 } 726 }
728 727
729 728
730 // painting 729 // painting
731 pressed = TRUE; 730 pressed = TRUE;
732 731
733 pressedKeyRow = row; 732 pressedKeyRow = row;
734 pressedKeyCol = col; 733 pressedKeyCol = col;
735 734
736 if (need_repaint) repaint(FALSE); 735 if (need_repaint) repaint(FALSE);
737 else { // just paint the one key pressed 736 else { // just paint the one key pressed
738 737
739 738
740 739
741 QPainter p(this); 740 QPainter p(this);
742 drawKeyboard(p, row, col); 741 drawKeyboard(p, row, col);
743 742
744 } 743 }
745 744
746 if (useRepeat) repeatTimer->start( 800 ); 745 if (useRepeat) repeatTimer->start( 800 );
747 //pressTid = startTimer(80); 746 //pressTid = startTimer(80);
748 747
749} 748}
750 749
751 750
752/* Keyboard::mouseReleaseEvent {{{1 */ 751/* Keyboard::mouseReleaseEvent {{{1 */
753void Keyboard::mouseReleaseEvent(QMouseEvent*) 752void Keyboard::mouseReleaseEvent(QMouseEvent*)
754{ 753{
755 pressed = FALSE; 754 pressed = FALSE;
756 //if ( pressTid == 0 ) 755 //if ( pressTid == 0 )
757#if defined(Q_WS_QWS) || defined(_WS_QWS_) 756#if defined(Q_WS_QWS) || defined(_WS_QWS_)
758 if ( unicode != -1 ) { 757 if ( unicode != -1 ) {
759 emit key( unicode, qkeycode, modifiers, false, false ); 758 emit key( unicode, qkeycode, modifiers, false, false );
760 repeatTimer->stop(); 759 repeatTimer->stop();
761 } 760 }
762#endif 761#endif
763 if (shift && unicode != 0) { 762 if (shift && unicode != 0) {
764 763
765 764
766 *shift = 0; // unpress shift key 765 *shift = 0; // unpress shift key
767 shift = 0; // reset the shift pointer 766 shift = 0; // reset the shift pointer
768 repaint(FALSE); 767 repaint(FALSE);
769 768
770 } 769 }
771 if (ctrl && unicode != 0) { 770 if (ctrl && unicode != 0) {
772 771
773 *ctrl = 0; 772 *ctrl = 0;
774 ctrl = 0; 773 ctrl = 0;
775 repaint(FALSE); 774 repaint(FALSE);
776 775
777 } 776 }
777 if (alt && alt != 0) {
778
779 *alt = 0;
780 alt = 0;
781 repaint(FALSE);
782
783 }
778 784
779 /* 785 /*
780 * do not make the meta key release after being pressed 786 * do not make the meta key release after being pressed
781 * 787 *
782 788
783 else if (meta && unicode != 0) { 789 else if (meta && unicode != 0) {
784 790
785 *meta = 0; 791 *meta = 0;
786 meta = 0; 792 meta = 0;
787 repaint(FALSE); 793 repaint(FALSE);
788 } 794 }
789 795
790 */ 796 */
791 797
792 else clearHighlight(); 798 else clearHighlight();
793} 799}
794 800
795/* Keyboard::timerEvent {{{1 */ 801/* Keyboard::timerEvent {{{1 */
796 802
797/* dont know what this does, but i think it is here so that if your screen 803/* dont know what this does, but i think it is here so that if your screen
798 * sticks (like on an ipaq) then it will stop repeating if you click another 804 * sticks (like on an ipaq) then it will stop repeating if you click another
799 * key... but who knows what anything does in this thing anyway? 805 * key... but who knows what anything does in this thing anyway?
800 806
801 void Keyboard::timerEvent(QTimerEvent* e) 807 void Keyboard::timerEvent(QTimerEvent* e)
802{ 808{
803 if ( e->timerId() == pressTid ) { 809 if ( e->timerId() == pressTid ) {
804 killTimer(pressTid); 810 killTimer(pressTid);
805 pressTid = 0; 811 pressTid = 0;
806 if ( !pressed ) 812 if ( !pressed )
807 cout << "calling clearHighlight from timerEvent\n"; 813 cout << "calling clearHighlight from timerEvent\n";
808 //clearHighlight(); 814 //clearHighlight();
809 } 815 }
810} 816}
811*/ 817*/
812 818
813void Keyboard::repeat() 819void Keyboard::repeat()
814{ 820{
815 821
816 repeatTimer->start( 200 ); 822 repeatTimer->start( 200 );
817 emit key( unicode, qkeycode, modifiers, true, true ); 823 emit key( unicode, qkeycode, modifiers, true, true );
818} 824}
819 825
820void Keyboard::clearHighlight() 826void Keyboard::clearHighlight()
821{ 827{
822 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 828 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
823 int tmpRow = pressedKeyRow; 829 int tmpRow = pressedKeyRow;
824 int tmpCol = pressedKeyCol; 830 int tmpCol = pressedKeyCol;
825 831
826 pressedKeyRow = -1; 832 pressedKeyRow = -1;
827 pressedKeyCol = -1; 833 pressedKeyCol = -1;
828 834
829 QPainter p(this); 835 QPainter p(this);
830 drawKeyboard(p, tmpRow, tmpCol); 836 drawKeyboard(p, tmpRow, tmpCol);
831 } 837 }
832} 838}
833 839
834 840
835/* Keyboard::sizeHint {{{1 */ 841/* Keyboard::sizeHint {{{1 */
836QSize Keyboard::sizeHint() const 842QSize Keyboard::sizeHint() const
837{ 843{
838 QFontMetrics fm=fontMetrics(); 844 QFontMetrics fm=fontMetrics();
839 int keyHeight = fm.lineSpacing() + 2; 845 int keyHeight = fm.lineSpacing() + 2;
840 846
841 return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); 847 return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1);
842} 848}
843 849
844 850
845void Keyboard::resetState() 851void Keyboard::resetState()
846{ 852{
847 if (shift) { *shift = 0; shift = 0; } 853 if (shift) { *shift = 0; shift = 0; }
848 if (lock) {*lock = 0; lock = 0; } 854 if (lock) {*lock = 0; lock = 0; }
849 if (meta) { *meta = 0; meta = 0; } 855 if (meta) { *meta = 0; meta = 0; }
850 if (circumflex) { *circumflex = 0; circumflex = 0; } 856 if (circumflex) { *circumflex = 0; circumflex = 0; }
851 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 857 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
852 if (baccent) { *baccent = 0; baccent = 0; } 858 if (baccent) { *baccent = 0; baccent = 0; }
853 if (accent) { *accent = 0; accent = 0; } 859 if (accent) { *accent = 0; accent = 0; }
854 860
855 schar = mchar = echar = 0; 861 schar = mchar = echar = 0;
856 picks->resetState(); 862 picks->resetState();
857} 863}
858 864
859/* Keyboard::togglePickboard {{{1 */ 865/* Keyboard::togglePickboard {{{1 */
860void Keyboard::togglePickboard(bool on_off) 866void Keyboard::togglePickboard(bool on_off)
861{ 867{
862 usePicks = on_off; 868 usePicks = on_off;
863 if (usePicks) { 869 if (usePicks) {
864 picks->show(); 870 picks->show();
865 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send 871 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
866 //adjustSize(); 872 //adjustSize();
867 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 873 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
868 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 874 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
869 } else { 875 } else {
870 876
871 picks->hide(); 877 picks->hide();
872 picks->resetState(); 878 picks->resetState();
873 //move(x(), y() + picks->height()); 879 //move(x(), y() + picks->height());
874 //adjustSize(); 880 //adjustSize();
875 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 881 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
876 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 882 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
877 883
878 } 884 }
879 /* 885 /*
880 * this closes && opens the input method 886 * this closes && opens the input method
881 */ 887 */
882 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 888 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
883 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 889 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
884} 890}
885 891
886void Keyboard::toggleRepeat(bool on) { 892void Keyboard::toggleRepeat(bool on) {
887 893
888 useRepeat = on; 894 useRepeat = on;
889 //cout << "setting useRepeat to: " << useRepeat << "\n"; 895 //cout << "setting useRepeat to: " << useRepeat << "\n";
890} 896}
891 897
892void Keyboard::cleanupConfigDlg() { 898void Keyboard::cleanupConfigDlg() {
893 899
894 if ( configdlg ) { 900 if ( configdlg ) {
895 delete (ConfigDlg *) configdlg; 901 delete (ConfigDlg *) configdlg;
896 configdlg = 0; 902 configdlg = 0;
897 } 903 }
898} 904}
899 905
900/* Keyboard::setMapTo ... {{{1 */ 906/* Keyboard::setMapTo ... {{{1 */
901void Keyboard::setMapToDefault() { 907void Keyboard::setMapToDefault() {
902 908
903 909
904 /* load current locale language map */ 910 /* load current locale language map */
905 Config *config = new Config("locale"); 911 Config *config = new Config("locale");
906 config->setGroup( "Language" ); 912 config->setGroup( "Language" );
907 QString l = config->readEntry( "Language" , "en" ); 913 QString l = config->readEntry( "Language" , "en" );
908 delete config; 914 delete config;
909 915
910 QString key_map = QPEApplication::qpeDir() + "share/multikey/" 916 QString key_map = QPEApplication::qpeDir() + "share/multikey/"
911 + l + ".keymap"; 917 + l + ".keymap";
912 918
913 /* save change to multikey config file */ 919 /* save change to multikey config file */
914 config = new Config("multikey"); 920 config = new Config("multikey");
915 config->setGroup ("keymaps"); 921 config->setGroup ("keymaps");
916 config->writeEntry ("current", key_map); // default closed 922 config->writeEntry ("current", key_map); // default closed
917 delete config; 923 delete config;
918 924
919 int prevRows = keys->rows(); 925 int prevRows = keys->rows();
920 926
921 delete keys; 927 delete keys;
922 keys = new Keys(key_map); 928 keys = new Keys(key_map);
923 929
924 // have to repaint the keyboard 930 // have to repaint the keyboard
925 if (prevRows != keys->rows()) { 931 if (prevRows != keys->rows()) {
926 932
927 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 933 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
928 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 934 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
929 935
930 } else repaint(FALSE); 936 } else repaint(FALSE);
931 937
932 resetState(); 938 resetState();
933} 939}
934 940
935void Keyboard::setMapToFile(QString map) { 941void Keyboard::setMapToFile(QString map) {
936 942
937 /* save change to multikey config file */ 943 /* save change to multikey config file */
938 Config *config = new Config("multikey"); 944 Config *config = new Config("multikey");
939 config->setGroup ("keymaps"); 945 config->setGroup ("keymaps");
940 config->writeEntry ("current", map); // default closed 946 config->writeEntry ("current", map); // default closed
941 947
942 delete config; 948 delete config;
943 949
944 int prevRows = keys->rows(); 950 int prevRows = keys->rows();
945 951
946 delete keys; 952 delete keys;
947 if (QFile(map).exists()) 953 if (QFile(map).exists())
948 keys = new Keys(map); 954 keys = new Keys(map);
949 else 955 else
950 keys = new Keys(); 956 keys = new Keys();
951 957
952 if (keys->rows() != prevRows) { 958 if (keys->rows() != prevRows) {
953 959
954 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 960 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
955 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 961 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
956 } 962 }
957 else repaint(FALSE); 963 else repaint(FALSE);
958 964
959 resetState(); 965 resetState();
960} 966}
961 967
962/* Keybaord::reloadKeyboard {{{1 */ 968/* Keybaord::reloadKeyboard {{{1 */
963void Keyboard::reloadKeyboard() { 969void Keyboard::reloadKeyboard() {
964 970
965 // reload colors and redraw 971 // reload colors and redraw
966 loadKeyboardColors(); 972 loadKeyboardColors();
967 repaint(); 973 repaint();
968 974
969} 975}