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,
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

View File

@ -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 )

View File

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

View File

@ -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 );