aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-07-04 15:08:51 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-07-04 18:05:32 +0000
commitaf74ca8e0ccf0fc59d6e918c679fcc5139aab59d (patch)
tree10f939131d484203a91f6ae3116b357afa9f215b
parent26d528f6b5c61ab5003e97989693851bb6964be4 (diff)
PageIndicator: don't block touch when non-interactive
Unlike with mouse events there's setAcceptedMouseButtons(), currently there's no way to control whether a control receives touch events or not. As a temporary workaround until QQuickItem::setAcceptTouchEvents() has been added, we'll have to ignore touch events by hand. Task-number: QTBUG-61785 Change-Id: I8e3bdc3df1c3b28afaf8f80965569135e6a53120 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickpageindicator.cpp11
-rw-r--r--src/quicktemplates2/qquickpageindicator_p.h4
-rw-r--r--tests/auto/controls/data/tst_pageindicator.qml36
3 files changed, 51 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpageindicator.cpp b/src/quicktemplates2/qquickpageindicator.cpp
index 7387b019..8f9c8525 100644
--- a/src/quicktemplates2/qquickpageindicator.cpp
+++ b/src/quicktemplates2/qquickpageindicator.cpp
@@ -335,6 +335,17 @@ void QQuickPageIndicator::contentItemChange(QQuickItem *newItem, QQuickItem *old
QQuickItemPrivate::get(newItem)->addItemChangeListener(d, QQuickItemPrivate::Children);
}
+#if QT_CONFIG(quicktemplates2_multitouch)
+void QQuickPageIndicator::touchEvent(QTouchEvent *event)
+{
+ Q_D(QQuickPageIndicator);
+ if (d->interactive)
+ QQuickControl::touchEvent(event);
+ else
+ event->ignore(); // QTBUG-61785
+}
+#endif
+
#if QT_CONFIG(accessibility)
QAccessible::Role QQuickPageIndicator::accessibleRole() const
{
diff --git a/src/quicktemplates2/qquickpageindicator_p.h b/src/quicktemplates2/qquickpageindicator_p.h
index ea20a37a..01352016 100644
--- a/src/quicktemplates2/qquickpageindicator_p.h
+++ b/src/quicktemplates2/qquickpageindicator_p.h
@@ -87,6 +87,10 @@ Q_SIGNALS:
protected:
void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
+#if QT_CONFIG(quicktemplates2_multitouch)
+ void touchEvent(QTouchEvent *event) override;
+#endif
+
#if QT_CONFIG(accessibility)
QAccessible::Role accessibleRole() const override;
#endif
diff --git a/tests/auto/controls/data/tst_pageindicator.qml b/tests/auto/controls/data/tst_pageindicator.qml
index 0ceefa35..70813cb8 100644
--- a/tests/auto/controls/data/tst_pageindicator.qml
+++ b/tests/auto/controls/data/tst_pageindicator.qml
@@ -65,6 +65,11 @@ TestCase {
PageIndicator { }
}
+ Component {
+ id: mouseArea
+ MouseArea { }
+ }
+
function test_count() {
var control = createTemporaryObject(pageIndicator, testCase)
verify(control)
@@ -132,4 +137,35 @@ TestCase {
}
}
}
+
+ function test_mouseArea_data() {
+ return [
+ { tag: "interactive", interactive: true },
+ { tag: "non-interactive", interactive: false }
+ ]
+ }
+
+ // QTBUG-61785
+ function test_mouseArea(data) {
+ var ma = createTemporaryObject(mouseArea, testCase, {width: testCase.width, height: testCase.height})
+ verify(ma)
+
+ var control = pageIndicator.createObject(ma, {count: 5, interactive: data.interactive, width: testCase.width, height: testCase.height})
+ verify(control)
+
+ compare(control.interactive, data.interactive)
+
+ mousePress(control)
+ compare(ma.pressed, !data.interactive)
+
+ mouseRelease(control)
+ verify(!ma.pressed)
+
+ var touch = touchEvent(control)
+ touch.press(0, control).commit()
+ compare(ma.pressed, !data.interactive)
+
+ touch.release(0, control).commit()
+ verify(!ma.pressed)
+ }
}