[Android] Remove signal and slot mechanism to listen states in editor's
Task-number: QTBUG-58013 Change-Id: Ib589f1b69e2e82026d27fbc7519d10e18ae21f59 Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
This commit is contained in:
parent
86bb14b2b9
commit
a40a512dec
@ -853,9 +853,44 @@ void QAndroidInputContext::update(Qt::InputMethodQueries queries)
|
|||||||
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery(queries);
|
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery(queries);
|
||||||
if (query.isNull())
|
if (query.isNull())
|
||||||
return;
|
return;
|
||||||
#warning TODO extract the needed data from query
|
|
||||||
|
if (query->value(Qt::ImCursorPosition).toInt() >= 0 &&
|
||||||
|
query->value(Qt::ImSurroundingText).toString()
|
||||||
|
.left(query->value(Qt::ImCursorPosition).toInt()).length() >= 0) {
|
||||||
|
|
||||||
|
// Cursor position should be always valid
|
||||||
|
// when object is composing
|
||||||
|
if (focusObjectIsComposing())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// NOTE: This seems to be happening sometimes
|
||||||
|
// when qt quick application is booted up
|
||||||
|
if (m_focusObject == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_focusObject->isWidgetType())
|
||||||
|
updateCursorPosition();
|
||||||
|
else
|
||||||
|
updateCursorPositionInRange(query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QAndroidInputContext::updateCursorPositionInRange(const QSharedPointer<QInputMethodQueryEvent> &query)
|
||||||
|
{
|
||||||
|
QObject *input = qGuiApp->focusObject();
|
||||||
|
QList<QInputMethodEvent::Attribute> attributes;
|
||||||
|
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
|
||||||
|
query->value(Qt::ImCursorPosition).toInt(), 1));
|
||||||
|
|
||||||
|
QInputMethodEvent event(QString(), attributes);
|
||||||
|
QCoreApplication::sendEvent(input, &event);
|
||||||
|
|
||||||
|
QtAndroidInput::updateSelection(query->value(Qt::ImCursorPosition).toInt(),
|
||||||
|
query->value(Qt::ImCursorPosition).toInt(), 0,
|
||||||
|
query->value(Qt::ImSurroundingText).toString().length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QAndroidInputContext::invokeAction(QInputMethod::Action action, int cursorPosition)
|
void QAndroidInputContext::invokeAction(QInputMethod::Action action, int cursorPosition)
|
||||||
{
|
{
|
||||||
#warning TODO Handle at least QInputMethod::ContextMenu action
|
#warning TODO Handle at least QInputMethod::ContextMenu action
|
||||||
@ -886,12 +921,6 @@ void QAndroidInputContext::showInputPanel()
|
|||||||
if (query.isNull())
|
if (query.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
disconnect(m_updateCursorPosConnection);
|
|
||||||
if (qGuiApp->focusObject()->metaObject()->indexOfSignal("cursorPositionChanged(int,int)") >= 0) // QLineEdit breaks the pattern
|
|
||||||
m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(updateCursorPosition()));
|
|
||||||
else
|
|
||||||
m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
|
|
||||||
|
|
||||||
QRect rect = cursorRect();
|
QRect rect = cursorRect();
|
||||||
if (!isInputPanelVisible())
|
if (!isInputPanelVisible())
|
||||||
QtAndroidInput::showSoftwareKeyboard(rect.left(), rect.top(), rect.width(), rect.height(),
|
QtAndroidInput::showSoftwareKeyboard(rect.left(), rect.top(), rect.width(), rect.height(),
|
||||||
|
@ -156,13 +156,13 @@ private:
|
|||||||
void focusObjectStartComposing();
|
void focusObjectStartComposing();
|
||||||
bool focusObjectStopComposing();
|
bool focusObjectStopComposing();
|
||||||
QRect cursorRect();
|
QRect cursorRect();
|
||||||
|
void updateCursorPositionInRange(const QSharedPointer<QInputMethodQueryEvent> &query);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExtractedText m_extractedText;
|
ExtractedText m_extractedText;
|
||||||
QString m_composingText;
|
QString m_composingText;
|
||||||
int m_composingTextStart;
|
int m_composingTextStart;
|
||||||
int m_composingCursor;
|
int m_composingCursor;
|
||||||
QMetaObject::Connection m_updateCursorPosConnection;
|
|
||||||
HandleModes m_handleMode;
|
HandleModes m_handleMode;
|
||||||
int m_batchEditNestingLevel;
|
int m_batchEditNestingLevel;
|
||||||
QObject *m_focusObject;
|
QObject *m_focusObject;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user