Revert "[Android] Remove signal and slot mechanism to listen states in editor's"
This reverts commit a40a512dec0f34e84eb63812af556608f03713ff. It caused UI freezes and cursor position inconsistencies. See the linked bugs. Pick-to: 6.2 6.2.1 5.15 Task-number: QTBUG-58013 Task-number: QTBUG-93414 Task-number: QTBUG-95669 Task-number: QTBUG-96671 Task-number: QTBUG-96675 Task-number: QTBUG-96769 Change-Id: Ie8100538609a1460713ca9115cdbe329654d0772 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
2160042dc3
commit
2630c15a3d
@ -882,44 +882,9 @@ void QAndroidInputContext::update(Qt::InputMethodQueries queries)
|
||||
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery(queries);
|
||||
if (query.isNull())
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
#warning TODO extract the needed data from 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)
|
||||
{
|
||||
#warning TODO Handle at least QInputMethod::ContextMenu action
|
||||
@ -950,6 +915,12 @@ void QAndroidInputContext::showInputPanel()
|
||||
if (query.isNull())
|
||||
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();
|
||||
if (!isInputPanelVisible())
|
||||
QtAndroidInput::showSoftwareKeyboard(rect.left(), rect.top(), rect.width(), rect.height(),
|
||||
|
@ -156,13 +156,13 @@ private:
|
||||
void focusObjectStartComposing();
|
||||
bool focusObjectStopComposing();
|
||||
QRect cursorRect();
|
||||
void updateCursorPositionInRange(const QSharedPointer<QInputMethodQueryEvent> &query);
|
||||
|
||||
private:
|
||||
ExtractedText m_extractedText;
|
||||
QString m_composingText;
|
||||
int m_composingTextStart;
|
||||
int m_composingCursor;
|
||||
QMetaObject::Connection m_updateCursorPosConnection;
|
||||
HandleModes m_handleMode;
|
||||
int m_batchEditNestingLevel;
|
||||
QObject *m_focusObject;
|
||||
|
Loading…
x
Reference in New Issue
Block a user