diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-01-19 14:31:54 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-01-20 09:05:06 +0000 |
commit | fdd41317118cd14fdab472a60ac67516d9d4d937 (patch) | |
tree | e271bd55ae5a0e6bf700ffc32f7db53b6072a671 /src/quicktemplates2/qquickscrollbar.cpp | |
parent | 945a407d6f6ca25098efcf3bdf138fb622cd5110 (diff) |
Add ScrollBar::interactive
[ChangeLog][Controls][ScrollBar] Added an interactive-property.
A non-interactive ScrollBar is visually and behaviorally similar
to ScrollIndicator. This property is useful for switching between
typical mouse- and touch-orientated UIs with interactive and non-
interactive scroll bars, respectively.
Change-Id: Ie98bfa0b5bba94a9751baf3c65f17b850b58fd1f
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickscrollbar.cpp')
-rw-r--r-- | src/quicktemplates2/qquickscrollbar.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index 66df3dc9..f7a5c246 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -164,6 +164,7 @@ public: active(false), pressed(false), moving(false), + interactive(true), orientation(Qt::Vertical), snapMode(QQuickScrollBar::NoSnap) { @@ -191,6 +192,7 @@ public: bool active; bool pressed; bool moving; + bool interactive; Qt::Orientation orientation; QQuickScrollBar::SnapMode snapMode; }; @@ -216,7 +218,7 @@ qreal QQuickScrollBarPrivate::positionAt(const QPointF &point) const void QQuickScrollBarPrivate::updateActive() { Q_Q(QQuickScrollBar); - q->setActive(moving || pressed || hovered); + q->setActive(moving || (interactive && (pressed || hovered))); } void QQuickScrollBarPrivate::resizeContent() @@ -489,6 +491,35 @@ void QQuickScrollBar::setSnapMode(SnapMode mode) } /*! + \since QtQuick.Controls 2.2 + \qmlproperty bool QtQuick.Controls::ScrollBar::interactive + + This property holds whether the scroll bar is interactive. The default value is \c true. + + A non-interactive scroll bar is visually and behaviorally similar to \l ScrollIndicator. + This property is useful for switching between typical mouse- and touch-orientated UIs + with interactive and non-interactive scroll bars, respectively. +*/ +bool QQuickScrollBar::isInteractive() const +{ + Q_D(const QQuickScrollBar); + return d->interactive; +} + +void QQuickScrollBar::setInteractive(bool interactive) +{ + Q_D(QQuickScrollBar); + if (d->interactive == interactive) + return; + + d->interactive = interactive; + setAcceptedMouseButtons(interactive ? Qt::LeftButton : Qt::NoButton); + if (!interactive) + ungrabMouse(); + emit interactiveChanged(); +} + +/*! \qmlmethod void QtQuick.Controls::ScrollBar::increase() Increases the position by \l stepSize or \c 0.1 if stepSize is \c 0.0. |