aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/platform/widgets/qwidgetplatform_p.h6
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp4
-rw-r--r--src/quicktemplates2/qquickpage.cpp8
-rw-r--r--src/quicktemplates2/qquickpane.cpp8
-rw-r--r--src/quicktemplates2/qquickpopup.cpp6
-rw-r--r--src/quicktemplates2/qquickpopupitem.cpp2
-rw-r--r--tests/auto/drawer/data/multiTouch.qml82
-rw-r--r--tests/auto/drawer/tst_drawer.cpp115
8 files changed, 215 insertions, 16 deletions
diff --git a/src/imports/platform/widgets/qwidgetplatform_p.h b/src/imports/platform/widgets/qwidgetplatform_p.h
index 5a983a33..c203406c 100644
--- a/src/imports/platform/widgets/qwidgetplatform_p.h
+++ b/src/imports/platform/widgets/qwidgetplatform_p.h
@@ -121,6 +121,7 @@ namespace QWidgetPlatform
#if defined(QT_WIDGETS_LIB) && QT_CONFIG(menu)
return createWidget<QWidgetPlatformMenu>("Menu", parent);
#else
+ Q_UNUSED(parent);
return nullptr;
#endif
}
@@ -128,6 +129,7 @@ namespace QWidgetPlatform
#if defined(QT_WIDGETS_LIB) && QT_CONFIG(menu)
return createWidget<QWidgetPlatformMenuItem>("MenuItem", parent);
#else
+ Q_UNUSED(parent);
return nullptr;
#endif
}
@@ -135,11 +137,15 @@ namespace QWidgetPlatform
#ifndef QT_NO_SYSTEMTRAYICON
return createWidget<QWidgetPlatformSystemTrayIcon>("SystemTrayIcon", parent);
#else
+ Q_UNUSED(parent);
return nullptr;
#endif
}
static inline QPlatformDialogHelper *createDialog(QPlatformTheme::DialogType type, QObject *parent = nullptr)
{
+#if !defined(QT_WIDGETS_LIB) || !(QT_CONFIG(colordialog) || QT_CONFIG(filedialog) || QT_CONFIG(fontdialog) || QT_CONFIG(messagebox))
+ Q_UNUSED(parent);
+#endif
switch (type) {
#if defined(QT_WIDGETS_LIB) && QT_CONFIG(colordialog)
case QPlatformTheme::ColorDialog: return createWidget<QWidgetPlatformColorDialog>("ColorDialog", parent);
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index 007ce4e6..96d48f08 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -357,10 +357,10 @@ bool QQuickDrawerPrivate::grabMouse(QQuickItem *item, QMouseEvent *event)
bool QQuickDrawerPrivate::grabTouch(QQuickItem *item, QTouchEvent *event)
{
Q_Q(QQuickDrawer);
- handleTouchEvent(item, event);
+ bool handled = handleTouchEvent(item, event);
if (!window || !interactive || popupItem->keepTouchGrab() || !event->touchPointStates().testFlag(Qt::TouchPointMoved))
- return false;
+ return handled;
bool overThreshold = false;
for (const QTouchEvent::TouchPoint &point : event->touchPoints()) {
diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp
index 40d47cda..ecc5a9c9 100644
--- a/src/quicktemplates2/qquickpage.cpp
+++ b/src/quicktemplates2/qquickpage.cpp
@@ -107,7 +107,7 @@ QQuickItem *QQuickPagePrivate::getContentItem()
{
Q_Q(QQuickPage);
if (!contentItem)
- contentItem = new QQuickItem(q);
+ return new QQuickItem(q);
return contentItem;
}
@@ -298,8 +298,7 @@ void QQuickPage::setContentHeight(qreal height)
*/
QQmlListProperty<QObject> QQuickPage::contentData()
{
- Q_D(QQuickPage);
- return QQmlListProperty<QObject>(d->getContentItem(), nullptr,
+ return QQmlListProperty<QObject>(contentItem(), nullptr,
QQuickItemPrivate::data_append,
QQuickItemPrivate::data_count,
QQuickItemPrivate::data_at,
@@ -321,8 +320,7 @@ QQmlListProperty<QObject> QQuickPage::contentData()
*/
QQmlListProperty<QQuickItem> QQuickPage::contentChildren()
{
- Q_D(QQuickPage);
- return QQmlListProperty<QQuickItem>(d->getContentItem(), nullptr,
+ return QQmlListProperty<QQuickItem>(contentItem(), nullptr,
QQuickItemPrivate::children_append,
QQuickItemPrivate::children_count,
QQuickItemPrivate::children_at,
diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp
index efa85e0c..b89131c4 100644
--- a/src/quicktemplates2/qquickpane.cpp
+++ b/src/quicktemplates2/qquickpane.cpp
@@ -114,7 +114,7 @@ QQuickItem *QQuickPanePrivate::getContentItem()
{
Q_Q(QQuickPane);
if (!contentItem)
- contentItem = new QQuickItem(q);
+ return new QQuickItem(q);
return contentItem;
}
@@ -206,8 +206,7 @@ void QQuickPane::setContentHeight(qreal height)
*/
QQmlListProperty<QObject> QQuickPane::contentData()
{
- Q_D(QQuickPane);
- return QQmlListProperty<QObject>(d->getContentItem(), nullptr,
+ return QQmlListProperty<QObject>(contentItem(), nullptr,
QQuickItemPrivate::data_append,
QQuickItemPrivate::data_count,
QQuickItemPrivate::data_at,
@@ -229,8 +228,7 @@ QQmlListProperty<QObject> QQuickPane::contentData()
*/
QQmlListProperty<QQuickItem> QQuickPane::contentChildren()
{
- Q_D(QQuickPane);
- return QQmlListProperty<QQuickItem>(d->getContentItem(), nullptr,
+ return QQmlListProperty<QQuickItem>(contentItem(), nullptr,
QQuickItemPrivate::children_append,
QQuickItemPrivate::children_count,
QQuickItemPrivate::children_at,
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 39bd56a1..4dba5893 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -265,6 +265,7 @@ void QQuickPopupPrivate::init()
q->setParentItem(qobject_cast<QQuickItem *>(parent));
QObject::connect(popupItem, &QQuickItem::enabledChanged, q, &QQuickPopup::enabledChanged);
QObject::connect(popupItem, &QQuickControl::paddingChanged, q, &QQuickPopup::paddingChanged);
+ QObject::connect(popupItem, &QQuickControl::contentItemChanged, q, &QQuickPopup::contentItemChanged);
positioner = new QQuickPopupPositioner(q);
}
@@ -387,8 +388,8 @@ bool QQuickPopupPrivate::handleTouchEvent(QQuickItem *item, QTouchEvent *event)
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
for (const QTouchEvent::TouchPoint &point : event->touchPoints()) {
- if (!acceptTouch(point) && !blockInput(item, point.pos()))
- continue;
+ if (!acceptTouch(point))
+ return blockInput(item, point.pos());
switch (point.state()) {
case Qt::TouchPointPressed:
@@ -2247,7 +2248,6 @@ void QQuickPopup::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
{
Q_UNUSED(newItem);
Q_UNUSED(oldItem);
- emit contentItemChanged();
}
void QQuickPopup::fontChange(const QFont &newFont, const QFont &oldFont)
diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp
index a8d35596..27528f2f 100644
--- a/src/quicktemplates2/qquickpopupitem.cpp
+++ b/src/quicktemplates2/qquickpopupitem.cpp
@@ -105,7 +105,7 @@ QQuickItem *QQuickPopupItemPrivate::getContentItem()
{
Q_Q(QQuickPopupItem);
if (!contentItem)
- contentItem = new QQuickItem(q);
+ return new QQuickItem(q);
return contentItem;
}
diff --git a/tests/auto/drawer/data/multiTouch.qml b/tests/auto/drawer/data/multiTouch.qml
new file mode 100644
index 00000000..0faf3c61
--- /dev/null
+++ b/tests/auto/drawer/data/multiTouch.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, 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 {
+ id: window
+ width: 400
+ height: 400
+
+ property alias drawer: drawer
+ property alias popup: popup
+ property alias button: button
+
+ Drawer {
+ id: drawer
+ width: window.width / 2
+ height: parent.height
+ dragMargin: parent.width
+ }
+
+ Popup {
+ id: popup
+ x: 10; y: 10
+ width: window.width - 10
+ height: window.height - 10
+
+ Button {
+ id: button
+ text: "Button"
+ anchors.fill: parent
+ }
+ }
+}
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index 9c30f8cf..d316e08f 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -86,6 +86,8 @@ private slots:
void touch_data();
void touch();
+ void multiTouch();
+
void grabber();
void interactive_data();
@@ -813,6 +815,119 @@ void tst_Drawer::touch()
QCOMPARE(drawer->position(), 0.0);
}
+void tst_Drawer::multiTouch()
+{
+ QQuickApplicationHelper helper(this, QStringLiteral("multiTouch.qml"));
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ QQuickOverlay *overlay = QQuickOverlay::overlay(window);
+ QVERIFY(overlay);
+
+ QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer *>();
+ QVERIFY(drawer);
+
+ QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
+ QVERIFY(popup);
+
+ QQuickButton *button = window->property("button").value<QQuickButton *>();
+ QVERIFY(button);
+
+ QSignalSpy overlayPressedSpy(overlay, SIGNAL(pressed()));
+ QSignalSpy overlayReleasedSpy(overlay, SIGNAL(released()));
+ QVERIFY(overlayPressedSpy.isValid());
+ QVERIFY(overlayReleasedSpy.isValid());
+
+ QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened()));
+ QVERIFY(drawerOpenedSpy.isValid());
+
+ QSignalSpy buttonPressedSpy(button, SIGNAL(pressed()));
+ QSignalSpy buttonReleasedSpy(button, SIGNAL(released()));
+ QVERIFY(buttonPressedSpy.isValid());
+ QVERIFY(buttonReleasedSpy.isValid());
+
+ popup->open();
+ QVERIFY(popup->isVisible());
+
+ drawer->open();
+ QVERIFY(drawer->isVisible());
+ QVERIFY(drawerOpenedSpy.wait());
+
+ // 1st press
+ QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100));
+ QVERIFY(popup->isVisible());
+ QVERIFY(drawer->isVisible());
+ QCOMPARE(buttonPressedSpy.count(), 0);
+ QCOMPARE(overlayPressedSpy.count(), 1);
+
+ // 2nd press (blocked & ignored)
+ QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200));
+ QVERIFY(popup->isVisible());
+ QVERIFY(drawer->isVisible());
+ QCOMPARE(buttonPressedSpy.count(), 0);
+ QCOMPARE(overlayPressedSpy.count(), 2);
+
+ // 2nd release (blocked & ignored)
+ QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 200));
+ QVERIFY(popup->isVisible());
+ QVERIFY(drawer->isVisible());
+ QCOMPARE(buttonPressedSpy.count(), 0);
+ QCOMPARE(buttonReleasedSpy.count(), 0);
+ QCOMPARE(overlayPressedSpy.count(), 2);
+ QCOMPARE(overlayReleasedSpy.count(), 1);
+
+ // 1st release
+ QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100));
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(!drawer->isVisible());
+ QCOMPARE(buttonPressedSpy.count(), 0);
+ QCOMPARE(buttonReleasedSpy.count(), 0);
+ QCOMPARE(overlayPressedSpy.count(), 2);
+ QCOMPARE(overlayReleasedSpy.count(), 2);
+
+ drawer->open();
+ QVERIFY(drawer->isVisible());
+ QVERIFY(drawerOpenedSpy.wait());
+
+ // 1st drag
+ QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100));
+ QCOMPARE(buttonPressedSpy.count(), 0);
+ QCOMPARE(overlayPressedSpy.count(), 3);
+ for (int x = 300; x >= 100; x -= 10) {
+ QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, 100));
+ QVERIFY(popup->isVisible());
+ QVERIFY(drawer->isVisible());
+ }
+ QCOMPARE(drawer->position(), 0.5);
+
+ // 2nd drag (blocked & ignored)
+ QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200));
+ QCOMPARE(buttonPressedSpy.count(), 0);
+ QCOMPARE(overlayPressedSpy.count(), 4);
+ for (int x = 300; x >= 0; x -= 10) {
+ QTest::touchEvent(window, touchDevice.data()).stationary(0).move(1, QPoint(x, 200));
+ QVERIFY(popup->isVisible());
+ QVERIFY(drawer->isVisible());
+ }
+ QCOMPARE(drawer->position(), 0.5);
+
+ // 2nd release (blocked & ignored)
+ QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 0));
+ QVERIFY(popup->isVisible());
+ QVERIFY(drawer->isVisible());
+ QCOMPARE(drawer->position(), 0.5);
+ QCOMPARE(buttonReleasedSpy.count(), 0);
+ QCOMPARE(overlayReleasedSpy.count(), 3);
+
+ // 1st release
+ QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100));
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(!drawer->isVisible());
+ QCOMPARE(buttonReleasedSpy.count(), 0);
+ QCOMPARE(overlayReleasedSpy.count(), 4);
+}
+
void tst_Drawer::grabber()
{
QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml"));