-rw-r--r-- | core/launcher/inputmethods.cpp | 76 | ||||
-rw-r--r-- | core/launcher/inputmethods.h | 1 |
2 files changed, 69 insertions, 8 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index d89a366..8f3e812 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -100,8 +100,8 @@ InputMethods::InputMethods( QWidget *parent ) : | |||
100 | { | 100 | { |
101 | Config cfg( "Launcher" ); | 101 | Config cfg( "Launcher" ); |
102 | cfg.setGroup( "InputMethods" ); | 102 | cfg.setGroup( "InputMethods" ); |
103 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader; | 103 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; |
104 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : QWidget::WStyle_Tool; | 104 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0; |
105 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); | 105 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); |
106 | 106 | ||
107 | setBackgroundMode( PaletteBackground ); | 107 | setBackgroundMode( PaletteBackground ); |
@@ -532,16 +532,64 @@ void InputMethods::showKbd( bool on ) | |||
532 | if ( !mkeyboard ) | 532 | if ( !mkeyboard ) |
533 | return; | 533 | return; |
534 | 534 | ||
535 | if ( on ) { | 535 | if ( on ) |
536 | { | ||
536 | mkeyboard->resetState(); | 537 | mkeyboard->resetState(); |
537 | // HACK... Make the texteditor fit with all input methods | 538 | |
538 | // Input methods should also never use more than about 40% of the screen | ||
539 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); | 539 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); |
540 | mkeyboard->widget->resize( qApp->desktop()->width() * (inputWidgetWidth*0.01), height ); | 540 | int width = qApp->desktop()->width() * (inputWidgetWidth*0.01); |
541 | mkeyboard->widget->move( 0, mapToGlobal( QPoint() ).y() - height ); | 541 | int left = 0; |
542 | int top = mapToGlobal( QPoint() ).y() - height; | ||
543 | |||
544 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) | ||
545 | { | ||
546 | qDebug( "InputMethods: reading geometry." ); | ||
547 | Config cfg( "Launcher" ); | ||
548 | cfg.setGroup( "InputMethods" ); | ||
549 | int l = cfg.readNumEntry( "absX", -1 ); | ||
550 | int t = cfg.readNumEntry( "absY", -1 ); | ||
551 | int w = cfg.readNumEntry( "absWidth", -1 ); | ||
552 | int h = cfg.readNumEntry( "absHeight", -1 ); | ||
553 | |||
554 | if ( l > -1 && t > -1 && w > -1 && h > -1 ) | ||
555 | { | ||
556 | qDebug( "InputMethods: config values ( %d, %d, %d, %d ) are ok.", l, t, w, h ); | ||
557 | left = l; | ||
558 | top = t; | ||
559 | width = w; | ||
560 | height = h; | ||
561 | } | ||
562 | else | ||
563 | { | ||
564 | qDebug( "InputMethods: config values are new or not ok." ); | ||
565 | } | ||
566 | } | ||
567 | else | ||
568 | { | ||
569 | qDebug( "InputMethods: no floating selected." ); | ||
570 | } | ||
571 | mkeyboard->widget->resize( width, height ); | ||
572 | mkeyboard->widget->move( left, top ); | ||
542 | mkeyboard->widget->show(); | 573 | mkeyboard->widget->show(); |
543 | } else { | 574 | mkeyboard->widget->installEventFilter( this ); |
575 | } | ||
576 | else | ||
577 | { | ||
578 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) | ||
579 | { | ||
580 | QPoint pos = mkeyboard->widget->pos(); | ||
581 | QSize siz = mkeyboard->widget->size(); | ||
582 | qDebug( "InputMethods: saving geometry." ); | ||
583 | Config cfg( "Launcher" ); | ||
584 | cfg.setGroup( "InputMethods" ); | ||
585 | cfg.writeEntry( "absX", pos.x() ); | ||
586 | cfg.writeEntry( "absY", pos.y() ); | ||
587 | cfg.writeEntry( "absWidth", siz.width() ); | ||
588 | cfg.writeEntry( "absHeight", siz.height() ); | ||
589 | cfg.write(); | ||
544 | mkeyboard->widget->hide(); | 590 | mkeyboard->widget->hide(); |
591 | mkeyboard->widget->removeEventFilter( this ); | ||
592 | } | ||
545 | } | 593 | } |
546 | 594 | ||
547 | emit inputToggled( on ); | 595 | emit inputToggled( on ); |
@@ -564,3 +612,15 @@ void InputMethods::sendKey( ushort unicode, ushort scancode, ushort mod, bool pr | |||
564 | QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); | 612 | QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); |
565 | #endif | 613 | #endif |
566 | } | 614 | } |
615 | |||
616 | bool InputMethods::eventFilter( QObject* o, QEvent* e ) | ||
617 | { | ||
618 | if ( e->type() == QEvent::Close ) | ||
619 | { | ||
620 | ( (QCloseEvent*) e )->ignore(); | ||
621 | showKbd( false ); | ||
622 | kbdButton->setOn( false ); | ||
623 | return true; | ||
624 | } | ||
625 | return false; | ||
626 | } | ||
diff --git a/core/launcher/inputmethods.h b/core/launcher/inputmethods.h index 246661a..55ac020 100644 --- a/core/launcher/inputmethods.h +++ b/core/launcher/inputmethods.h | |||
@@ -73,6 +73,7 @@ public: | |||
73 | void hideInputMethod(); | 73 | void hideInputMethod(); |
74 | void unloadInputMethods(); | 74 | void unloadInputMethods(); |
75 | void loadInputMethods(); | 75 | void loadInputMethods(); |
76 | virtual bool eventFilter( QObject *, QEvent * ); | ||
76 | 77 | ||
77 | signals: | 78 | signals: |
78 | void inputToggled( bool on ); | 79 | void inputToggled( bool on ); |