diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-05 15:57:47 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-10-06 08:40:09 +0000 |
commit | d03c8de38f5838c237b8c2fb50739d770c5fc14e (patch) | |
tree | bbeae02272484eb5b2a3710e96032a3f74a8de22 /src/quicktemplates2/qquickdial.cpp | |
parent | 405ef2c0524e6b9b0236bc5d7c0e6e5ed5c82fe8 (diff) |
Add QQuickDial::live
[ChangeLog][Controls][Dial] Added a live-property that determines
whether the dial provides live updates for the value-property while
the handle is dragged.
Change-Id: I8da1190df1e9093f81271a8e11f2cea55759573f
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickdial.cpp')
-rw-r--r-- | src/quicktemplates2/qquickdial.cpp | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 48d02faa..eb60c93c 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -95,6 +95,7 @@ public: pressed(false), snapMode(QQuickDial::NoSnap), wrap(false), + live(false), handle(nullptr) { } @@ -116,6 +117,7 @@ public: QPoint pressPoint; QQuickDial::SnapMode snapMode; bool wrap; + bool live; QQuickItem *handle; }; @@ -246,11 +248,12 @@ void QQuickDial::setTo(qreal to) This property holds the value in the range \c from - \c to. The default value is \c 0.0. - Unlike the \l position property, the \c value is not updated while the - handle is dragged. The value is updated after the value has been chosen - and the dial has been released. + Unlike the \l position property, the \c value is not updated by default + while the handle is dragged. The value is updated after the value has + been chosen and the dial has been released. The \l live property can be + used to make the dial provide live updates for the \c value property. - \sa position + \sa position, live */ qreal QQuickDial::value() const { @@ -445,6 +448,33 @@ void QQuickDial::setPressed(bool pressed) } /*! + \since QtQuick.Controls 2.2 + \qmlproperty bool QtQuick.Controls::Dial::live + + This property holds whether the dial provides live updates for the \l value + property while the handle is dragged. + + The default value is \c false. + + \sa value +*/ +bool QQuickDial::live() const +{ + Q_D(const QQuickDial); + return d->live; +} + +void QQuickDial::setLive(bool live) +{ + Q_D(QQuickDial); + if (d->live == live) + return; + + d->live = live; + emit liveChanged(); +} + +/*! \qmlmethod void QtQuick.Controls::Dial::increase() Increases the value by \l stepSize, or \c 0.1 if stepSize is not defined. @@ -571,8 +601,12 @@ void QQuickDial::mouseMoveEvent(QMouseEvent *event) if (d->snapMode == SnapAlways) pos = d->snapPosition(pos); - if (d->wrap || (!d->wrap && !d->isLargeChange(event->pos(), pos))) - d->setPosition(pos); + if (d->wrap || (!d->wrap && !d->isLargeChange(event->pos(), pos))) { + if (d->live) + setValue(d->valueAt(pos)); + else + d->setPosition(pos); + } } } |