9#include <QtCore/qscopedpointer.h>
10#include <QtQuick/private/qquickwindow_p.h>
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
65 Q_DECLARE_PUBLIC(QQuickRangeSliderNode)
75 void setPosition(qreal position,
bool ignoreOtherPosition =
false);
96 return this == get(slider->first());
101 Q_Q(QQuickRangeSliderNode);
103 const qreal min = isFirst() || ignoreOtherPosition ? 0.0 : qMax<qreal>(0.0, slider->first()->position());
104 const qreal max = !isFirst() || ignoreOtherPosition ? 1.0 : qMin<qreal>(1.0, slider->second()->position());
105 position = qBound(min, position, max);
106 if (!qFuzzyCompare(
this->position, position)) {
107 this->position = position;
108 emit q->positionChanged();
109 emit q->visualPositionChanged();
116 if (!qFuzzyCompare(slider->from(), slider->to()))
117 pos = (value - slider->from()) / (slider->to() - slider->from());
118 setPosition(pos, ignoreOtherPosition);
123 Q_Q(QQuickRangeSliderNode);
124 quickCancelDeferred(q, handleName());
129 Q_Q(QQuickRangeSliderNode);
130 if (handle.wasExecuted())
133 if (!handle || complete)
134 quickBeginDeferred(q, handleName(), handle);
136 quickCompleteDeferred(q, handleName(), handle);
141 return node->d_func();
144QQuickRangeSliderNode::QQuickRangeSliderNode(qreal value, QQuickRangeSlider *slider)
145 : QObject(*(
new QQuickRangeSliderNodePrivate(value, slider)), slider)
149QQuickRangeSliderNode::~QQuickRangeSliderNode()
153qreal QQuickRangeSliderNode::value()
const
155 Q_D(
const QQuickRangeSliderNode);
159void QQuickRangeSliderNode::setValue(qreal value)
161 Q_D(QQuickRangeSliderNode);
162 if (!d->slider->isComponentComplete()) {
163 d->pendingValue = value;
164 d->isPendingValue =
true;
169 const qreal smaller = qMin(d->slider->to(), d->slider->from());
170 const qreal larger = qMax(d->slider->to(), d->slider->from());
171 value = qBound(smaller, value, larger);
175 const bool invertedRange = d->slider->from() > d->slider->to();
178 if (value < d->slider->second()->value())
179 value = d->slider->second()->value();
181 if (value > d->slider->second()->value())
182 value = d->slider->second()->value();
186 if (value > d->slider->first()->value())
187 value = d->slider->first()->value();
189 if (value < d->slider->first()->value())
190 value = d->slider->first()->value();
194 if (!qFuzzyCompare(d->value, value)) {
201qreal QQuickRangeSliderNode::position()
const
203 Q_D(
const QQuickRangeSliderNode);
207qreal QQuickRangeSliderNode::visualPosition()
const
209 Q_D(
const QQuickRangeSliderNode);
210 if (d->slider->orientation() == Qt::Vertical || d->slider->isMirrored())
211 return 1.0 - d->position;
215QQuickItem *QQuickRangeSliderNode::handle()
const
217 QQuickRangeSliderNodePrivate *d =
const_cast<QQuickRangeSliderNodePrivate *>(d_func());
223void QQuickRangeSliderNode::setHandle(QQuickItem *handle)
225 Q_D(QQuickRangeSliderNode);
226 if (d->handle == handle)
229 QQuickControlPrivate::warnIfCustomizationNotSupported(d->slider, handle, QStringLiteral(
"handle"));
231 if (!d->handle.isExecuting())
234 const qreal oldImplicitHandleWidth = implicitHandleWidth();
235 const qreal oldImplicitHandleHeight = implicitHandleHeight();
237 QQuickControlPrivate::get(d->slider)->removeImplicitSizeListener(d->handle);
238 QQuickControlPrivate::hideOldItem(d->handle);
242 if (!handle->parentItem())
243 handle->setParentItem(d->slider);
245 QQuickItem *firstHandle = QQuickRangeSliderNodePrivate::get(d->slider->first())->handle;
246 QQuickItem *secondHandle = QQuickRangeSliderNodePrivate::get(d->slider->second())->handle;
247 if (firstHandle && secondHandle) {
251 const QList<QQuickItem *> childItems = d->slider->childItems();
252 const int firstIndex = childItems.indexOf(firstHandle);
253 const int secondIndex = childItems.indexOf(secondHandle);
254 if (firstIndex != -1 && secondIndex != -1 && firstIndex > secondIndex) {
255 firstHandle->stackBefore(secondHandle);
259 secondHandle->setZ(secondHandle->z() + 1);
263 handle->setActiveFocusOnTab(
true);
264 QQuickControlPrivate::get(d->slider)->addImplicitSizeListener(handle);
267 if (!qFuzzyCompare(oldImplicitHandleWidth, implicitHandleWidth()))
268 emit implicitHandleWidthChanged();
269 if (!qFuzzyCompare(oldImplicitHandleHeight, implicitHandleHeight()))
270 emit implicitHandleHeightChanged();
271 if (!d->handle.isExecuting())
272 emit handleChanged();
275bool QQuickRangeSliderNode::isPressed()
const
277 Q_D(
const QQuickRangeSliderNode);
281void QQuickRangeSliderNode::setPressed(
bool pressed)
283 Q_D(QQuickRangeSliderNode);
284 if (d->pressed == pressed)
287 d->pressed = pressed;
288 d->slider->setAccessibleProperty(
"pressed", pressed || d->slider->second()->isPressed());
289 emit pressedChanged();
292bool QQuickRangeSliderNode::isHovered()
const
294 Q_D(
const QQuickRangeSliderNode);
298void QQuickRangeSliderNode::setHovered(
bool hovered)
300 Q_D(QQuickRangeSliderNode);
301 if (d->hovered == hovered)
304 d->hovered = hovered;
305 emit hoveredChanged();
308qreal QQuickRangeSliderNode::implicitHandleWidth()
const
310 Q_D(
const QQuickRangeSliderNode);
313 return d->handle->implicitWidth();
316qreal QQuickRangeSliderNode::implicitHandleHeight()
const
318 Q_D(
const QQuickRangeSliderNode);
321 return d->handle->implicitHeight();
324void QQuickRangeSliderNode::increase()
326 Q_D(QQuickRangeSliderNode);
327 qreal step = qFuzzyIsNull(d->slider->stepSize()) ? 0.1 : d->slider->stepSize();
328 setValue(d->value + step);
331void QQuickRangeSliderNode::decrease()
333 Q_D(QQuickRangeSliderNode);
334 qreal step = qFuzzyIsNull(d->slider->stepSize()) ? 0.1 : d->slider->stepSize();
335 setValue(d->value - step);
343 Q_DECLARE_PUBLIC(QQuickRangeSlider)
348#if QT_CONFIG(quicktemplates2_multitouch)
352 bool handleMove(
const QPointF &point, ulong timestamp)
override;
367 QQuickRangeSliderNode *
first =
nullptr;
376 return slider->from() + (slider->to() - slider->from()) * position;
381 const qreal range = slider->to() - slider->from();
382 if (qFuzzyIsNull(range))
385 const qreal effectiveStep = slider->stepSize() / range;
386 if (qFuzzyIsNull(effectiveStep))
389 return qRound(position / effectiveStep) * effectiveStep;
392static qreal positionAt(
const QQuickRangeSlider *slider, QQuickItem *handle,
const QPointF &point)
394 if (slider->orientation() == Qt::Horizontal) {
395 const qreal hw = handle ? handle->width() : 0;
396 const qreal offset = hw / 2;
397 const qreal extent = slider->availableWidth() - hw;
398 if (!qFuzzyIsNull(extent)) {
399 if (slider->isMirrored())
400 return (slider->width() - point.x() - slider->rightPadding() - offset) / extent;
401 return (point.x() - slider->leftPadding() - offset) / extent;
404 const qreal hh = handle ? handle->height() : 0;
405 const qreal offset = hh / 2;
406 const qreal extent = slider->availableHeight() - hh;
407 if (!qFuzzyIsNull(extent))
408 return (slider->height() - point.y() - slider->bottomPadding() - offset) / extent;
424#if QT_CONFIG(quicktemplates2_multitouch)
425bool QQuickRangeSliderPrivate::acceptTouch(
const QTouchEvent::TouchPoint &point)
427 int firstId = QQuickRangeSliderNodePrivate::get(first)->touchId;
428 int secondId = QQuickRangeSliderNodePrivate::get(second)->touchId;
430 if (((firstId == -1 || secondId == -1) && point.state() == QEventPoint::Pressed) || point.id() == firstId || point.id() == secondId) {
431 touchId = point.id();
441 Q_Q(QQuickRangeSlider);
442 QQuickControlPrivate::handlePress(point, timestamp);
445 QQuickItem *firstHandle =
first->handle();
446 QQuickItem *secondHandle =
second->handle();
447 const bool firstHit = firstHandle && !first->isPressed() && firstHandle->contains(q->mapToItem(firstHandle, point));
448 const bool secondHit = secondHandle && !second->isPressed() && secondHandle->contains(q->mapToItem(secondHandle, point));
449 QQuickRangeSliderNode *hitNode =
nullptr;
450 QQuickRangeSliderNode *otherNode =
nullptr;
452 if (firstHit && secondHit) {
454 hitNode = firstHandle->z() > secondHandle->z() ?
first :
second;
455 otherNode = firstHandle->z() > secondHandle->z() ?
second :
first;
456 }
else if (firstHit) {
459 }
else if (secondHit) {
464 const qreal firstPos = positionAt(q, firstHandle, point);
465 const qreal secondPos = positionAt(q, secondHandle, point);
466 const qreal firstDistance = qAbs(firstPos -
first->position());
467 const qreal secondDistance = qAbs(secondPos -
second->position());
469 if (qFuzzyCompare(firstDistance, secondDistance)) {
471 const bool inverted = from > to;
472 if ((!inverted && firstPos <
first->position()) || (inverted && firstPos >
first->position())) {
479 }
else if (firstDistance < secondDistance) {
489 hitNode->setPressed(
true);
490 if (QQuickItem *handle = hitNode->handle()) {
495 if (focusPolicy & Qt::ClickFocus)
496 handle->forceActiveFocus(Qt::MouseFocusReason);
498 QQuickRangeSliderNodePrivate::get(hitNode)->touchId = touchId;
501 if (QQuickItem *handle = otherNode->handle())
509 Q_Q(QQuickRangeSlider);
510 QQuickControlPrivate::handleMove(point, timestamp);
511 QQuickRangeSliderNode *pressedNode = QQuickRangeSliderPrivate::pressedNode(touchId);
513 const qreal oldPos = pressedNode->position();
514 qreal pos = positionAt(q, pressedNode->handle(), point);
515 if (snapMode == QQuickRangeSlider::SnapAlways)
516 pos = snapPosition(q, pos);
518 pressedNode->setValue(valueAt(q, pos));
522 if (!qFuzzyCompare(pressedNode->position(), oldPos))
523 emit pressedNode->moved();
530 Q_Q(QQuickRangeSlider);
531 QQuickControlPrivate::handleRelease(point, timestamp);
532 pressPoint = QPointF();
534 QQuickRangeSliderNode *pressedNode = QQuickRangeSliderPrivate::pressedNode(touchId);
539 const qreal oldPos = pressedNode->position();
540 qreal pos = positionAt(q, pressedNode->handle(), point);
541 if (snapMode != QQuickRangeSlider::NoSnap)
542 pos = snapPosition(q, pos);
543 qreal val = valueAt(q, pos);
544 if (!qFuzzyCompare(val, pressedNode->value()))
545 pressedNode->setValue(val);
546 else if (snapMode != QQuickRangeSlider::NoSnap)
547 pressedNodePrivate->setPosition(pos);
548 q->setKeepMouseGrab(
false);
549 q->setKeepTouchGrab(
false);
551 if (!qFuzzyCompare(pressedNode->position(), oldPos))
552 emit pressedNode->moved();
554 pressedNode->setPressed(
false);
561 QQuickControlPrivate::handleUngrab();
562 pressPoint = QPointF();
563 first->setPressed(
false);
564 second->setPressed(
false);
571 Q_Q(QQuickRangeSlider);
572 QQuickItem *firstHandle =
first->handle();
573 QQuickItem *secondHandle =
second->handle();
574 bool firstHandleHovered = firstHandle && firstHandle->isEnabled()
575 && firstHandle->contains(q->mapToItem(firstHandle, pos));
576 bool secondHandleHovered = secondHandle && secondHandle->isEnabled()
577 && secondHandle->contains(q->mapToItem(secondHandle, pos));
579 if (firstHandleHovered && secondHandleHovered) {
581 const bool firstHandleHasHigherZ = firstHandle->z() > secondHandle->z();
582 firstHandleHovered = firstHandleHasHigherZ;
583 secondHandleHovered = !firstHandleHasHigherZ;
585 first->setHovered(firstHandleHovered);
586 second->setHovered(secondHandleHovered);
591 QQuickControlPrivate::itemImplicitWidthChanged(item);
592 if (item ==
first->handle())
593 emit first->implicitHandleWidthChanged();
594 else if (item ==
second->handle())
595 emit second->implicitHandleWidthChanged();
600 QQuickControlPrivate::itemImplicitHeightChanged(item);
601 if (item ==
first->handle())
602 emit first->implicitHandleHeightChanged();
603 else if (item ==
second->handle())
604 emit second->implicitHandleHeightChanged();
609 QQuickControlPrivate::itemDestroyed(item);
610 if (item ==
first->handle())
611 first->setHandle(
nullptr);
612 else if (item ==
second->handle())
613 second->setHandle(
nullptr);
616QQuickRangeSlider::QQuickRangeSlider(QQuickItem *parent)
617 : QQuickControl(*(
new QQuickRangeSliderPrivate), parent)
619 Q_D(QQuickRangeSlider);
620 d->first =
new QQuickRangeSliderNode(0.0,
this);
621 d->second =
new QQuickRangeSliderNode(1.0,
this);
622 d->setSizePolicy(QLayoutPolicy::Expanding, QLayoutPolicy::Fixed);
624 setFlag(QQuickItem::ItemIsFocusScope);
626 setFocusPolicy(Qt::TabFocus);
628 setFocusPolicy(Qt::StrongFocus);
630 setAcceptedMouseButtons(Qt::LeftButton);
631#if QT_CONFIG(quicktemplates2_multitouch)
632 setAcceptTouchEvents(
true);
635 setCursor(Qt::ArrowCursor);
639QQuickRangeSlider::~QQuickRangeSlider()
641 Q_D(QQuickRangeSlider);
642 d->removeImplicitSizeListener(d->first->handle());
643 d->removeImplicitSizeListener(d->second->handle());
647
648
649
650
651
652
653qreal QQuickRangeSlider::from()
const
655 Q_D(
const QQuickRangeSlider);
659void QQuickRangeSlider::setFrom(qreal from)
661 Q_D(QQuickRangeSlider);
662 if (qFuzzyCompare(d->from, from))
668 if (isComponentComplete()) {
669 d->first->setValue(d->first->value());
670 d->second->setValue(d->second->value());
671 auto *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
672 auto *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
673 firstPrivate->updatePosition(
true);
674 secondPrivate->updatePosition();
679
680
681
682
683
684
685qreal QQuickRangeSlider::to()
const
687 Q_D(
const QQuickRangeSlider);
691void QQuickRangeSlider::setTo(qreal to)
693 Q_D(QQuickRangeSlider);
694 if (qFuzzyCompare(d->to, to))
700 if (isComponentComplete()) {
701 d->first->setValue(d->first->value());
702 d->second->setValue(d->second->value());
703 auto *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
704 auto *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
705 firstPrivate->updatePosition(
true);
706 secondPrivate->updatePosition();
711
712
713
714
715
716
717
718
719
720
721qreal QQuickRangeSlider::touchDragThreshold()
const
723 Q_D(
const QQuickRangeSlider);
724 return d->touchDragThreshold;
727void QQuickRangeSlider::setTouchDragThreshold(qreal touchDragThreshold)
729 Q_D(QQuickRangeSlider);
730 if (d->touchDragThreshold == touchDragThreshold)
733 d->touchDragThreshold = touchDragThreshold;
734 emit touchDragThresholdChanged();
737void QQuickRangeSlider::resetTouchDragThreshold()
739 setTouchDragThreshold(-1);
743
744
745
746
747
748
749
750qreal QQuickRangeSlider::valueAt(qreal position)
const
752 Q_D(
const QQuickRangeSlider);
753 const qreal value = (d->to - d->from) * position;
754 if (qFuzzyIsNull(d->stepSize))
755 return d->from + value;
756 return d->from + qRound(value / d->stepSize) * d->stepSize;
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820QQuickRangeSliderNode *QQuickRangeSlider::first()
const
822 Q_D(
const QQuickRangeSlider);
827
828
829
830
831
832
833
834
835
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898QQuickRangeSliderNode *QQuickRangeSlider::second()
const
900 Q_D(
const QQuickRangeSlider);
905
906
907
908
909
910
911qreal QQuickRangeSlider::stepSize()
const
913 Q_D(
const QQuickRangeSlider);
917void QQuickRangeSlider::setStepSize(qreal step)
919 Q_D(QQuickRangeSlider);
920 if (qFuzzyCompare(d->stepSize, step))
924 emit stepSizeChanged();
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945QQuickRangeSlider::SnapMode QQuickRangeSlider::snapMode()
const
947 Q_D(
const QQuickRangeSlider);
951void QQuickRangeSlider::setSnapMode(SnapMode mode)
953 Q_D(QQuickRangeSlider);
954 if (d->snapMode == mode)
958 emit snapModeChanged();
962
963
964
965
966
967
968
969
970
971
972Qt::Orientation QQuickRangeSlider::orientation()
const
974 Q_D(
const QQuickRangeSlider);
975 return d->orientation;
978void QQuickRangeSlider::setOrientation(Qt::Orientation orientation)
980 Q_D(QQuickRangeSlider);
981 if (d->orientation == orientation)
984 if (orientation == Qt::Horizontal)
985 d->setSizePolicy(QLayoutPolicy::Expanding, QLayoutPolicy::Fixed);
987 d->setSizePolicy(QLayoutPolicy::Fixed, QLayoutPolicy::Expanding);
989 d->orientation = orientation;
990 emit orientationChanged();
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011void QQuickRangeSlider::setValues(qreal firstValue, qreal secondValue)
1013 Q_D(QQuickRangeSlider);
1015 const qreal smaller = qMin(d->to, d->from);
1016 const qreal larger = qMax(d->to, d->from);
1017 firstValue = qBound(smaller, firstValue, larger);
1018 secondValue = qBound(smaller, secondValue, larger);
1020 if (d->from > d->to) {
1023 if (secondValue > firstValue)
1024 secondValue = firstValue;
1027 if (firstValue > secondValue)
1028 firstValue = secondValue;
1032 QQuickRangeSliderNodePrivate *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
1033 if (firstValue != firstPrivate->value) {
1034 firstPrivate->value = firstValue;
1035 emit d->first->valueChanged();
1038 QQuickRangeSliderNodePrivate *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
1039 if (secondValue != secondPrivate->value) {
1040 secondPrivate->value = secondValue;
1041 emit d->second->valueChanged();
1046 firstPrivate->updatePosition(
true);
1047 secondPrivate->updatePosition();
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061bool QQuickRangeSlider::live()
const
1063 Q_D(
const QQuickRangeSlider);
1067void QQuickRangeSlider::setLive(
bool live)
1069 Q_D(QQuickRangeSlider);
1070 if (d->live == live)
1078
1079
1080
1081
1082
1083
1084
1085
1086bool QQuickRangeSlider::isHorizontal()
const
1088 Q_D(
const QQuickRangeSlider);
1089 return d->orientation == Qt::Horizontal;
1093
1094
1095
1096
1097
1098
1099
1100
1101bool QQuickRangeSlider::isVertical()
const
1103 Q_D(
const QQuickRangeSlider);
1104 return d->orientation == Qt::Vertical;
1107void QQuickRangeSlider::focusInEvent(QFocusEvent *event)
1109 Q_D(QQuickRangeSlider);
1110 QQuickControl::focusInEvent(event);
1116 QQuickItem *handle = nextItemInFocusChain();
1119 if (!handle || handle ==
this)
1120 handle = d->first->handle();
1122 handle->forceActiveFocus(event->reason());
1125void QQuickRangeSlider::keyPressEvent(QKeyEvent *event)
1127 Q_D(QQuickRangeSlider);
1128 QQuickControl::keyPressEvent(event);
1130 QQuickRangeSliderNode *focusNode = d->first->handle()->hasActiveFocus()
1131 ? d->first : (d->second->handle()->hasActiveFocus() ? d->second :
nullptr);
1135 const qreal oldValue = focusNode->value();
1136 if (d->orientation == Qt::Horizontal) {
1137 if (event->key() == Qt::Key_Left) {
1138 focusNode->setPressed(
true);
1140 focusNode->increase();
1142 focusNode->decrease();
1144 }
else if (event->key() == Qt::Key_Right) {
1145 focusNode->setPressed(
true);
1147 focusNode->decrease();
1149 focusNode->increase();
1153 if (event->key() == Qt::Key_Up) {
1154 focusNode->setPressed(
true);
1155 focusNode->increase();
1157 }
else if (event->key() == Qt::Key_Down) {
1158 focusNode->setPressed(
true);
1159 focusNode->decrease();
1163 if (!qFuzzyCompare(focusNode->value(), oldValue))
1164 emit focusNode->moved();
1167void QQuickRangeSlider::hoverEnterEvent(QHoverEvent *event)
1169 Q_D(QQuickRangeSlider);
1170 QQuickControl::hoverEnterEvent(event);
1171 d->updateHover(event->position());
1175void QQuickRangeSlider::hoverMoveEvent(QHoverEvent *event)
1177 Q_D(QQuickRangeSlider);
1178 QQuickControl::hoverMoveEvent(event);
1179 d->updateHover(event->position());
1183void QQuickRangeSlider::hoverLeaveEvent(QHoverEvent *event)
1185 Q_D(QQuickRangeSlider);
1186 QQuickControl::hoverLeaveEvent(event);
1187 d->first->setHovered(
false);
1188 d->second->setHovered(
false);
1192void QQuickRangeSlider::keyReleaseEvent(QKeyEvent *event)
1194 Q_D(QQuickRangeSlider);
1195 QQuickControl::keyReleaseEvent(event);
1196 d->first->setPressed(
false);
1197 d->second->setPressed(
false);
1200void QQuickRangeSlider::mousePressEvent(QMouseEvent *event)
1202 Q_D(QQuickRangeSlider);
1203 QQuickControl::mousePressEvent(event);
1204 d->handleMove(event->position(), event->timestamp());
1205 setKeepMouseGrab(
true);
1208#if QT_CONFIG(quicktemplates2_multitouch)
1209void QQuickRangeSlider::touchEvent(QTouchEvent *event)
1211 Q_D(QQuickRangeSlider);
1212 switch (event->type()) {
1213 case QEvent::TouchUpdate:
1214 for (
const QTouchEvent::TouchPoint &point : event->points()) {
1215 if (!d->acceptTouch(point))
1218 switch (point.state()) {
1219 case QEventPoint::Pressed:
1220 d->handlePress(point.position(), event->timestamp());
1222 case QEventPoint::Updated:
1223 if (!keepTouchGrab()) {
1224 if (d->orientation == Qt::Horizontal) {
1225 setKeepTouchGrab(QQuickDeliveryAgentPrivate::dragOverThreshold(point.position().x() - point.pressPosition().x(),
1226 Qt::XAxis, point, qRound(d->touchDragThreshold)));
1228 setKeepTouchGrab(QQuickDeliveryAgentPrivate::dragOverThreshold(point.position().y() - point.pressPosition().y(),
1229 Qt::YAxis, point, qRound(d->touchDragThreshold)));
1232 if (keepTouchGrab())
1233 d->handleMove(point.position(), event->timestamp());
1235 case QEventPoint::Released:
1236 d->handleRelease(point.position(), event->timestamp());
1245 QQuickControl::touchEvent(event);
1251void QQuickRangeSlider::mirrorChange()
1253 Q_D(QQuickRangeSlider);
1254 QQuickControl::mirrorChange();
1255 emit d->first->visualPositionChanged();
1256 emit d->second->visualPositionChanged();
1259void QQuickRangeSlider::classBegin()
1261 Q_D(QQuickRangeSlider);
1262 QQuickControl::classBegin();
1264 QQmlContext *context = qmlContext(
this);
1266 QQmlEngine::setContextForObject(d->first, context);
1267 QQmlEngine::setContextForObject(d->second, context);
1271void QQuickRangeSlider::componentComplete()
1273 Q_D(QQuickRangeSlider);
1274 QQuickRangeSliderNodePrivate *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
1275 QQuickRangeSliderNodePrivate *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
1276 firstPrivate->executeHandle(
true);
1277 secondPrivate->executeHandle(
true);
1279 QQuickControl::componentComplete();
1281 if (firstPrivate->isPendingValue || secondPrivate->isPendingValue
1282 || !qFuzzyCompare(d->from, defaultFrom) || !qFuzzyCompare(d->to, defaultTo)) {
1286 setValues(firstPrivate->isPendingValue ? firstPrivate->pendingValue : firstPrivate->value,
1287 secondPrivate->isPendingValue ? secondPrivate->pendingValue : secondPrivate->value);
1289 firstPrivate->pendingValue = 0;
1290 firstPrivate->isPendingValue =
false;
1291 secondPrivate->pendingValue = 0;
1292 secondPrivate->isPendingValue =
false;
1298 firstPrivate->updatePosition();
1299 secondPrivate->updatePosition();
1304
1305
1306
1307
1308
1309
1312
1313
1314
1315
1316
1317
1320
1321
1322
1323
1324
1325
1328
1329
1330
1331
1332
1333
1335#if QT_CONFIG(accessibility)
1336QAccessible::Role QQuickRangeSlider::accessibleRole()
const
1338 return QAccessible::Slider;
1344#include "moc_qquickrangeslider_p.cpp"
Used to select a range of values by sliding two handles along a track.
void setPosition(qreal position, bool ignoreOtherPosition=false)
void executeHandle(bool complete=false)
static QQuickRangeSliderNodePrivate * get(QQuickRangeSliderNode *node)
QQuickDeferredPointer< QQuickItem > handle
QQuickRangeSlider * slider
void updatePosition(bool ignoreOtherPosition=false)
bool handleMove(const QPointF &point, ulong timestamp) override
Qt::Orientation orientation
void itemDestroyed(QQuickItem *item) override
void handleUngrab() override
bool handleRelease(const QPointF &point, ulong timestamp) override
QQuickRangeSliderNode * first
void itemImplicitHeightChanged(QQuickItem *item) override
bool handlePress(const QPointF &point, ulong timestamp) override
void updateHover(const QPointF &pos)
QQuickRangeSliderNode * second
void itemImplicitWidthChanged(QQuickItem *item) override
static const qreal defaultFrom
static const qreal defaultTo
static qreal valueAt(const QQuickRangeSlider *slider, qreal position)
static qreal positionAt(const QQuickRangeSlider *slider, QQuickItem *handle, const QPointF &point)
static qreal snapPosition(const QQuickRangeSlider *slider, qreal position)