aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/activeFocusOnTab
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-10-10 16:07:28 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-10-22 14:42:16 +0000
commite3bf4f771458590dd003fc710803c1c1babea68e (patch)
tree853c9805e2c21b79d5df479914da921db5725852 /tests/auto/activeFocusOnTab
parent51458ba5400c1dcaef1bd2101cbf60a8ddc2a0fa (diff)
Re-introduce SpinBox
It came up in discussions at the QtWS that even if we have Tumbler, people still want and expect to have the good old SpinBox control. SpinBox has it pros, such as that it might work better inside a vertical Flickable, and that in multi-field forms it might visually align better with other controls like TextFields. An early mockup of SpinBox was removed in 1c0edf0. A quote from the commit message: SpinBox is a desktop centric control. It won't be provided in Qt Quick Controls 2.0, but maybe later when desktop support is re-considered. Qt Quick Controls 2.0 will focus on embedded and mobile. SpinBox is still available in 1.x. While it is true that SpinBox might not be optimal for touch or mobile, the real reason for the removal was that validating decimal number input is very complicated. Even though locales have well- defined thousand separators and decimal points, users have very different expectations on how strict or relaxed the input validation should be. This change re-introduces a touch-optimized integer-based SpinBox. What makes it more touch friendly than the earlier version is that it has now auto-repeating buttons. Limiting it to integers avoids the decimal number input validation problem. We can introduce a separate DoubleSpinBox later if necessary - just like in QtWidgets. Change-Id: I2819060eb5d1ae6a8c00b0f12be703456085079d Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/auto/activeFocusOnTab')
-rw-r--r--tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml5
-rw-r--r--tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp33
2 files changed, 35 insertions, 3 deletions
diff --git a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
index 5ab0191e..cf107373 100644
--- a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
+++ b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml
@@ -141,6 +141,11 @@ Item {
objectName: "slider"
value: 0.5
}
+ SpinBox {
+ id: spinbox
+ objectName: "spinbox"
+ value: 50
+ }
// StackView
Switch {
id: swtich // switch
diff --git a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
index 88607514..c618a2d5 100644
--- a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
+++ b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp
@@ -191,7 +191,16 @@ void tst_activeFocusOnTab::allControls()
QVERIFY(item);
QVERIFY(item->hasActiveFocus());
- // Tab: slider->switch
+ // Tab: slider->spinbox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "spinbox");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Tab: spinbox->switch
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
@@ -290,7 +299,16 @@ void tst_activeFocusOnTab::allControls()
QVERIFY(item);
QVERIFY(item->hasActiveFocus());
- // BackTab: switch->switch
+ // BackTab: switch->spinbox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "spinbox");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: spinbox->slider
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
@@ -450,7 +468,16 @@ void tst_activeFocusOnTab::textControls()
QVERIFY(item);
QVERIFY(item->hasActiveFocus());
- // BackTab: textfield->textarea
+ // BackTab: textfield->spinbox
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
+ QGuiApplication::sendEvent(window, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(window->rootObject(), "spinbox");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // BackTab: spinbox->textarea
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());