diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-12-01 13:59:53 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-12-01 13:59:53 +0100 |
commit | 4ba00f0054ffd183377fd420b35ef7a388c0bcfe (patch) | |
tree | dde076314b40ce0dd540e5363ff6d9fca98016f4 /src/quicktemplates2 | |
parent | 948932c9c6ae535647e69962aad2add516802b9c (diff) | |
parent | d8c5dea96fb8861089e2166ae574a85d2b69c09e (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
src/imports/controls/SpinBox.qml
src/imports/controls/material/SpinBox.qml
src/imports/controls/universal/SpinBox.qml
tests/auto/controls/data/tst_swipedelegate.qml
Change-Id: Ie1d1f487890f0a9f80a00df5e813e1d2e8303fe5
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/qquickdial.cpp | 14 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdial_p.h | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickoverlay.cpp | 17 | ||||
-rw-r--r-- | src/quicktemplates2/qquickoverlay_p_p.h | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickswipedelegate.cpp | 15 |
5 files changed, 44 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 2932f4ce..7bfc0487 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -657,6 +657,20 @@ void QQuickDial::mouseUngrabEvent() setPressed(false); } +void QQuickDial::wheelEvent(QWheelEvent *event) +{ + Q_D(QQuickDial); + QQuickControl::wheelEvent(event); + if (d->wheelEnabled) { + const qreal oldValue = d->value; + const QPointF angle = event->angleDelta(); + const qreal delta = (qFuzzyIsNull(angle.y()) ? angle.x() : angle.y()) / QWheelEvent::DefaultDeltasPerStep; + const qreal step = qFuzzyIsNull(d->stepSize) ? 0.1 : d->stepSize; + setValue(oldValue + step * delta); + event->setAccepted(!qFuzzyCompare(d->value, oldValue)); + } +} + void QQuickDial::mirrorChange() { QQuickControl::mirrorChange(); diff --git a/src/quicktemplates2/qquickdial_p.h b/src/quicktemplates2/qquickdial_p.h index cd45ad0e..cfaf1f32 100644 --- a/src/quicktemplates2/qquickdial_p.h +++ b/src/quicktemplates2/qquickdial_p.h @@ -138,6 +138,8 @@ protected: void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseUngrabEvent() override; + void wheelEvent(QWheelEvent *event) override; + void mirrorChange() override; void componentComplete() override; diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index 55fecb15..27b66aee 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -194,6 +194,13 @@ void QQuickOverlayPrivate::removePopup(QQuickPopup *popup) q->setVisible(!allDrawers.isEmpty() || !q->childItems().isEmpty()); } +void QQuickOverlayPrivate::setMouseGrabberPopup(QQuickPopup *popup) +{ + if (popup && !popup->isVisible()) + popup = nullptr; + mouseGrabberPopup = popup; +} + QQuickOverlay::QQuickOverlay(QQuickItem *parent) : QQuickItem(*(new QQuickOverlayPrivate), parent) { @@ -327,7 +334,7 @@ void QQuickOverlay::mousePressEvent(QMouseEvent *event) for (QQuickDrawer *drawer : drawers) { QQuickDrawerPrivate *p = QQuickDrawerPrivate::get(drawer); if (p->startDrag(window(), event)) { - d->mouseGrabberPopup = drawer; + d->setMouseGrabberPopup(drawer); return; } } @@ -337,7 +344,7 @@ void QQuickOverlay::mousePressEvent(QMouseEvent *event) const auto popups = d->stackingOrderPopups(); for (QQuickPopup *popup : popups) { if (popup->overlayEvent(this, event)) { - d->mouseGrabberPopup = popup; + d->setMouseGrabberPopup(popup); return; } } @@ -360,7 +367,7 @@ void QQuickOverlay::mouseReleaseEvent(QMouseEvent *event) if (d->mouseGrabberPopup) { d->mouseGrabberPopup->overlayEvent(this, event); - d->mouseGrabberPopup = nullptr; + d->setMouseGrabberPopup(nullptr); } else { const auto popups = d->stackingOrderPopups(); for (QQuickPopup *popup : popups) { @@ -406,7 +413,7 @@ bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event) case QEvent::MouseButtonPress: emit pressed(); if (popup->overlayEvent(item, event)) { - d->mouseGrabberPopup = popup; + d->setMouseGrabberPopup(popup); return true; } break; @@ -414,7 +421,7 @@ bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event) return popup->overlayEvent(item, event); case QEvent::MouseButtonRelease: emit released(); - d->mouseGrabberPopup = nullptr; + d->setMouseGrabberPopup(nullptr); return popup->overlayEvent(item, event); default: break; diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h index ef142f1b..b10bfe83 100644 --- a/src/quicktemplates2/qquickoverlay_p_p.h +++ b/src/quicktemplates2/qquickoverlay_p_p.h @@ -72,6 +72,7 @@ public: void addPopup(QQuickPopup *popup); void removePopup(QQuickPopup *popup); + void setMouseGrabberPopup(QQuickPopup *popup); void popupAboutToShow(); void popupAboutToHide(); diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp index e660cfa2..2f7e7382 100644 --- a/src/quicktemplates2/qquickswipedelegate.cpp +++ b/src/quicktemplates2/qquickswipedelegate.cpp @@ -775,6 +775,21 @@ bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *item, QMous const bool hadGrabbedMouse = q->keepMouseGrab(); q->setKeepMouseGrab(false); + // Animations for the background and contentItem delegates are typically + // only enabled when !control.down, so that the animations aren't running + // when the user is swiping. To ensure that the animations are enabled + // *before* the positions of these delegates change (via the swipe.setPosition() calls below), + // we must cancel the press. QQuickAbstractButton::mouseUngrabEvent() does this + // for us, but by then it's too late. + if (hadGrabbedMouse) { + // TODO: this is copied from QQuickAbstractButton::mouseUngrabEvent(). + // Eventually it should be moved into a private helper so that we don't have to duplicate it. + q->setPressed(false); + stopPressRepeat(); + stopPressAndHold(); + emit q->canceled(); + } + // The control can be exposed by either swiping past the halfway mark, or swiping fast enough. const qreal swipeVelocity = swipePrivate->velocityCalculator.velocity().x(); if (swipePrivate->position > 0.5 || |