aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-06 16:06:32 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-17 09:51:41 +0000
commitbd5e078e5b908dc647b5395f9a772074ce206670 (patch)
tree1a9146ff01484fa43c554c7cdaefc35e483a5568 /tests
parenta6e55c907e8b1f2928d7b642272e29522965ac6d (diff)
Make hoverEnabled propagate to children
Hover effects can be sometimes a bit disturbing. This change makes it possible to conveniently disable hover effects for a tree of controls in one go. For example, to disable hover effects for a page including its header, footer, and all list items: Page { hoverEnabled: false header: ... footer: ... ListView { delegate: ... } } [ChangeLog][Controls][Important Behavior Changes] Control::hoverEnabled has been made to inherit to children, to make it possible to disable hover effects for a tree of controls in one place. Change-Id: Ia87144f2cc04957a32f89d3313816b91d97db635 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_control.qml40
-rw-r--r--tests/auto/drawer/tst_drawer.cpp9
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/auto/controls/data/tst_control.qml b/tests/auto/controls/data/tst_control.qml
index 77f23fa5..f07f6051 100644
--- a/tests/auto/controls/data/tst_control.qml
+++ b/tests/auto/controls/data/tst_control.qml
@@ -852,7 +852,9 @@ TestCase {
verify(control)
compare(control.hovered, false)
- compare(control.hoverEnabled, false)
+ compare(control.hoverEnabled, Qt.styleHints.useHoverEffects)
+
+ control.hoverEnabled = false
mouseMove(control, control.width / 2, control.height / 2)
compare(control.hovered, false)
@@ -874,6 +876,42 @@ TestCase {
control.destroy()
}
+ function test_hoverEnabled() {
+ var control = component.createObject(testCase)
+ compare(control.hoverEnabled, Qt.styleHints.useHoverEffects)
+
+ var child = component.createObject(control)
+ var grandChild = component.createObject(child)
+
+ var childExplicitHoverEnabled = component.createObject(control, {hoverEnabled: true})
+ var grandChildExplicitHoverDisabled = component.createObject(childExplicitHoverEnabled, {hoverEnabled: false})
+
+ var childExplicitHoverDisabled = component.createObject(control, {hoverEnabled: false})
+ var grandChildExplicitHoverEnabled = component.createObject(childExplicitHoverDisabled, {hoverEnabled: true})
+
+ control.hoverEnabled = false
+ compare(control.hoverEnabled, false)
+ compare(grandChild.hoverEnabled, false)
+
+ compare(childExplicitHoverEnabled.hoverEnabled, true)
+ compare(grandChildExplicitHoverDisabled.hoverEnabled, false)
+
+ compare(childExplicitHoverDisabled.hoverEnabled, false)
+ compare(grandChildExplicitHoverEnabled.hoverEnabled, true)
+
+ control.hoverEnabled = true
+ compare(control.hoverEnabled, true)
+ compare(grandChild.hoverEnabled, true)
+
+ compare(childExplicitHoverEnabled.hoverEnabled, true)
+ compare(grandChildExplicitHoverDisabled.hoverEnabled, false)
+
+ compare(childExplicitHoverDisabled.hoverEnabled, false)
+ compare(grandChildExplicitHoverEnabled.hoverEnabled, true)
+
+ control.destroy()
+ }
+
function test_implicitSize() {
var control = component.createObject(testCase)
verify(control)
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index 4e9e1e67..58a5ba3c 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -452,6 +452,10 @@ void tst_Drawer::hover()
QVERIFY(drawer);
drawer->setModal(modal);
+ QQuickControl *drawerItem = qobject_cast<QQuickControl *>(drawer->popupItem());
+ QVERIFY(drawerItem);
+ QVERIFY(drawerItem->isHoverEnabled());
+
QQuickButton *backgroundButton = window->property("backgroundButton").value<QQuickButton*>();
QVERIFY(backgroundButton);
backgroundButton->setHoverEnabled(true);
@@ -469,16 +473,19 @@ void tst_Drawer::hover()
QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1));
QCOMPARE(backgroundButton->isHovered(), !modal);
QVERIFY(!drawerButton->isHovered());
+ QVERIFY(!drawerItem->isHovered());
// hover the drawer background
QTest::mouseMove(window, QPoint(1, 1));
QVERIFY(!backgroundButton->isHovered());
QVERIFY(!drawerButton->isHovered());
+ QVERIFY(drawerItem->isHovered());
// hover the button in a drawer
QTest::mouseMove(window, QPoint(2, 2));
QVERIFY(!backgroundButton->isHovered());
QVERIFY(drawerButton->isHovered());
+ QVERIFY(drawerItem->isHovered());
QSignalSpy closedSpy(drawer, SIGNAL(closed()));
QVERIFY(closedSpy.isValid());
@@ -488,6 +495,8 @@ void tst_Drawer::hover()
// hover the background button after closing the drawer
QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2));
QVERIFY(backgroundButton->isHovered());
+ QVERIFY(!drawerButton->isHovered());
+ QVERIFY(!drawerItem->isHovered());
}
void tst_Drawer::wheel_data()