-rw-r--r-- | core/launcher/inputmethods.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index 62e316c..5d8faf7 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -402,229 +402,229 @@ void InputMethods::chooseKbd() | |||
402 | } | 402 | } |
403 | 403 | ||
404 | void InputMethods::chooseIm() | 404 | void InputMethods::chooseIm() |
405 | { | 405 | { |
406 | QPopupMenu pop( this ); | 406 | QPopupMenu pop( this ); |
407 | 407 | ||
408 | int i = 0; | 408 | int i = 0; |
409 | QValueList<InputMethod>::Iterator it; | 409 | QValueList<InputMethod>::Iterator it; |
410 | for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { | 410 | for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { |
411 | pop.insertItem( (*it).name(), i ); | 411 | pop.insertItem( (*it).name(), i ); |
412 | if ( imethod == &(*it) ) | 412 | if ( imethod == &(*it) ) |
413 | pop.setItemChecked( i, TRUE ); | 413 | pop.setItemChecked( i, TRUE ); |
414 | } | 414 | } |
415 | 415 | ||
416 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); | 416 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); |
417 | QSize s = pop.sizeHint(); | 417 | QSize s = pop.sizeHint(); |
418 | pt.ry() -= s.height(); | 418 | pt.ry() -= s.height(); |
419 | pt.rx() -= s.width(); | 419 | pt.rx() -= s.width(); |
420 | i = pop.exec( pt ); | 420 | i = pop.exec( pt ); |
421 | if ( i == -1 ) | 421 | if ( i == -1 ) |
422 | return; | 422 | return; |
423 | InputMethod *im = &inputModifierList[i]; | 423 | InputMethod *im = &inputModifierList[i]; |
424 | 424 | ||
425 | chooseMethod(im); | 425 | chooseMethod(im); |
426 | } | 426 | } |
427 | 427 | ||
428 | void InputMethods::chooseKeyboard(InputMethod* im) | 428 | void InputMethods::chooseKeyboard(InputMethod* im) |
429 | { | 429 | { |
430 | if ( im != mkeyboard ) { | 430 | if ( im != mkeyboard ) { |
431 | if ( mkeyboard && mkeyboard->widget->isVisible() ) | 431 | if ( mkeyboard && mkeyboard->widget->isVisible() ) |
432 | mkeyboard->widget->hide(); | 432 | mkeyboard->widget->hide(); |
433 | mkeyboard = im; | 433 | mkeyboard = im; |
434 | kbdButton->setPixmap( *mkeyboard->icon() ); | 434 | kbdButton->setPixmap( *mkeyboard->icon() ); |
435 | } | 435 | } |
436 | if ( !kbdButton->isOn() ) | 436 | if ( !kbdButton->isOn() ) |
437 | kbdButton->setOn( TRUE ); | 437 | kbdButton->setOn( TRUE ); |
438 | else | 438 | else |
439 | showKbd( TRUE ); | 439 | showKbd( TRUE ); |
440 | } | 440 | } |
441 | 441 | ||
442 | static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) | 442 | static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) |
443 | { | 443 | { |
444 | if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) | 444 | if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) |
445 | return TRUE; | 445 | return TRUE; |
446 | 446 | ||
447 | if ( keyb->extInterface->compatible().contains(imname) ) | 447 | if ( keyb->extInterface->compatible().contains(imname) ) |
448 | return TRUE; | 448 | return TRUE; |
449 | 449 | ||
450 | return FALSE; | 450 | return FALSE; |
451 | } | 451 | } |
452 | 452 | ||
453 | // Updates the display of the soft keyboards available to the current input method | 453 | // Updates the display of the soft keyboards available to the current input method |
454 | void InputMethods::updateKeyboards(InputMethod *im ) | 454 | void InputMethods::updateKeyboards(InputMethod *im ) |
455 | { | 455 | { |
456 | uint count; | 456 | uint count; |
457 | 457 | ||
458 | if ( im ) { | 458 | if ( im ) { |
459 | QString imname = im->libName.mid(im->libName.findRev('/') + 1); | 459 | QString imname = im->libName.mid(im->libName.findRev('/') + 1); |
460 | 460 | ||
461 | if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { | 461 | if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { |
462 | kbdButton->setOn( FALSE ); | 462 | kbdButton->setOn( FALSE ); |
463 | showKbd( FALSE ); | 463 | showKbd( FALSE ); |
464 | mkeyboard = 0; | 464 | mkeyboard = 0; |
465 | } | 465 | } |
466 | 466 | ||
467 | count = 0; | 467 | count = 0; |
468 | 468 | ||
469 | QValueList<InputMethod>::Iterator it; | 469 | QValueList<InputMethod>::Iterator it; |
470 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { | 470 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { |
471 | if ( keyboardCompatible( &(*it), imname ) ) { | 471 | if ( keyboardCompatible( &(*it), imname ) ) { |
472 | if ( !mkeyboard ) { | 472 | if ( !mkeyboard ) { |
473 | mkeyboard = &(*it); | 473 | mkeyboard = &(*it); |
474 | kbdButton->setPixmap( *mkeyboard->icon() ); | 474 | kbdButton->setPixmap( *mkeyboard->icon() ); |
475 | } | 475 | } |
476 | 476 | ||
477 | count++; | 477 | count++; |
478 | } | 478 | } |
479 | } | 479 | } |
480 | } else { | 480 | } else { |
481 | count = inputMethodList.count(); | 481 | count = inputMethodList.count(); |
482 | if ( count && !mkeyboard ) { | 482 | if ( count && !mkeyboard ) { |
483 | mkeyboard = &inputMethodList[0]; | 483 | mkeyboard = &inputMethodList[0]; |
484 | kbdButton->setPixmap( *mkeyboard->icon() ); | 484 | kbdButton->setPixmap( *mkeyboard->icon() ); |
485 | } else if (!count){ | 485 | } else if (!count){ |
486 | mkeyboard = 0; //might be redundant | 486 | mkeyboard = 0; //might be redundant |
487 | } | 487 | } |
488 | } | 488 | } |
489 | 489 | ||
490 | if ( count > 1 ) | 490 | if ( count > 1 ) |
491 | kbdChoice->show(); | 491 | kbdChoice->show(); |
492 | else | 492 | else |
493 | kbdChoice->hide(); | 493 | kbdChoice->hide(); |
494 | 494 | ||
495 | if ( count ) | 495 | if ( count ) |
496 | kbdButton->show(); | 496 | kbdButton->show(); |
497 | else | 497 | else |
498 | kbdButton->hide(); | 498 | kbdButton->hide(); |
499 | } | 499 | } |
500 | 500 | ||
501 | void InputMethods::chooseMethod(InputMethod* im) | 501 | void InputMethods::chooseMethod(InputMethod* im) |
502 | { | 502 | { |
503 | if ( im != imethod ) { | 503 | if ( im != imethod ) { |
504 | updateKeyboards( im ); | 504 | updateKeyboards( im ); |
505 | 505 | ||
506 | Config cfg("qpe"); | 506 | Config cfg("qpe"); |
507 | cfg.setGroup("InputMethod"); | 507 | cfg.setGroup("InputMethod"); |
508 | if (im ) | 508 | if (im ) |
509 | cfg.writeEntry("im", im->name() ); | 509 | cfg.writeEntry("im", im->name() ); |
510 | if (mkeyboard) | 510 | if (mkeyboard) |
511 | cfg.writeEntry("current", mkeyboard->name() ); | 511 | cfg.writeEntry("current", mkeyboard->name() ); |
512 | 512 | ||
513 | QWSServer::setCurrentInputMethod( 0 ); | 513 | QWSServer::setCurrentInputMethod( 0 ); |
514 | imethod = im; | 514 | imethod = im; |
515 | if ( imethod && imethod->newIM ) | 515 | if ( imethod && imethod->newIM ) |
516 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); | 516 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); |
517 | else | 517 | else |
518 | QWSServer::setCurrentInputMethod( 0 ); | 518 | QWSServer::setCurrentInputMethod( 0 ); |
519 | 519 | ||
520 | if ( im ) | 520 | if ( im ) |
521 | imButton->raiseWidget(im->widget); | 521 | imButton->raiseWidget(im->widget); |
522 | else | 522 | else |
523 | imButton->hide(); //### good UI? make sure it is shown again! | 523 | imButton->hide(); //### good UI? make sure it is shown again! |
524 | } | 524 | } |
525 | } | 525 | } |
526 | 526 | ||
527 | void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) | 527 | void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) |
528 | { | 528 | { |
529 | if ( imethod && imethod->newIM ) | 529 | if ( imethod && imethod->newIM ) |
530 | imethod->extInterface->qcopReceive( msg, data ); | 530 | imethod->extInterface->qcopReceive( msg, data ); |
531 | } | 531 | } |
532 | 532 | ||
533 | 533 | ||
534 | void InputMethods::showKbd( bool on ) | 534 | void InputMethods::showKbd( bool on ) |
535 | { | 535 | { |
536 | if ( !mkeyboard ) | 536 | if ( !mkeyboard ) |
537 | return; | 537 | return; |
538 | 538 | ||
539 | if ( on ) | 539 | if ( on ) |
540 | { | 540 | { |
541 | mkeyboard->resetState(); | 541 | mkeyboard->resetState(); |
542 | 542 | ||
543 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); | 543 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); |
544 | int width = qApp->desktop()->width() * (inputWidgetWidth*0.01); | 544 | int width = qApp->desktop()->width() * (inputWidgetWidth*0.01); |
545 | int left = 0; | 545 | int left = 0; |
546 | int top = mapToGlobal( QPoint() ).y() - height; | 546 | int top = mapToGlobal( QPoint() ).y() - height; |
547 | 547 | ||
548 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) | 548 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) |
549 | { | 549 | { |
550 | qDebug( "InputMethods: reading geometry." ); | 550 | qDebug( "InputMethods: reading geometry." ); |
551 | Config cfg( "Launcher" ); | 551 | Config cfg( "Launcher" ); |
552 | cfg.setGroup( "InputMethods" ); | 552 | cfg.setGroup( "InputMethods" ); |
553 | int l = cfg.readNumEntry( "absX", -1 ); | 553 | int l = cfg.readNumEntry( "absX", -1 ); |
554 | int t = cfg.readNumEntry( "absY", -1 ); | 554 | int t = cfg.readNumEntry( "absY", -1 ); |
555 | int w = cfg.readNumEntry( "absWidth", -1 ); | 555 | int w = cfg.readNumEntry( "absWidth", -1 ); |
556 | int h = cfg.readNumEntry( "absHeight", -1 ); | 556 | int h = cfg.readNumEntry( "absHeight", -1 ); |
557 | 557 | ||
558 | if ( l > -1 && t > -1 && w > -1 && h > -1 ) | 558 | if ( l > -1 && t > -1 && w > -1 && h > -1 ) |
559 | { | 559 | { |
560 | qDebug( "InputMethods: config values ( %d, %d, %d, %d ) are ok.", l, t, w, h ); | 560 | qDebug( "InputMethods: config values ( %d, %d, %d, %d ) are ok.", l, t, w, h ); |
561 | left = l; | 561 | left = l; |
562 | top = t; | 562 | top = t; |
563 | width = w; | 563 | width = w; |
564 | height = h; | 564 | height = h; |
565 | } | 565 | } |
566 | else | 566 | else |
567 | { | 567 | { |
568 | qDebug( "InputMethods: config values are new or not ok." ); | 568 | qDebug( "InputMethods: config values are new or not ok." ); |
569 | } | 569 | } |
570 | } | 570 | } |
571 | else | 571 | else |
572 | { | 572 | { |
573 | qDebug( "InputMethods: no floating selected." ); | 573 | qDebug( "InputMethods: no floating selected." ); |
574 | } | 574 | } |
575 | mkeyboard->widget->resize( width, height ); | 575 | mkeyboard->widget->resize( width, height ); |
576 | mkeyboard->widget->move( left, top ); | 576 | mkeyboard->widget->move( left, top ); |
577 | mkeyboard->widget->show(); | 577 | mkeyboard->widget->show(); |
578 | mkeyboard->widget->installEventFilter( this ); | 578 | mkeyboard->widget->installEventFilter( this ); |
579 | } | 579 | } |
580 | else | 580 | else |
581 | { | 581 | { |
582 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) | 582 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) |
583 | { | 583 | { |
584 | QPoint pos = mkeyboard->widget->pos(); | 584 | QPoint pos = mkeyboard->widget->pos(); |
585 | QSize siz = mkeyboard->widget->size(); | 585 | QSize siz = mkeyboard->widget->size(); |
586 | qDebug( "InputMethods: saving geometry." ); | 586 | qDebug( "InputMethods: saving geometry." ); |
587 | Config cfg( "Launcher" ); | 587 | Config cfg( "Launcher" ); |
588 | cfg.setGroup( "InputMethods" ); | 588 | cfg.setGroup( "InputMethods" ); |
589 | cfg.writeEntry( "absX", pos.x() ); | 589 | cfg.writeEntry( "absX", pos.x() ); |
590 | cfg.writeEntry( "absY", pos.y() ); | 590 | cfg.writeEntry( "absY", pos.y() ); |
591 | cfg.writeEntry( "absWidth", siz.width() ); | 591 | cfg.writeEntry( "absWidth", siz.width() ); |
592 | cfg.writeEntry( "absHeight", siz.height() ); | 592 | cfg.writeEntry( "absHeight", siz.height() ); |
593 | cfg.write(); | 593 | cfg.write(); |
594 | mkeyboard->widget->hide(); | ||
595 | mkeyboard->widget->removeEventFilter( this ); | 594 | mkeyboard->widget->removeEventFilter( this ); |
596 | } | 595 | } |
596 | mkeyboard->widget->hide(); | ||
597 | } | 597 | } |
598 | 598 | ||
599 | emit inputToggled( on ); | 599 | emit inputToggled( on ); |
600 | } | 600 | } |
601 | 601 | ||
602 | bool InputMethods::shown() const | 602 | bool InputMethods::shown() const |
603 | { | 603 | { |
604 | return mkeyboard && mkeyboard->widget->isVisible(); | 604 | return mkeyboard && mkeyboard->widget->isVisible(); |
605 | } | 605 | } |
606 | 606 | ||
607 | QString InputMethods::currentShown() const | 607 | QString InputMethods::currentShown() const |
608 | { | 608 | { |
609 | return mkeyboard && mkeyboard->widget->isVisible() | 609 | return mkeyboard && mkeyboard->widget->isVisible() |
610 | ? mkeyboard->name() : QString::null; | 610 | ? mkeyboard->name() : QString::null; |
611 | } | 611 | } |
612 | 612 | ||
613 | void InputMethods::sendKey( ushort unicode, ushort scancode, ushort mod, bool press, bool repeat ) | 613 | void InputMethods::sendKey( ushort unicode, ushort scancode, ushort mod, bool press, bool repeat ) |
614 | { | 614 | { |
615 | #if defined(Q_WS_QWS) | 615 | #if defined(Q_WS_QWS) |
616 | QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); | 616 | QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); |
617 | #endif | 617 | #endif |
618 | } | 618 | } |
619 | 619 | ||
620 | bool InputMethods::eventFilter( QObject* o, QEvent* e ) | 620 | bool InputMethods::eventFilter( QObject* o, QEvent* e ) |
621 | { | 621 | { |
622 | if ( e->type() == QEvent::Close ) | 622 | if ( e->type() == QEvent::Close ) |
623 | { | 623 | { |
624 | ( (QCloseEvent*) e )->ignore(); | 624 | ( (QCloseEvent*) e )->ignore(); |
625 | showKbd( false ); | 625 | showKbd( false ); |
626 | kbdButton->setOn( false ); | 626 | kbdButton->setOn( false ); |
627 | return true; | 627 | return true; |
628 | } | 628 | } |
629 | return false; | 629 | return false; |
630 | } | 630 | } |