diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-04-27 21:51:56 +0300 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-27 21:52:01 +0300 |
commit | ea470e8d612e5aa8c12eb3393baf057b8e8149e4 (patch) | |
tree | b5b77618de709c2cd818970b42f138d8e4b7c390 /src/quicktemplates2/qquickrangeslider.cpp | |
parent | 806b1f7c4ed218d4df67428277f06bdbb1c71e0e (diff) | |
parent | f9552a96a7c6f8ea58d8ea90cf3027cc0636bf64 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I47fbec425594386f529623f2dcbddd7ec7a09ee7
Diffstat (limited to 'src/quicktemplates2/qquickrangeslider.cpp')
-rw-r--r-- | src/quicktemplates2/qquickrangeslider.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 1468d358..f1e8a01e 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -435,16 +435,15 @@ void QQuickRangeSliderPrivate::handlePress(const QPointF &point) otherNode = first; } else { // find the nearest - const qreal firstDistance = QLineF(firstHandle->boundingRect().center(), - q->mapToItem(firstHandle, point)).length(); - const qreal secondDistance = QLineF(secondHandle->boundingRect().center(), - q->mapToItem(secondHandle, point)).length(); + const qreal firstPos = positionAt(q, firstHandle, point); + const qreal secondPos = positionAt(q, secondHandle, point); + const qreal firstDistance = qAbs(firstPos - first->position()); + const qreal secondDistance = qAbs(secondPos - second->position()); if (qFuzzyCompare(firstDistance, secondDistance)) { // same distance => choose the one that can be moved towards the press position const bool inverted = from > to; - const qreal pos = positionAt(q, firstHandle, point); - if ((!inverted && pos < first->position()) || (inverted && pos > first->position())) { + if ((!inverted && firstPos < first->position()) || (inverted && firstPos > first->position())) { hitNode = first; otherNode = second; } else { @@ -462,11 +461,14 @@ void QQuickRangeSliderPrivate::handlePress(const QPointF &point) if (hitNode) { hitNode->setPressed(true); - hitNode->handle()->setZ(1); + if (QQuickItem *handle = hitNode->handle()) + handle->setZ(1); QQuickRangeSliderNodePrivate::get(hitNode)->touchId = touchId; } - if (otherNode) - otherNode->handle()->setZ(0); + if (otherNode) { + if (QQuickItem *handle = otherNode->handle()) + handle->setZ(0); + } } void QQuickRangeSliderPrivate::handleMove(const QPointF &point) |