aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-22 10:09:05 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-23 05:14:51 +0000
commit3ca980f2011384ee65bc8c49cbcacadf50872eb8 (patch)
tree0ddbd0a724e37b9630dcdad35482cc613597294a
parent7193318330bc518255fb7ed008c144578f49b4bd (diff)
Drawer: allow interaction outside modal background dimming
If a drawer is positioned below a toolbar, for instance, it must be possible to interact with the buttons in the toolbar while the drawer is open (without the drawer closing due to the interaction). Change-Id: I5e07f66ad997ba6cf991a26fc6849ec51c9c0a22 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp7
-rw-r--r--tests/auto/drawer/data/header.qml8
-rw-r--r--tests/auto/drawer/tst_drawer.cpp9
3 files changed, 21 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index 80cd95c9..8319cf2c 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -369,8 +369,11 @@ bool QQuickDrawerPrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *e
pressPoint = event->windowPos();
velocityCalculator.startMeasuring(pressPoint, event->timestamp());
- // don't block press events a) outside a non-modal drawer, or b) to drawer children
- event->setAccepted(modal && !popupItem->isAncestorOf(item));
+ // don't block press events
+ // a) outside a non-modal drawer,
+ // b) to drawer children, or
+ // c) outside a modal drawer's background dimming
+ event->setAccepted(modal && !popupItem->isAncestorOf(item) && (!dimmer || dimmer->contains(dimmer->mapFromScene(pressPoint))));
return event->isAccepted();
}
diff --git a/tests/auto/drawer/data/header.qml b/tests/auto/drawer/data/header.qml
index 9a352ffc..c74cc0c0 100644
--- a/tests/auto/drawer/data/header.qml
+++ b/tests/auto/drawer/data/header.qml
@@ -46,8 +46,14 @@ ApplicationWindow {
height: 400
property alias drawer: drawer
+ property alias button: button
- header: ToolBar { }
+ header: ToolBar {
+ ToolButton {
+ id: button
+ text: "="
+ }
+ }
Drawer {
id: drawer
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index 19a66326..383dedff 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -402,6 +402,9 @@ void tst_Drawer::header()
QVERIFY(drawer);
QQuickItem *popupItem = drawer->popupItem();
+ QQuickButton *button = window->property("button").value<QQuickButton*>();
+ QVERIFY(button);
+
drawer->open();
QVERIFY(drawer->isVisible());
@@ -413,6 +416,12 @@ void tst_Drawer::header()
QCOMPARE(drawer->parentItem(), content);
QCOMPARE(drawer->height(), content->height());
QCOMPARE(popupItem->height(), content->height());
+
+ // must be possible to interact with the header when the drawer is below the header
+ QSignalSpy clickSpy(button, SIGNAL(clicked()));
+ QVERIFY(clickSpy.isValid());
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + button->width() / 2, button->y() + button->height() / 2));
+ QCOMPARE(clickSpy.count(), 1);
}
void tst_Drawer::hover_data()