input panel improvements

This commit is contained in:
Uwe Rathmann 2018-05-09 08:20:59 +02:00
parent f9ef60e2d5
commit 6b47678805
5 changed files with 34 additions and 16 deletions

View File

@ -265,6 +265,15 @@ void QskInputContext::showInputPanel()
this, &QPlatformInputContext::emitLocaleChanged, this, &QPlatformInputContext::emitLocaleChanged,
Qt::UniqueConnection ); 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 ) if ( QskDialog::instance()->policy() == QskDialog::TopLevelWindow )
{ {
// The input panel is embedded in a top level window // The input panel is embedded in a top level window

View File

@ -369,7 +369,6 @@ void QskInputPanel::processKey( int key,
const auto result = m_data->engine->processKey( key, inputHints, spaceLeft ); const auto result = m_data->engine->processKey( key, inputHints, spaceLeft );
auto inputItem = m_data->inputItem; auto inputItem = m_data->inputItem;
auto inputProxy = m_data->inputProxy;
if ( result.key ) if ( result.key )
{ {
@ -377,15 +376,12 @@ void QskInputPanel::processKey( int key,
{ {
case Qt::Key_Return: case Qt::Key_Return:
{ {
if ( m_data->hasInputProxy ) done( true );
qskSendReplaceText( inputItem, inputProxy->text() );
qskSendKey( inputItem, result.key );
break; break;
} }
case Qt::Key_Escape: case Qt::Key_Escape:
{ {
qskSendKey( inputItem, result.key ); done( false );
break; break;
} }
default: 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 ) void QskInputPanel::processInputMethodQueries( Qt::InputMethodQueries queries )
{ {
if ( m_data->inputItem == nullptr ) if ( m_data->inputItem == nullptr )

View File

@ -65,6 +65,7 @@ protected:
Qt::InputMethodHints, int spaceLeft ); Qt::InputMethodHints, int spaceLeft );
virtual void updatePrediction(); virtual void updatePrediction();
virtual void done( bool success );
private: private:
void commitKey( int key ); void commitKey( int key );

View File

@ -30,18 +30,18 @@ public:
QskVirtualKeyboard( QQuickItem* parent = nullptr ); QskVirtualKeyboard( QQuickItem* parent = nullptr );
virtual ~QskVirtualKeyboard() override; virtual ~QskVirtualKeyboard() override;
virtual QskAspect::Subcontrol effectiveSubcontrol(
QskAspect::Subcontrol ) const override;
void updateLocale( const QLocale& );
void setMode( Mode ); void setMode( Mode );
Mode mode() const; Mode mode() const;
void updateLocale( const QLocale& );
virtual qreal heightForWidth( qreal width ) const override; virtual qreal heightForWidth( qreal width ) const override;
virtual qreal widthForHeight( qreal height ) const override; virtual qreal widthForHeight( qreal height ) const override;
virtual QSizeF contentsSizeHint() const override; virtual QSizeF contentsSizeHint() const override;
virtual QskAspect::Subcontrol effectiveSubcontrol(
QskAspect::Subcontrol ) const override;
Q_SIGNALS: Q_SIGNALS:
void modeChanged( Mode ); void modeChanged( Mode );
void keySelected( int keyCode ); void keySelected( int keyCode );

View File

@ -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_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 ) }, { 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_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_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*/ }, { 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_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_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*/ }, { 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_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_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 }, { 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_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_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 ) }, { 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_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 }
} }
}, },
{ {