summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Spoerl <[email protected]>2024-03-05 08:36:56 +0000
committerQt Cherry-pick Bot <[email protected]>2024-03-08 01:26:03 +0000
commit3231c458b1a5957d24217cf3e13b6f2fcecd4288 (patch)
tree55427a820a4e755bd96c15d02cc8f0d6eccad512
parent394b6d96b589ca2fb523f58986c71eb030096586 (diff)
Revert "QAndroidPlatformInputContext: send composition text and cursor jointly"
This reverts commit be3b9b2ab12f664c196d649e8c4247d70805d667. Reason for revert: Caused QTBUG-121561 Fixes: QTBUG-121561 Pick-to: 6.2 Change-Id: I4b59d97ede6c50d2575a7d7cebbe2291983dd19f Reviewed-by: Tor Arne Vestbø <[email protected]> (cherry picked from commit 46502f9705634f02626ee1057975463d1c0ae1f8) Reviewed-by: Qt Cherry-pick Bot <[email protected]> (cherry picked from commit c76dd919fd89a9cf4fcbbf162423d12f3b5d6090) (cherry picked from commit cf6f0191be77b17e9e8f78e87b12ba99fbd0006e)
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp22
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp40
2 files changed, 20 insertions, 42 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index 41f6ba13143..1ea326c7183 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -1156,13 +1156,21 @@ bool QAndroidInputContext::focusObjectStopComposing()
m_composingCursor = -1;
- // commit composing text and cursor position
- QList<QInputMethodEvent::Attribute> attributes;
- attributes.append(
- QInputMethodEvent::Attribute(QInputMethodEvent::Selection, localCursorPos, 0));
- QInputMethodEvent event(QString(), attributes);
- event.setCommitString(m_composingText);
- sendInputMethodEvent(&event);
+ {
+ // commit the composing test
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event(QString(), attributes);
+ event.setCommitString(m_composingText);
+ sendInputMethodEvent(&event);
+ }
+ {
+ // Moving Qt's cursor to where the preedit cursor used to be
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes.append(
+ QInputMethodEvent::Attribute(QInputMethodEvent::Selection, localCursorPos, 0));
+ QInputMethodEvent event(QString(), attributes);
+ sendInputMethodEvent(&event);
+ }
return true;
}
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index df65ac932b4..702fd5aab70 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -1593,44 +1593,14 @@ void tst_QLineEdit::textMask()
QCOMPARE( testWidget->text(), insertString );
}
-class LineEditChangingText : public QLineEdit
-{
- Q_OBJECT
-
-public:
- LineEditChangingText(QWidget *parent) : QLineEdit(parent)
- {
- connect(this, &QLineEdit::textEdited, this, &LineEditChangingText::onTextEdited);
- }
-
-public slots:
- void onTextEdited(const QString &text)
- {
- if (text.length() == 3)
- setText(text + "-");
- }
-};
-
void tst_QLineEdit::setText()
{
QLineEdit *testWidget = ensureTestWidget();
- {
- QSignalSpy editedSpy(testWidget, &QLineEdit::textEdited);
- QSignalSpy changedSpy(testWidget, &QLineEdit::textChanged);
- testWidget->setText("hello");
- QCOMPARE(editedSpy.size(), 0);
- QCOMPARE(changedSpy.value(0).value(0).toString(), QString("hello"));
- }
-
- QTestEventList keys;
- keys.addKeyClick(Qt::Key_A);
- keys.addKeyClick(Qt::Key_B);
- keys.addKeyClick(Qt::Key_C);
-
- LineEditChangingText lineEdit(nullptr);
- keys.simulate(&lineEdit);
- QCOMPARE(lineEdit.text(), "abc-");
- QCOMPARE(lineEdit.cursorPosition(), 4);
+ QSignalSpy editedSpy(testWidget, SIGNAL(textEdited(QString)));
+ QSignalSpy changedSpy(testWidget, SIGNAL(textChanged(QString)));
+ testWidget->setText("hello");
+ QCOMPARE(editedSpy.size(), 0);
+ QCOMPARE(changedSpy.value(0).value(0).toString(), QString("hello"));
}
void tst_QLineEdit::displayText_data()