diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-01-25 10:22:47 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-01-26 14:12:44 +0000 |
commit | 855e23ebd6691b03420b7f1621ea4185447cfd54 (patch) | |
tree | 5e7f8c314a5d8425918f22783119aaa36b701d3c /src/quicktemplates2/qquickscrollbar.cpp | |
parent | f2602121228e910b9e400dadd2b8ee951052c3ba (diff) |
Keep track whether ScrollBar::interactive is explicitly set
The upcoming ScrollView toggles between interactive and non-interactive
scroll bars depending on whether it is interacted via touch or a mouse
device. This allows ScrollView to check whether the user or style
explicitly requested a specific mode and respect it.
Change-Id: I69d21652b3a91cb9db0f76ba52adc35ccd612ab1
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickscrollbar.cpp')
-rw-r--r-- | src/quicktemplates2/qquickscrollbar.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index ac786649..f0dd640b 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -163,6 +163,7 @@ QQuickScrollBarPrivate::QQuickScrollBarPrivate() pressed(false), moving(false), interactive(true), + explicitInteractive(false), orientation(Qt::Vertical), snapMode(QQuickScrollBar::NoSnap), policy(QQuickScrollBar::AsNeeded) @@ -187,6 +188,19 @@ qreal QQuickScrollBarPrivate::positionAt(const QPointF &point) const return (point.y() - q->topPadding()) / q->availableHeight(); } +void QQuickScrollBarPrivate::setInteractive(bool enabled) +{ + Q_Q(QQuickScrollBar); + if (interactive == enabled) + return; + + interactive = enabled; + q->setAcceptedMouseButtons(interactive ? Qt::LeftButton : Qt::NoButton); + if (!interactive) + q->ungrabMouse(); + emit q->interactiveChanged(); +} + void QQuickScrollBarPrivate::updateActive() { Q_Q(QQuickScrollBar); @@ -480,14 +494,15 @@ bool QQuickScrollBar::isInteractive() const void QQuickScrollBar::setInteractive(bool interactive) { Q_D(QQuickScrollBar); - if (d->interactive == interactive) - return; + d->explicitInteractive = true; + d->setInteractive(interactive); +} - d->interactive = interactive; - setAcceptedMouseButtons(interactive ? Qt::LeftButton : Qt::NoButton); - if (!interactive) - ungrabMouse(); - emit interactiveChanged(); +void QQuickScrollBar::resetInteractive() +{ + Q_D(QQuickScrollBar); + d->explicitInteractive = false; + d->setInteractive(true); } /*! |