diff --git a/src/inputpanel/QskInputContext.cpp b/src/inputpanel/QskInputContext.cpp index 4d4e01e3..f3d115aa 100644 --- a/src/inputpanel/QskInputContext.cpp +++ b/src/inputpanel/QskInputContext.cpp @@ -265,6 +265,15 @@ void QskInputContext::showInputPanel() this, &QPlatformInputContext::emitLocaleChanged, Qt::UniqueConnection ); + if ( qskInputPanel->parent() == nullptr ) + { + /* + Take ownership to avoid, that the panel gets + destroyed together with the popup/window + */ + qskInputPanel->setParent( this ); + } + if ( QskDialog::instance()->policy() == QskDialog::TopLevelWindow ) { // The input panel is embedded in a top level window diff --git a/src/inputpanel/QskInputPanel.cpp b/src/inputpanel/QskInputPanel.cpp index 069f9f42..753412fc 100644 --- a/src/inputpanel/QskInputPanel.cpp +++ b/src/inputpanel/QskInputPanel.cpp @@ -369,7 +369,6 @@ void QskInputPanel::processKey( int key, const auto result = m_data->engine->processKey( key, inputHints, spaceLeft ); auto inputItem = m_data->inputItem; - auto inputProxy = m_data->inputProxy; if ( result.key ) { @@ -377,15 +376,12 @@ void QskInputPanel::processKey( int key, { case Qt::Key_Return: { - if ( m_data->hasInputProxy ) - qskSendReplaceText( inputItem, inputProxy->text() ); - - qskSendKey( inputItem, result.key ); + done( true ); break; } case Qt::Key_Escape: { - qskSendKey( inputItem, result.key ); + done( false ); break; } default: @@ -401,6 +397,18 @@ void QskInputPanel::processKey( int key, } } +void QskInputPanel::done( bool success ) +{ + if ( success ) + { + if ( m_data->hasInputProxy ) + qskSendReplaceText( m_data->inputItem, m_data->inputProxy->text() ); + } + + qskSendKey( m_data->inputItem, + success ? Qt::Key_Return : Qt::Key_Escape ); +} + void QskInputPanel::processInputMethodQueries( Qt::InputMethodQueries queries ) { if ( m_data->inputItem == nullptr ) diff --git a/src/inputpanel/QskInputPanel.h b/src/inputpanel/QskInputPanel.h index 79f72160..0054bfad 100644 --- a/src/inputpanel/QskInputPanel.h +++ b/src/inputpanel/QskInputPanel.h @@ -65,6 +65,7 @@ protected: Qt::InputMethodHints, int spaceLeft ); virtual void updatePrediction(); + virtual void done( bool success ); private: void commitKey( int key ); diff --git a/src/inputpanel/QskVirtualKeyboard.h b/src/inputpanel/QskVirtualKeyboard.h index 8d3c57c5..373c189b 100644 --- a/src/inputpanel/QskVirtualKeyboard.h +++ b/src/inputpanel/QskVirtualKeyboard.h @@ -30,18 +30,18 @@ public: QskVirtualKeyboard( QQuickItem* parent = nullptr ); virtual ~QskVirtualKeyboard() override; - virtual QskAspect::Subcontrol effectiveSubcontrol( - QskAspect::Subcontrol ) const override; - - void updateLocale( const QLocale& ); - void setMode( Mode ); Mode mode() const; + void updateLocale( const QLocale& ); + virtual qreal heightForWidth( qreal width ) const override; virtual qreal widthForHeight( qreal height ) const override; virtual QSizeF contentsSizeHint() const override; + virtual QskAspect::Subcontrol effectiveSubcontrol( + QskAspect::Subcontrol ) const override; + Q_SIGNALS: void modeChanged( Mode ); void keySelected( int keyCode ); diff --git a/src/inputpanel/QskVirtualKeyboardLayouts.cpp b/src/inputpanel/QskVirtualKeyboardLayouts.cpp index ecadef53..93780416 100644 --- a/src/inputpanel/QskVirtualKeyboardLayouts.cpp +++ b/src/inputpanel/QskVirtualKeyboardLayouts.cpp @@ -327,7 +327,7 @@ { LOWER( Qt::Key_Q ), LOWER( Qt::Key_W ), LOWER( Qt::Key_E ), LOWER( Qt::Key_R ), LOWER( Qt::Key_T ), LOWER( Qt::Key_Z ), LOWER( Qt::Key_U ), LOWER( Qt::Key_I ), LOWER( Qt::Key_O ), LOWER( Qt::Key_P ), 0x0151 /*o double acute*/ }, { LOWER( Qt::Key_A ), LOWER( Qt::Key_S ), LOWER( Qt::Key_D ), LOWER( Qt::Key_F ), LOWER( Qt::Key_G ), LOWER( Qt::Key_H ), LOWER( Qt::Key_J ), LOWER( Qt::Key_K ), LOWER( Qt::Key_L ), LOWER( Qt::Key_Eacute ), LOWER( Qt::Key_Aacute ) }, { Qt::Key_CapsLock, LOWER( Qt::Key_Y ), LOWER( Qt::Key_X ), LOWER( Qt::Key_C ), LOWER( Qt::Key_V ), LOWER( Qt::Key_B ), LOWER( Qt::Key_N ), LOWER( Qt::Key_M ), Qt::Key_Backspace }, - { Qt::Key_Mode_switch, Qt::Key_0, LOWER( Qt::Key_Icircumflex), LOWER( Qt::Key_Acircumflex ), Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } + { Qt::Key_Mode_switch, Qt::Key_0, LOWER( Qt::Key_Icircumflex ), LOWER( Qt::Key_Acircumflex ), Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } } }, { @@ -550,7 +550,7 @@ { LOWER( Qt::Key_Q ), LOWER( Qt::Key_W ), LOWER( Qt::Key_E ), LOWER( Qt::Key_R ), LOWER( Qt::Key_T ), LOWER( Qt::Key_Z ), LOWER( Qt::Key_U ), LOWER( Qt::Key_I ), LOWER( Qt::Key_O ), LOWER( Qt::Key_P ), 0x017C /*z dot*/ }, { LOWER( Qt::Key_A ), LOWER( Qt::Key_S ), LOWER( Qt::Key_D ), LOWER( Qt::Key_F ), LOWER( Qt::Key_G ), LOWER( Qt::Key_H ), LOWER( Qt::Key_J ), LOWER( Qt::Key_K ), LOWER( Qt::Key_L ), 0x0142 /*l stroke*/, 0x0105 /*a ogonek*/ }, { Qt::Key_CapsLock, LOWER( Qt::Key_Y ), LOWER( Qt::Key_X ), LOWER( Qt::Key_C ), LOWER( Qt::Key_V ), LOWER( Qt::Key_B ), LOWER( Qt::Key_N ), LOWER( Qt::Key_M ), Qt::Key_Backspace }, - { Qt::Key_Mode_switch, LOWER( Qt::Key_Oacute), 0x015B /*s acute*/, Qt::Key_Minus, Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } + { Qt::Key_Mode_switch, LOWER( Qt::Key_Oacute ), 0x015B /*s acute*/, Qt::Key_Minus, Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } } }, { @@ -613,7 +613,7 @@ { LOWER( Qt::Key_Q ), LOWER( Qt::Key_W ), LOWER( Qt::Key_E ), LOWER( Qt::Key_R ), LOWER( Qt::Key_T ), LOWER( Qt::Key_Z ), LOWER( Qt::Key_U ), LOWER( Qt::Key_I ), LOWER( Qt::Key_O ), LOWER( Qt::Key_P ), 0x0103 /*a breve*/ }, { LOWER( Qt::Key_A ), LOWER( Qt::Key_S ), LOWER( Qt::Key_D ), LOWER( Qt::Key_F ), LOWER( Qt::Key_G ), LOWER( Qt::Key_H ), LOWER( Qt::Key_J ), LOWER( Qt::Key_K ), LOWER( Qt::Key_L ), 0x015F /*s cedilla*/, 0x0163 /*t cedilla*/ }, { Qt::Key_CapsLock, LOWER( Qt::Key_Y ), LOWER( Qt::Key_X ), LOWER( Qt::Key_C ), LOWER( Qt::Key_V ), LOWER( Qt::Key_B ), LOWER( Qt::Key_N ), LOWER( Qt::Key_M ), Qt::Key_Backspace }, - { Qt::Key_Mode_switch, Qt::Key_BracketRight, LOWER( Qt::Key_Icircumflex), LOWER( Qt::Key_Acircumflex), Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } + { Qt::Key_Mode_switch, Qt::Key_BracketRight, LOWER( Qt::Key_Icircumflex ), LOWER( Qt::Key_Acircumflex ), Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } } }, { @@ -708,7 +708,7 @@ { LOWER( Qt::Key_Q ), LOWER( Qt::Key_W ), LOWER( Qt::Key_E ), LOWER( Qt::Key_R ), LOWER( Qt::Key_T ), LOWER( Qt::Key_Z ), LOWER( Qt::Key_U ), LOWER( Qt::Key_I ), LOWER( Qt::Key_O ), LOWER( Qt::Key_P ), LOWER( Qt::Key_Uacute ) }, { LOWER( Qt::Key_A ), LOWER( Qt::Key_S ), LOWER( Qt::Key_D ), LOWER( Qt::Key_F ), LOWER( Qt::Key_G ), LOWER( Qt::Key_H ), LOWER( Qt::Key_J ), LOWER( Qt::Key_K ), LOWER( Qt::Key_L ), LOWER( Qt::Key_Ocircumflex ), Qt::Key_section }, { Qt::Key_CapsLock, LOWER( Qt::Key_Y ), LOWER( Qt::Key_X ), LOWER( Qt::Key_C ), LOWER( Qt::Key_V ), LOWER( Qt::Key_B ), LOWER( Qt::Key_N ), LOWER( Qt::Key_M ), Qt::Key_Backspace }, - { Qt::Key_Mode_switch, Qt::Key_Semicolon, LOWER( Qt::Key_Adiaeresis), Qt::Key_Minus, Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } + { Qt::Key_Mode_switch, Qt::Key_Semicolon, LOWER( Qt::Key_Adiaeresis ), Qt::Key_Minus, Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } } }, { @@ -739,7 +739,7 @@ { LOWER( Qt::Key_Q ), LOWER( Qt::Key_W ), LOWER( Qt::Key_E ), LOWER( Qt::Key_R ), LOWER( Qt::Key_T ), LOWER( Qt::Key_Y ), LOWER( Qt::Key_U ), 0x0131 /*dotless i*/, LOWER( Qt::Key_O ), LOWER( Qt::Key_P ), 0x011F /*g breve*/ }, { LOWER( Qt::Key_A ), LOWER( Qt::Key_S ), LOWER( Qt::Key_D ), LOWER( Qt::Key_F ), LOWER( Qt::Key_G ), LOWER( Qt::Key_H ), LOWER( Qt::Key_J ), LOWER( Qt::Key_K ), LOWER( Qt::Key_L ), 0x015F /*s cedilla*/, LOWER( Qt::Key_I ) }, { Qt::Key_CapsLock, LOWER( Qt::Key_Z ), LOWER( Qt::Key_X ), LOWER( Qt::Key_C ), LOWER( Qt::Key_V ), LOWER( Qt::Key_B ), LOWER( Qt::Key_N ), LOWER( Qt::Key_M ), LOWER( Qt::Key_Odiaeresis ), 0x00E7 /*c cedilla*/, Qt::Key_Backspace }, - { Qt::Key_Mode_switch, LOWER( Qt::Key_Udiaeresis), Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } + { Qt::Key_Mode_switch, LOWER( Qt::Key_Udiaeresis ), Qt::Key_Space, Qt::Key_Comma, Qt::Key_Period, Qt::Key_Left, Qt::Key_Right, Qt::Key_Return } } }, {