summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorBartlomiej Moskal <bartlomiej.moskal@qt.io>2022-09-09 09:55:56 +0200
committerBartlomiej Moskal <bartlomiej.moskal@qt.io>2022-12-21 04:11:58 +0100
commit02f1e72d5a18040832a9dd1426b176e5ba769f2f (patch)
tree6b58164dd214b0e4864e2b95c4fd7af08b1effec /tests/auto/widgets
parent4b892b1034fbae9fe492769c6057c8a6fa3fd5af (diff)
Android: Set EnterKeyNext as default type for QLineEdit
Behavior of EnterKey for virtual keyboard need to be changed for QLineEdit. Before this commit, ImeOption was set to IME_ACTION_DONE. Because of that, setting any text in QLineEdit automatically accept QDialogs. That was annoying, when more than one QLineEdit need to be set. [ChangeLog][Widgets][Android] EnterKey type is now changed from EnterKeyDefault to EnterKeyNext for virtual keyboard in QLineEdit. It is done only if the focus can be moved to widget below. Fixes: QTBUG-61652 Change-Id: I98a7686f9f675fccf0112b8d27d48ad8fd7a887f Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 74a011d96d..efd59059d0 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -267,6 +267,8 @@ private slots:
void inputMethodQueryImHints_data();
void inputMethodQueryImHints();
+ void inputMethodQueryEnterKeyType();
+
void inputMethodUpdate();
void undoRedoAndEchoModes_data();
@@ -4409,6 +4411,33 @@ void tst_QLineEdit::inputMethodQueryImHints()
QCOMPARE(static_cast<Qt::InputMethodHints>(value.toInt()), hints);
}
+void tst_QLineEdit::inputMethodQueryEnterKeyType()
+{
+ QWidget mw;
+ QVBoxLayout layout(&mw);
+ QLineEdit le1(&mw);
+ layout.addWidget(&le1);
+ mw.show();
+ QVariant enterType = le1.inputMethodQuery(Qt::ImEnterKeyType);
+ QCOMPARE(enterType.value<Qt::EnterKeyType>(), Qt::EnterKeyDefault);
+
+ mw.hide();
+ QLineEdit le2(&mw);
+ layout.addWidget(&le2);
+ mw.show();
+
+ enterType = le1.inputMethodQuery(Qt::ImEnterKeyType);
+#ifdef Q_OS_ANDROID
+ // QTBUG-61652
+ // EnterKey is changed to EnterKeyNext if the focus can be moved to widget below
+ QCOMPARE(enterType.value<Qt::EnterKeyType>(), Qt::EnterKeyNext);
+#else
+ QCOMPARE(enterType.value<Qt::EnterKeyType>(), Qt::EnterKeyDefault);
+#endif
+ enterType = le2.inputMethodQuery(Qt::ImEnterKeyType);
+ QCOMPARE(enterType.value<Qt::EnterKeyType>(), Qt::EnterKeyDefault);
+}
+
void tst_QLineEdit::inputMethodUpdate()
{
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))