diff options
| author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-05-22 11:22:43 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-26 12:38:20 +0200 |
| commit | 35c11e02e01d19e1184a97be7e7aba9b1b936b79 (patch) | |
| tree | 2da82574abaef801cf55cc26c87baa0e5d9fc15e /src | |
| parent | e6e7f37afd21a2f5224db367159801d20088d99d (diff) | |
Fix Slider increments on keypress
Instead of always adding/subtracting 1/10 of the range use the step size when
the arrow keys are pressed. In addition add accessible actions to inc/dec the value.
Task-number: QTBUG-39099
Change-Id: I4fdf2adc8912ab1fa8838be56af4e798eeb59781
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/controls/Private/qquickrangemodel.cpp | 18 | ||||
| -rw-r--r-- | src/controls/Private/qquickrangemodel_p.h | 2 | ||||
| -rw-r--r-- | src/controls/Slider.qml | 16 |
3 files changed, 32 insertions, 4 deletions
diff --git a/src/controls/Private/qquickrangemodel.cpp b/src/controls/Private/qquickrangemodel.cpp index ee1ade32c..356fe0804 100644 --- a/src/controls/Private/qquickrangemodel.cpp +++ b/src/controls/Private/qquickrangemodel.cpp @@ -521,4 +521,22 @@ void QQuickRangeModel::toMaximum() setValue(d->maximum); } +void QQuickRangeModel::increaseSingleStep() +{ + Q_D(const QQuickRangeModel); + if (qFuzzyIsNull(d->stepSize)) + setValue(value() + (d->maximum - d->minimum)/10.0); + else + setValue(value() + d->stepSize); +} + +void QQuickRangeModel::decreaseSingleStep() +{ + Q_D(const QQuickRangeModel); + if (qFuzzyIsNull(d->stepSize)) + setValue(value() - (d->maximum - d->minimum)/10.0); + else + setValue(value() - d->stepSize); +} + QT_END_NAMESPACE diff --git a/src/controls/Private/qquickrangemodel_p.h b/src/controls/Private/qquickrangemodel_p.h index a15843d70..6a05f22a1 100644 --- a/src/controls/Private/qquickrangemodel_p.h +++ b/src/controls/Private/qquickrangemodel_p.h @@ -97,6 +97,8 @@ public Q_SLOTS: void toMaximum(); void setValue(qreal value); void setPosition(qreal position); + void increaseSingleStep(); + void decreaseSingleStep(); Q_SIGNALS: void valueChanged(qreal value); diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index ffea986c4..2838ed7e6 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -177,13 +177,21 @@ Control { activeFocusOnTab: true Accessible.role: Accessible.Slider + /*! \internal */ + function accessibleIncreaseAction() { + range.increaseSingleStep() + } + /*! \internal */ + function accessibleDecreaseAction() { + range.decreaseSingleStep() + } style: Qt.createComponent(Settings.style + "/SliderStyle.qml", slider) - Keys.onRightPressed: if (__horizontal) value += (maximumValue - minimumValue)/10.0 - Keys.onLeftPressed: if (__horizontal) value -= (maximumValue - minimumValue)/10.0 - Keys.onUpPressed: if (!__horizontal) value += (maximumValue - minimumValue)/10.0 - Keys.onDownPressed: if (!__horizontal) value -= (maximumValue - minimumValue)/10.0 + Keys.onRightPressed: if (__horizontal) range.increaseSingleStep() + Keys.onLeftPressed: if (__horizontal) range.decreaseSingleStep() + Keys.onUpPressed: if (!__horizontal) range.increaseSingleStep() + Keys.onDownPressed: if (!__horizontal) range.decreaseSingleStep() RangeModel { id: range |
