keyboard: fix cursor navigation and clean up the code a bit
This commit is contained in:
parent
debd286b4d
commit
a0995f6d72
|
@ -71,8 +71,7 @@ void QskInputCompositionModel::composeKey( Qt::Key key )
|
||||||
if ( !inputMethod )
|
if ( !inputMethod )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto focusObject = QGuiApplication::focusObject();
|
if ( !m_data->inputItem )
|
||||||
if ( !focusObject )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QInputMethodQueryEvent queryEvent(
|
QInputMethodQueryEvent queryEvent(
|
||||||
|
@ -224,8 +223,7 @@ void QskInputCompositionModel::commitCandidate( int index )
|
||||||
|
|
||||||
void QskInputCompositionModel::backspace()
|
void QskInputCompositionModel::backspace()
|
||||||
{
|
{
|
||||||
auto focusWindow = QGuiApplication::focusWindow();
|
if ( !m_data->inputItem )
|
||||||
if ( !focusWindow )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( !m_data->preedit.isEmpty() )
|
if ( !m_data->preedit.isEmpty() )
|
||||||
|
@ -253,8 +251,7 @@ void QskInputCompositionModel::moveCursor( Qt::Key key )
|
||||||
if ( key != Qt::Key_Left && key != Qt::Key_Right )
|
if ( key != Qt::Key_Left && key != Qt::Key_Right )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto focusWindow = QGuiApplication::focusWindow();
|
if ( !m_data->inputItem )
|
||||||
if ( !focusWindow )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Moving cursor is disabled when preedit is active.
|
// Moving cursor is disabled when preedit is active.
|
||||||
|
@ -263,8 +260,8 @@ void QskInputCompositionModel::moveCursor( Qt::Key key )
|
||||||
|
|
||||||
QKeyEvent moveCursorPress( QEvent::KeyPress, key, Qt::NoModifier );
|
QKeyEvent moveCursorPress( QEvent::KeyPress, key, Qt::NoModifier );
|
||||||
QKeyEvent moveCursorRelease( QEvent::KeyRelease, key, Qt::NoModifier );
|
QKeyEvent moveCursorRelease( QEvent::KeyRelease, key, Qt::NoModifier );
|
||||||
QCoreApplication::sendEvent( focusWindow, &moveCursorPress );
|
QCoreApplication::sendEvent( m_data->inputItem, &moveCursorPress );
|
||||||
QCoreApplication::sendEvent( focusWindow, &moveCursorRelease );
|
QCoreApplication::sendEvent( m_data->inputItem, &moveCursorRelease );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputCompositionModel::sendCompositionEvent( QInputMethodEvent* e )
|
void QskInputCompositionModel::sendCompositionEvent( QInputMethodEvent* e )
|
||||||
|
|
|
@ -21,13 +21,15 @@
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
|
|
||||||
QskInputContext::QskInputContext():
|
QskInputContext::QskInputContext():
|
||||||
Inherited()
|
Inherited(),
|
||||||
|
m_inputCompositionModel( new QskInputCompositionModel )
|
||||||
{
|
{
|
||||||
connect( qskSetup, &QskSetup::inputPanelChanged,
|
connect( qskSetup, &QskSetup::inputPanelChanged,
|
||||||
this, &QskInputContext::setInputPanel );
|
this, &QskInputContext::setInputPanel );
|
||||||
setInputPanel( qskSetup->inputPanel() );
|
setInputPanel( qskSetup->inputPanel() );
|
||||||
|
|
||||||
m_inputCompositionModel.reset( new QskInputCompositionModel );
|
// We could connect candidatesChanged() here, but we don't emit
|
||||||
|
// the signal in the normal composition model anyhow
|
||||||
}
|
}
|
||||||
|
|
||||||
QskInputContext::~QskInputContext()
|
QskInputContext::~QskInputContext()
|
||||||
|
|
|
@ -23,7 +23,7 @@ class QskInputContext : public QPlatformInputContext
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QskInputContext();
|
QskInputContext();
|
||||||
~QskInputContext();
|
~QskInputContext() override;
|
||||||
|
|
||||||
bool isValid() const override;
|
bool isValid() const override;
|
||||||
void update( Qt::InputMethodQueries ) override;
|
void update( Qt::InputMethodQueries ) override;
|
||||||
|
|
Loading…
Reference in New Issue