diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-07-11 12:06:15 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-07-11 12:57:13 +0200 |
commit | d2d0e08e584c780b4b70a37e7b39c6bbcc7bc63e (patch) | |
tree | 22582b82dd5bb370205aa66302fb238bf5edaa6e /src/quicktemplates2 | |
parent | c3431db7a3eb6b0c6e325e2d1e16eb6def9a4b4d (diff) | |
parent | 744164e6c92cb721d2a339cee8c465e1685723f9 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
.qmake.conf
tests/auto/controls/data/tst_scrollindicator.qml
Change-Id: I1f5581ae7814c0d4152e4c9b79a30a8af5a3a17b
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/qquickbusyindicator.cpp | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickbusyindicator_p.h | 4 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 14 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdrawer.cpp | 25 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdrawer_p_p.h | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickoverlay.cpp | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpageindicator.cpp | 84 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpageindicator_p.h | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 24 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollindicator.cpp | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollindicator_p.h | 4 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktumbler.cpp | 13 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktumbler_p_p.h | 1 |
13 files changed, 123 insertions, 76 deletions
diff --git a/src/quicktemplates2/qquickbusyindicator.cpp b/src/quicktemplates2/qquickbusyindicator.cpp index 883066d7..e4f20d83 100644 --- a/src/quicktemplates2/qquickbusyindicator.cpp +++ b/src/quicktemplates2/qquickbusyindicator.cpp @@ -115,6 +115,13 @@ void QQuickBusyIndicator::setRunning(bool running) emit runningChanged(); } +#if QT_CONFIG(quicktemplates2_multitouch) +void QQuickBusyIndicator::touchEvent(QTouchEvent *event) +{ + event->ignore(); // QTBUG-61785 +} +#endif + #if QT_CONFIG(accessibility) QAccessible::Role QQuickBusyIndicator::accessibleRole() const { diff --git a/src/quicktemplates2/qquickbusyindicator_p.h b/src/quicktemplates2/qquickbusyindicator_p.h index 3607cc1f..f140764b 100644 --- a/src/quicktemplates2/qquickbusyindicator_p.h +++ b/src/quicktemplates2/qquickbusyindicator_p.h @@ -69,6 +69,10 @@ Q_SIGNALS: void runningChanged(); protected: +#if QT_CONFIG(quicktemplates2_multitouch) + void touchEvent(QTouchEvent *event) override; +#endif + #if QT_CONFIG(accessibility) QAccessible::Role accessibleRole() const override; #endif diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index dca50244..4b85e444 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -1482,13 +1482,8 @@ void QQuickControl::touchEvent(QTouchEvent *event) Q_D(QQuickControl); switch (event->type()) { case QEvent::TouchBegin: - for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { - if (d->acceptTouch(point)) - d->handlePress(point.pos()); - } - break; - case QEvent::TouchUpdate: + case QEvent::TouchEnd: for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { if (!d->acceptTouch(point)) continue; @@ -1509,13 +1504,6 @@ void QQuickControl::touchEvent(QTouchEvent *event) } break; - case QEvent::TouchEnd: - for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { - if (d->acceptTouch(point)) - d->handleRelease(point.pos()); - } - break; - case QEvent::TouchCancel: d->handleUngrab(); break; diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index 8e77b966..007ce4e6 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -40,6 +40,7 @@ #include <QtGui/qstylehints.h> #include <QtGui/private/qguiapplication_p.h> +#include <QtQml/qqmlinfo.h> #include <QtQuick/private/qquickwindow_p.h> #include <QtQuick/private/qquickanimation_p.h> #include <QtQuick/private/qquicktransition_p.h> @@ -540,20 +541,32 @@ bool QQuickDrawerPrivate::prepareExitTransition() return QQuickPopupPrivate::prepareExitTransition(); } -void QQuickDrawerPrivate::setEdge(Qt::Edge e) +bool QQuickDrawerPrivate::setEdge(Qt::Edge e) { - edge = e; - if (edge == Qt::LeftEdge || edge == Qt::RightEdge) { + Q_Q(QQuickDrawer); + switch (e) { + case Qt::LeftEdge: + case Qt::RightEdge: allowVerticalMove = true; allowVerticalResize = true; allowHorizontalMove = false; allowHorizontalResize = false; - } else { + break; + case Qt::TopEdge: + case Qt::BottomEdge: allowVerticalMove = false; allowVerticalResize = false; allowHorizontalMove = true; allowHorizontalResize = true; + break; + default: + qmlWarning(q) << "invalid edge value - valid values are: " + << "Qt.TopEdge, Qt.LeftEdge, Qt.RightEdge, Qt.BottomEdge"; + return false; } + + edge = e; + return true; } QQuickDrawer::QQuickDrawer(QObject *parent) @@ -588,7 +601,9 @@ void QQuickDrawer::setEdge(Qt::Edge edge) if (d->edge == edge) return; - d->setEdge(edge); + if (!d->setEdge(edge)) + return; + if (isComponentComplete()) d->reposition(); emit edgeChanged(); diff --git a/src/quicktemplates2/qquickdrawer_p_p.h b/src/quicktemplates2/qquickdrawer_p_p.h index 72a83343..010f1d49 100644 --- a/src/quicktemplates2/qquickdrawer_p_p.h +++ b/src/quicktemplates2/qquickdrawer_p_p.h @@ -88,7 +88,7 @@ public: bool prepareEnterTransition() override; bool prepareExitTransition() override; - void setEdge(Qt::Edge edge); + bool setEdge(Qt::Edge edge); Qt::Edge edge; qreal offset; diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index 12158f06..ed3d3d45 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -150,6 +150,11 @@ bool QQuickOverlayPrivate::startDrag(QEvent *event, const QPointF &pos) return false; } +static bool isTouchEvent(QEvent *event) +{ + return event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd; +} + bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuickPopup *target) { if (target) { @@ -158,7 +163,7 @@ bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuick return true; } return false; - } else if (!mouseGrabberPopup) { + } else if (!mouseGrabberPopup || isTouchEvent(event)) { // allow non-modal popups to close themselves, // and non-dimming modal popups to block the event const auto popups = stackingOrderPopups(); diff --git a/src/quicktemplates2/qquickpageindicator.cpp b/src/quicktemplates2/qquickpageindicator.cpp index b4c9c14c..df720c91 100644 --- a/src/quicktemplates2/qquickpageindicator.cpp +++ b/src/quicktemplates2/qquickpageindicator.cpp @@ -98,11 +98,16 @@ public: { } - QQuickItem *itemAt(const QPoint &pos) const; - void updatePressed(bool pressed, const QPoint &pos = QPoint()); + void handlePress(const QPointF &point) override; + void handleMove(const QPointF &point) override; + void handleRelease(const QPointF &point) override; + void handleUngrab() override; + + QQuickItem *itemAt(const QPointF &pos) const; + void updatePressed(bool pressed, const QPointF &pos = QPointF()); void setContextProperty(QQuickItem *item, const QString &name, const QVariant &value); - void itemChildAdded(QQuickItem *, QQuickItem *child); + void itemChildAdded(QQuickItem *, QQuickItem *child) override; int count; int currentIndex; @@ -111,7 +116,39 @@ public: QQuickItem *pressedItem; }; -QQuickItem *QQuickPageIndicatorPrivate::itemAt(const QPoint &pos) const +void QQuickPageIndicatorPrivate::handlePress(const QPointF &point) +{ + QQuickControlPrivate::handlePress(point); + if (interactive) + updatePressed(true, point); +} + +void QQuickPageIndicatorPrivate::handleMove(const QPointF &point) +{ + QQuickControlPrivate::handleMove(point); + if (interactive) + updatePressed(true, point); +} + +void QQuickPageIndicatorPrivate::handleRelease(const QPointF &point) +{ + Q_Q(QQuickPageIndicator); + QQuickControlPrivate::handleRelease(point); + if (interactive) { + if (pressedItem && contentItem) + q->setCurrentIndex(contentItem->childItems().indexOf(pressedItem)); + updatePressed(false); + } +} + +void QQuickPageIndicatorPrivate::handleUngrab() +{ + QQuickControlPrivate::handleUngrab(); + if (interactive) + updatePressed(false); +} + +QQuickItem *QQuickPageIndicatorPrivate::itemAt(const QPointF &pos) const { Q_Q(const QQuickPageIndicator); if (!contentItem || !q->contains(pos)) @@ -144,7 +181,7 @@ QQuickItem *QQuickPageIndicatorPrivate::itemAt(const QPoint &pos) const return nearest; } -void QQuickPageIndicatorPrivate::updatePressed(bool pressed, const QPoint &pos) +void QQuickPageIndicatorPrivate::updatePressed(bool pressed, const QPointF &pos) { QQuickItem *prevItem = pressedItem; pressedItem = pressed ? itemAt(pos) : nullptr; @@ -298,41 +335,16 @@ void QQuickPageIndicator::contentItemChange(QQuickItem *newItem, QQuickItem *old QQuickItemPrivate::get(newItem)->addItemChangeListener(d, QQuickItemPrivate::Children); } -void QQuickPageIndicator::mousePressEvent(QMouseEvent *event) -{ - Q_D(QQuickPageIndicator); - if (d->interactive) { - d->updatePressed(true, event->pos()); - event->accept(); - } -} - -void QQuickPageIndicator::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QQuickPageIndicator); - if (d->interactive) { - d->updatePressed(true, event->pos()); - event->accept(); - } -} - -void QQuickPageIndicator::mouseReleaseEvent(QMouseEvent *event) -{ - Q_D(QQuickPageIndicator); - if (d->interactive) { - if (d->pressedItem) - setCurrentIndex(d->contentItem->childItems().indexOf(d->pressedItem)); - d->updatePressed(false); - event->accept(); - } -} - -void QQuickPageIndicator::mouseUngrabEvent() +#if QT_CONFIG(quicktemplates2_multitouch) +void QQuickPageIndicator::touchEvent(QTouchEvent *event) { Q_D(QQuickPageIndicator); if (d->interactive) - d->updatePressed(false); + 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 921fe7e8..01352016 100644 --- a/src/quicktemplates2/qquickpageindicator_p.h +++ b/src/quicktemplates2/qquickpageindicator_p.h @@ -87,10 +87,9 @@ Q_SIGNALS: protected: void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void mouseUngrabEvent() override; +#if QT_CONFIG(quicktemplates2_multitouch) + void touchEvent(QTouchEvent *event) override; +#endif #if QT_CONFIG(accessibility) QAccessible::Role accessibleRole() const override; diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 6927699c..81e50642 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -384,15 +384,10 @@ bool QQuickPopupPrivate::handleTouchEvent(QQuickItem *item, QTouchEvent *event) { switch (event->type()) { case QEvent::TouchBegin: - for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { - if (acceptTouch(point)) - return handlePress(item, item->mapToScene(point.pos()), event->timestamp()); - } - break; - case QEvent::TouchUpdate: + case QEvent::TouchEnd: for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { - if (!acceptTouch(point)) + if (!acceptTouch(point) && !blockInput(item, point.pos())) continue; switch (point.state()) { @@ -408,13 +403,6 @@ bool QQuickPopupPrivate::handleTouchEvent(QQuickItem *item, QTouchEvent *event) } break; - case QEvent::TouchEnd: - for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { - if (acceptTouch(point)) - return handleRelease(item, item->mapToScene(point.pos()), event->timestamp()); - } - break; - case QEvent::TouchCancel: handleUngrab(); break; @@ -493,7 +481,13 @@ void QQuickPopupPrivate::finalizeExitTransition() destroyOverlay(); if (hadActiveFocusBeforeExitTransition && window) { - if (!qobject_cast<QQuickPopupItem *>(window->activeFocusItem())) { + // restore focus to the next popup in chain, or to the window content if there are no other popups open + QQuickPopup *popup = nullptr; + if (QQuickOverlay *overlay = QQuickOverlay::overlay(window)) + popup = QQuickOverlayPrivate::get(overlay)->stackingOrderPopups().value(0); + if (popup && popup->hasFocus()) { + popup->forceActiveFocus(); + } else { QQuickApplicationWindow *applicationWindow = qobject_cast<QQuickApplicationWindow*>(window); if (applicationWindow) applicationWindow->contentItem()->setFocus(true); diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp index d14138af..ee1078e4 100644 --- a/src/quicktemplates2/qquickscrollindicator.cpp +++ b/src/quicktemplates2/qquickscrollindicator.cpp @@ -567,6 +567,13 @@ void QQuickScrollIndicatorAttached::setVertical(QQuickScrollIndicator *vertical) emit verticalChanged(); } +#if QT_CONFIG(quicktemplates2_multitouch) +void QQuickScrollIndicator::touchEvent(QTouchEvent *event) +{ + event->ignore(); // QTBUG-61785 +} +#endif + #if QT_CONFIG(accessibility) QAccessible::Role QQuickScrollIndicator::accessibleRole() const { diff --git a/src/quicktemplates2/qquickscrollindicator_p.h b/src/quicktemplates2/qquickscrollindicator_p.h index 6f08ef31..c1065a3f 100644 --- a/src/quicktemplates2/qquickscrollindicator_p.h +++ b/src/quicktemplates2/qquickscrollindicator_p.h @@ -94,6 +94,10 @@ Q_SIGNALS: void orientationChanged(); protected: +#if QT_CONFIG(quicktemplates2_multitouch) + void touchEvent(QTouchEvent *event) override; +#endif + #if QT_CONFIG(accessibility) QAccessible::Role accessibleRole() const override; #endif diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp index 5cdd140d..80ab71ea 100644 --- a/src/quicktemplates2/qquicktumbler.cpp +++ b/src/quicktemplates2/qquicktumbler.cpp @@ -97,7 +97,8 @@ QQuickTumblerPrivate::QQuickTumblerPrivate() currentIndex(-1), pendingCurrentIndex(-1), ignoreCurrentIndexChanges(false), - count(0) + count(0), + ignoreSignals(false) { } @@ -163,6 +164,9 @@ QQuickTumblerPrivate *QQuickTumblerPrivate::get(QQuickTumbler *tumbler) void QQuickTumblerPrivate::_q_updateItemHeights() { + if (ignoreSignals) + return; + // Can't use our own private padding members here, as the padding property might be set, // which doesn't affect them, only their getters. Q_Q(const QQuickTumbler); @@ -174,6 +178,9 @@ void QQuickTumblerPrivate::_q_updateItemHeights() void QQuickTumblerPrivate::_q_updateItemWidths() { + if (ignoreSignals) + return; + Q_Q(const QQuickTumbler); const qreal availableWidth = q->availableWidth(); const auto items = viewContentItemChildItems(); @@ -195,6 +202,8 @@ void QQuickTumblerPrivate::_q_onViewCurrentIndexChanged() void QQuickTumblerPrivate::_q_onViewCountChanged() { Q_Q(QQuickTumbler); + if (ignoreSignals) + return; setCount(view->property("count").toInt()); @@ -336,7 +345,9 @@ void QQuickTumbler::setCurrentIndex(int currentIndex) couldSet = true; } else { d->ignoreCurrentIndexChanges = true; + d->ignoreSignals = true; d->view->setProperty("currentIndex", currentIndex); + d->ignoreSignals = false; d->ignoreCurrentIndexChanges = false; couldSet = d->view->property("currentIndex").toInt() == currentIndex; diff --git a/src/quicktemplates2/qquicktumbler_p_p.h b/src/quicktemplates2/qquicktumbler_p_p.h index 301b8402..0dcae762 100644 --- a/src/quicktemplates2/qquicktumbler_p_p.h +++ b/src/quicktemplates2/qquicktumbler_p_p.h @@ -88,6 +88,7 @@ public: int pendingCurrentIndex; bool ignoreCurrentIndexChanges; int count; + bool ignoreSignals; void _q_updateItemHeights(); void _q_updateItemWidths(); |