diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/controls/material/ScrollBar.qml | 1 | ||||
-rw-r--r-- | src/imports/controls/universal/ScrollBar.qml | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickrangeslider.cpp | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickspinbox.cpp | 57 |
4 files changed, 40 insertions, 26 deletions
diff --git a/src/imports/controls/material/ScrollBar.qml b/src/imports/controls/material/ScrollBar.qml index 1b014b87..8743a16e 100644 --- a/src/imports/controls/material/ScrollBar.qml +++ b/src/imports/controls/material/ScrollBar.qml @@ -81,6 +81,7 @@ T.ScrollBar { Transition { from: "active" SequentialAnimation { + PropertyAction{ targets: [contentItem, background]; property: "opacity"; value: 1.0 } PauseAnimation { duration: 2450 } NumberAnimation { targets: [contentItem, background]; property: "opacity"; to: 0.0 } } diff --git a/src/imports/controls/universal/ScrollBar.qml b/src/imports/controls/universal/ScrollBar.qml index c6ca874e..894e09e7 100644 --- a/src/imports/controls/universal/ScrollBar.qml +++ b/src/imports/controls/universal/ScrollBar.qml @@ -83,6 +83,7 @@ T.ScrollBar { Transition { from: "active" SequentialAnimation { + PropertyAction{ targets: [contentItem, background]; property: "opacity"; value: 1.0 } PauseAnimation { duration: 3000 } NumberAnimation { targets: [contentItem, background]; property: "opacity"; to: 0.0 } } diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index c1cf13db..3c9065db 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -68,6 +68,13 @@ QT_BEGIN_NAMESPACE } \endcode + In order to perform an action when the value for a particular handle changes, + use the following syntax: + + \code + first.onValueChanged: console.log("first.value changed to " + first.value) + \endcode + The \l {first.position} and \l {second.position} properties are expressed as fractions of the control's size, in the range \c {0.0 - 1.0}. The \l {first.visualPosition} and \l {second.visualPosition} properties are diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index f7458011..69b315b2 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -124,8 +124,10 @@ public: int boundValue(int value, bool wrap) const; void updateValue(); - bool setValue(int value, bool wrap); - bool stepBy(int steps); + bool setValue(int value, bool wrap, bool modified); + bool stepBy(int steps, bool modified); + void increase(bool modified); + void decrease(bool modified); int effectiveStepSize() const; @@ -187,16 +189,13 @@ void QQuickSpinBoxPrivate::updateValue() QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(engine); QJSValue loc(v4, QQmlLocale::wrap(v4, locale)); QJSValue val = q->valueFromText().call(QJSValueList() << text.toString() << loc); - const int oldValue = value; - setValue(val.toInt(), /* allowWrap = */ false); - if (oldValue != value) - emit q->valueModified(); + setValue(val.toInt(), /* modified = */ true, /* allowWrap = */ false); } } } } -bool QQuickSpinBoxPrivate::setValue(int newValue, bool allowWrap) +bool QQuickSpinBoxPrivate::setValue(int newValue, bool allowWrap, bool modified) { Q_Q(QQuickSpinBox); if (q->isComponentComplete()) @@ -211,12 +210,24 @@ bool QQuickSpinBoxPrivate::setValue(int newValue, bool allowWrap) updateDownEnabled(); emit q->valueChanged(); + if (modified) + emit q->valueModified(); return true; } -bool QQuickSpinBoxPrivate::stepBy(int steps) +bool QQuickSpinBoxPrivate::stepBy(int steps, bool modified) +{ + return setValue(value + steps, wrap, modified); +} + +void QQuickSpinBoxPrivate::increase(bool modified) +{ + setValue(value + effectiveStepSize(), wrap, modified); +} + +void QQuickSpinBoxPrivate::decrease(bool modified) { - return setValue(value + steps, wrap); + setValue(value - effectiveStepSize(), wrap, modified); } int QQuickSpinBoxPrivate::effectiveStepSize() const @@ -392,7 +403,7 @@ void QQuickSpinBox::setFrom(int from) d->from = from; emit fromChanged(); if (isComponentComplete()) { - if (!d->setValue(d->value, /* allowWrap = */ false)) { + if (!d->setValue(d->value, /* allowWrap = */ false, /* modified = */ false)) { d->updateUpEnabled(); d->updateDownEnabled(); } @@ -421,7 +432,7 @@ void QQuickSpinBox::setTo(int to) d->to = to; emit toChanged(); if (isComponentComplete()) { - if (!d->setValue(d->value, /* allowWrap = */false)) { + if (!d->setValue(d->value, /* allowWrap = */false, /* modified = */ false)) { d->updateUpEnabled(); d->updateDownEnabled(); } @@ -442,7 +453,7 @@ int QQuickSpinBox::value() const void QQuickSpinBox::setValue(int value) { Q_D(QQuickSpinBox); - d->setValue(value, /* allowWrap = */ false); + d->setValue(value, /* allowWrap = */ false, /* modified = */ false); } /*! @@ -751,7 +762,7 @@ void QQuickSpinBox::setWrap(bool wrap) void QQuickSpinBox::increase() { Q_D(QQuickSpinBox); - d->stepBy(d->effectiveStepSize()); + d->increase(false); } /*! @@ -764,7 +775,7 @@ void QQuickSpinBox::increase() void QQuickSpinBox::decrease() { Q_D(QQuickSpinBox); - d->stepBy(-d->effectiveStepSize()); + d->decrease(false); } void QQuickSpinBox::focusInEvent(QFocusEvent *event) @@ -804,11 +815,10 @@ void QQuickSpinBox::keyPressEvent(QKeyEvent *event) Q_D(QQuickSpinBox); QQuickControl::keyPressEvent(event); - const int oldValue = d->value; switch (event->key()) { case Qt::Key_Up: if (d->upEnabled()) { - increase(); + d->increase(true); d->up->setPressed(true); event->accept(); } @@ -816,7 +826,7 @@ void QQuickSpinBox::keyPressEvent(QKeyEvent *event) case Qt::Key_Down: if (d->downEnabled()) { - decrease(); + d->decrease(true); d->down->setPressed(true); event->accept(); } @@ -825,8 +835,6 @@ void QQuickSpinBox::keyPressEvent(QKeyEvent *event) default: break; } - if (d->value != oldValue) - emit valueModified(); setAccessibleProperty("pressed", d->up->isPressed() || d->down->isPressed()); } @@ -852,9 +860,9 @@ void QQuickSpinBox::timerEvent(QTimerEvent *event) d->startPressRepeat(); } else if (event->timerId() == d->repeatTimer) { if (d->up->isPressed()) - increase(); + d->increase(true); else if (d->down->isPressed()) - decrease(); + d->decrease(true); } } @@ -864,13 +872,10 @@ void QQuickSpinBox::wheelEvent(QWheelEvent *event) Q_D(QQuickSpinBox); QQuickControl::wheelEvent(event); if (d->wheelEnabled) { - const int oldValue = d->value; const QPointF angle = event->angleDelta(); const qreal delta = (qFuzzyIsNull(angle.y()) ? angle.x() : angle.y()) / QWheelEvent::DefaultDeltasPerStep; - d->stepBy(qRound(d->effectiveStepSize() * delta)); - if (d->value != oldValue) - emit valueModified(); - event->setAccepted(d->value != oldValue); + if (!d->stepBy(qRound(d->effectiveStepSize() * delta), true)) + event->ignore(); } } #endif |