aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-02-08 12:51:09 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-02-08 17:14:58 +0000
commita2aff9c3c8800d265757d5171cb4f39c81328edd (patch)
tree15fd46aa0f70399674e646ddfdd855dc22e36d3a /src/templates
parentacdaa3982713d525b5c04ffdd32229bd6a27ff19 (diff)
RangeSlider: fix stepSize handling when snapping is enabled
Same as the recent fix for Slider. The step size needs to be normalized when added to or subtracted from the position. Change-Id: I490d105f88db361fb0e1888017e1717e9d79e4c8 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/templates')
-rw-r--r--src/templates/qquickrangeslider.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/templates/qquickrangeslider.cpp b/src/templates/qquickrangeslider.cpp
index 4bb320cf..5fae3ae5 100644
--- a/src/templates/qquickrangeslider.cpp
+++ b/src/templates/qquickrangeslider.cpp
@@ -323,10 +323,15 @@ static qreal valueAt(const QQuickRangeSlider *slider, qreal position)
static qreal snapPosition(const QQuickRangeSlider *slider, qreal position)
{
- const qreal stepSize = slider->stepSize();
- if (qFuzzyIsNull(stepSize))
+ const qreal range = slider->from() + (slider->to() - slider->from());
+ if (qFuzzyIsNull(range))
return position;
- return qRound(position / stepSize) * stepSize;
+
+ const qreal effectiveStep = slider->stepSize() / range;
+ if (qFuzzyIsNull(effectiveStep))
+ return position;
+
+ return qRound(position / effectiveStep) * effectiveStep;
}
static qreal positionAt(const QQuickRangeSlider *slider, QQuickItem *handle, const QPoint &point)