aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-22 11:00:12 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-23 05:15:01 +0000
commit0e8cee6087f060667565029753ba48becf4b4d25 (patch)
tree5e715d15c92b1f3aa8d72f400d81c601d5f994f4
parent3ca980f2011384ee65bc8c49cbcacadf50872eb8 (diff)
Fix QQuickOverlay::childMouseEventFilter() to release the grabber popup
Change-Id: Id9d844d1fc75f4d254abaf1681747b7b521e881b Task-number: QTBUG-56131 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp1
-rw-r--r--tests/auto/drawer/data/grabber.qml63
-rw-r--r--tests/auto/drawer/tst_drawer.cpp38
3 files changed, 102 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index dbbc82bb..2855ba8b 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -403,6 +403,7 @@ bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event)
return popup->overlayEvent(item, event);
case QEvent::MouseButtonRelease:
emit released();
+ d->mouseGrabberPopup = nullptr;
return popup->overlayEvent(item, event);
default:
break;
diff --git a/tests/auto/drawer/data/grabber.qml b/tests/auto/drawer/data/grabber.qml
new file mode 100644
index 00000000..8b85f71a
--- /dev/null
+++ b/tests/auto/drawer/data/grabber.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Controls 2.0
+
+ApplicationWindow {
+ width: 400
+ height: 400
+
+ property alias drawer: drawer
+ property alias popup: popup
+
+ Drawer {
+ id: drawer
+ width: 200
+ height: parent.height
+ }
+
+ Popup {
+ id: popup
+ x: 200
+ width: 200
+ height: parent.height
+ }
+}
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index 383dedff..80385421 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -82,6 +82,8 @@ private slots:
void touch_data();
void touch();
+
+ void grabber();
};
void tst_Drawer::visible_data()
@@ -745,6 +747,42 @@ void tst_Drawer::touch()
QTRY_COMPARE(drawer->position(), 0.0);
}
+void tst_Drawer::grabber()
+{
+ QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml"));
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer *>();
+ QVERIFY(drawer);
+
+ QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened()));
+ QSignalSpy drawerClosedSpy(drawer, SIGNAL(closed()));
+ QVERIFY(drawerOpenedSpy.isValid());
+ QVERIFY(drawerClosedSpy.isValid());
+
+ drawer->open();
+ QVERIFY(drawerOpenedSpy.wait());
+
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(300, 100));
+ QVERIFY(drawerClosedSpy.wait());
+
+ QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
+ QVERIFY(popup);
+
+ QSignalSpy popupOpenedSpy(popup, SIGNAL(opened()));
+ QSignalSpy popupClosedSpy(popup, SIGNAL(closed()));
+ QVERIFY(popupOpenedSpy.isValid());
+ QVERIFY(popupClosedSpy.isValid());
+
+ popup->open();
+ QTRY_COMPARE(popupOpenedSpy.count(), 1);
+
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 300));
+ QTRY_COMPARE(popupClosedSpy.count(), 1);
+}
+
QTEST_MAIN(tst_Drawer)
#include "tst_drawer.moc"