9#include <QtCore/qscopedpointer.h>
10#include <QtQuick/private/qquickwindow_p.h>
11#include <QtQuickTemplates2/private/qtquicktemplates2math_p.h>
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
62
63
67 Q_DECLARE_PUBLIC(QQuickRangeSliderNode)
77 void setPosition(qreal position,
bool ignoreOtherPosition =
false);
98 return this ==
get(slider->first());
103 Q_Q(QQuickRangeSliderNode);
105 const qreal min = isFirst() || ignoreOtherPosition ? 0.0 : qMax<qreal>(0.0, slider->first()->position());
106 const qreal max = !isFirst() || ignoreOtherPosition ? 1.0 : qMin<qreal>(1.0, slider->second()->position());
107 position = qBound(min, position, max);
108 if (!qFuzzyCompare(
this->position, position)) {
109 this->position = position;
110 emit q->positionChanged();
111 emit q->visualPositionChanged();
118 if (!qFuzzyCompare(slider->from(), slider->to()))
119 pos = (value - slider->from()) / (slider->to() - slider->from());
120 setPosition(pos, ignoreOtherPosition);
125 Q_Q(QQuickRangeSliderNode);
126 quickCancelDeferred(q, handleName());
131 Q_Q(QQuickRangeSliderNode);
132 if (handle.wasExecuted())
135 if (!handle || complete)
136 quickBeginDeferred(q, handleName(), handle);
138 quickCompleteDeferred(q, handleName(), handle);
143 return node->d_func();
146QQuickRangeSliderNode::QQuickRangeSliderNode(qreal value, QQuickRangeSlider *slider)
147 : QObject(*(
new QQuickRangeSliderNodePrivate(value, slider)), slider)
151QQuickRangeSliderNode::~QQuickRangeSliderNode()
155qreal QQuickRangeSliderNode::value()
const
157 Q_D(
const QQuickRangeSliderNode);
161void QQuickRangeSliderNode::setValue(qreal value)
163 Q_D(QQuickRangeSliderNode);
164 if (!d->slider->isComponentComplete()) {
165 d->pendingValue = value;
166 d->isPendingValue =
true;
171 const qreal smaller = qMin(d->slider->to(), d->slider->from());
172 const qreal larger = qMax(d->slider->to(), d->slider->from());
173 value = qBound(smaller, value, larger);
177 const bool invertedRange = d->slider->from() > d->slider->to();
180 if (value < d->slider->second()->value())
181 value = d->slider->second()->value();
183 if (value > d->slider->second()->value())
184 value = d->slider->second()->value();
188 if (value > d->slider->first()->value())
189 value = d->slider->first()->value();
191 if (value < d->slider->first()->value())
192 value = d->slider->first()->value();
196 if (!qFuzzyCompare(d->value, value)) {
203qreal QQuickRangeSliderNode::position()
const
205 Q_D(
const QQuickRangeSliderNode);
209qreal QQuickRangeSliderNode::visualPosition()
const
211 Q_D(
const QQuickRangeSliderNode);
212 if (d->slider->orientation() == Qt::Vertical || d->slider->isMirrored())
213 return 1.0 - d->position;
217QQuickItem *QQuickRangeSliderNode::handle()
const
219 QQuickRangeSliderNodePrivate *d =
const_cast<QQuickRangeSliderNodePrivate *>(d_func());
225void QQuickRangeSliderNode::setHandle(QQuickItem *handle)
227 Q_D(QQuickRangeSliderNode);
228 if (d->handle == handle)
231 QQuickControlPrivate::warnIfCustomizationNotSupported(d->slider, handle, QStringLiteral(
"handle"));
233 if (!d->handle.isExecuting())
236 const qreal oldImplicitHandleWidth = implicitHandleWidth();
237 const qreal oldImplicitHandleHeight = implicitHandleHeight();
239 QQuickControlPrivate::get(d->slider)->removeImplicitSizeListener(d->handle);
240 QQuickControlPrivate::hideOldItem(d->handle);
244 if (!handle->parentItem())
245 handle->setParentItem(d->slider);
247 QQuickItem *firstHandle = QQuickRangeSliderNodePrivate::get(d->slider->first())->handle;
248 QQuickItem *secondHandle = QQuickRangeSliderNodePrivate::get(d->slider->second())->handle;
249 if (firstHandle && secondHandle) {
253 const QList<QQuickItem *> childItems = d->slider->childItems();
254 const int firstIndex = childItems.indexOf(firstHandle);
255 const int secondIndex = childItems.indexOf(secondHandle);
256 if (firstIndex != -1 && secondIndex != -1 && firstIndex > secondIndex) {
257 firstHandle->stackBefore(secondHandle);
261 secondHandle->setZ(secondHandle->z() + 1);
265 handle->setActiveFocusOnTab(
true);
266 QQuickControlPrivate::get(d->slider)->addImplicitSizeListener(handle);
269 if (!qFuzzyCompare(oldImplicitHandleWidth, implicitHandleWidth()))
270 emit implicitHandleWidthChanged();
271 if (!qFuzzyCompare(oldImplicitHandleHeight, implicitHandleHeight()))
272 emit implicitHandleHeightChanged();
273 if (!d->handle.isExecuting())
274 emit handleChanged();
277bool QQuickRangeSliderNode::isPressed()
const
279 Q_D(
const QQuickRangeSliderNode);
283void QQuickRangeSliderNode::setPressed(
bool pressed)
285 Q_D(QQuickRangeSliderNode);
286 if (d->pressed == pressed)
289 d->pressed = pressed;
290 d->slider->setAccessibleProperty(
"pressed", pressed || d->slider->second()->isPressed());
291 emit pressedChanged();
294bool QQuickRangeSliderNode::isHovered()
const
296 Q_D(
const QQuickRangeSliderNode);
300void QQuickRangeSliderNode::setHovered(
bool hovered)
302 Q_D(QQuickRangeSliderNode);
303 if (d->hovered == hovered)
306 d->hovered = hovered;
307 emit hoveredChanged();
310qreal QQuickRangeSliderNode::implicitHandleWidth()
const
312 Q_D(
const QQuickRangeSliderNode);
315 return d->handle->implicitWidth();
318qreal QQuickRangeSliderNode::implicitHandleHeight()
const
320 Q_D(
const QQuickRangeSliderNode);
323 return d->handle->implicitHeight();
326void QQuickRangeSliderNode::increase()
328 Q_D(QQuickRangeSliderNode);
329 qreal step = qFuzzyIsNull(d->slider->stepSize()) ? 0.1 : d->slider->stepSize();
330 setValue(d->value + step);
333void QQuickRangeSliderNode::decrease()
335 Q_D(QQuickRangeSliderNode);
336 qreal step = qFuzzyIsNull(d->slider->stepSize()) ? 0.1 : d->slider->stepSize();
337 setValue(d->value - step);
345 Q_DECLARE_PUBLIC(QQuickRangeSlider)
352#if QT_CONFIG(quicktemplates2_multitouch)
356 bool handleMove(
const QPointF &point, ulong timestamp)
override;
372 QQuickRangeSliderNode *
first =
nullptr;
383 qreal value = slider->from() + (slider->to() - slider->from()) * position;
386 if (QQuickRangeSliderPrivate::get(slider)->allValuesAreInteger)
387 value = qRound(value);
394 const qreal range = slider->to() - slider->from();
395 if (qFuzzyIsNull(range))
398 const qreal effectiveStep = slider->stepSize() / range;
399 if (qFuzzyIsNull(effectiveStep))
402 return qRound(position / effectiveStep) * effectiveStep;
405static qreal positionAt(
const QQuickRangeSlider *slider, QQuickItem *handle,
const QPointF &point)
407 if (slider->orientation() == Qt::Horizontal) {
408 const qreal hw = handle ? handle->width() : 0;
409 const qreal offset = hw / 2;
410 const qreal extent = slider->availableWidth() - hw;
411 if (!qFuzzyIsNull(extent)) {
412 if (slider->isMirrored())
413 return (slider->width() - point.x() - slider->rightPadding() - offset) / extent;
414 return (point.x() - slider->leftPadding() - offset) / extent;
417 const qreal hh = handle ? handle->height() : 0;
418 const qreal offset = hh / 2;
419 const qreal extent = slider->availableHeight() - hh;
420 if (!qFuzzyIsNull(extent))
421 return (slider->height() - point.y() - slider->bottomPadding() - offset) / extent;
428 return slider->d_func();
442#if QT_CONFIG(quicktemplates2_multitouch)
443bool QQuickRangeSliderPrivate::acceptTouch(
const QTouchEvent::TouchPoint &point)
445 int firstId = QQuickRangeSliderNodePrivate::get(first)->touchId;
446 int secondId = QQuickRangeSliderNodePrivate::get(second)->touchId;
448 if (((firstId == -1 || secondId == -1) && point.state() == QEventPoint::Pressed) || point.id() == firstId || point.id() == secondId) {
449 touchId = point.id();
459 Q_Q(QQuickRangeSlider);
460 QQuickControlPrivate::handlePress(point, timestamp);
463 QQuickItem *firstHandle =
first->handle();
464 QQuickItem *secondHandle =
second->handle();
465 const bool firstHit = firstHandle && !
first->isPressed() && firstHandle->contains(q->mapToItem(firstHandle, point));
466 const bool secondHit = secondHandle && !
second->isPressed() && secondHandle->contains(q->mapToItem(secondHandle, point));
467 QQuickRangeSliderNode *hitNode =
nullptr;
468 QQuickRangeSliderNode *otherNode =
nullptr;
470 if (firstHit && secondHit) {
472 hitNode = firstHandle->z() > secondHandle->z() ?
first :
second;
473 otherNode = firstHandle->z() > secondHandle->z() ?
second :
first;
474 }
else if (firstHit) {
477 }
else if (secondHit) {
482 const qreal firstPos = positionAt(q, firstHandle, point);
483 const qreal secondPos = positionAt(q, secondHandle, point);
484 const qreal firstDistance = qAbs(firstPos -
first->position());
485 const qreal secondDistance = qAbs(secondPos -
second->position());
487 if (qFuzzyCompare(firstDistance, secondDistance)) {
489 const bool inverted = from > to;
490 if ((!inverted && firstPos <
first->position()) || (inverted && firstPos >
first->position())) {
497 }
else if (firstDistance < secondDistance) {
507 hitNode->setPressed(
true);
508 if (QQuickItem *handle = hitNode->handle()) {
513 if (focusPolicy & Qt::ClickFocus)
514 handle->forceActiveFocus(Qt::MouseFocusReason);
516 QQuickRangeSliderNodePrivate::get(hitNode)->touchId = touchId;
519 if (QQuickItem *handle = otherNode->handle())
527 Q_Q(QQuickRangeSlider);
528 QQuickControlPrivate::handleMove(point, timestamp);
531 const qreal oldPos = pressedNode->position();
532 qreal pos = positionAt(q, pressedNode->handle(), point);
533 if (snapMode == QQuickRangeSlider::SnapAlways)
534 pos = snapPosition(q, pos);
536 pressedNode->setValue(valueAt(q, pos));
540 if (!qFuzzyCompare(pressedNode->position(), oldPos))
541 emit pressedNode->moved();
548 Q_Q(QQuickRangeSlider);
549 QQuickControlPrivate::handleRelease(point, timestamp);
550 pressPoint = QPointF();
557 const qreal oldPos = pressedNode->position();
558 qreal pos = positionAt(q, pressedNode->handle(), point);
559 if (snapMode != QQuickRangeSlider::NoSnap)
560 pos = snapPosition(q, pos);
561 qreal val = valueAt(q, pos);
562 if (!qFuzzyCompare(val, pressedNode->value()))
563 pressedNode->setValue(val);
564 else if (snapMode != QQuickRangeSlider::NoSnap)
565 pressedNodePrivate->setPosition(pos);
566 q->setKeepMouseGrab(
false);
567 q->setKeepTouchGrab(
false);
569 if (!qFuzzyCompare(pressedNode->position(), oldPos))
570 emit pressedNode->moved();
572 pressedNode->setPressed(
false);
579 QQuickControlPrivate::handleUngrab();
580 pressPoint = QPointF();
581 first->setPressed(
false);
582 second->setPressed(
false);
589 Q_Q(QQuickRangeSlider);
590 QQuickItem *firstHandle =
first->handle();
591 QQuickItem *secondHandle =
second->handle();
592 bool firstHandleHovered = firstHandle && firstHandle->isEnabled()
593 && firstHandle->contains(q->mapToItem(firstHandle, pos));
594 bool secondHandleHovered = secondHandle && secondHandle->isEnabled()
595 && secondHandle->contains(q->mapToItem(secondHandle, pos));
597 if (firstHandleHovered && secondHandleHovered) {
599 const bool firstHandleHasHigherZ = firstHandle->z() > secondHandle->z();
600 firstHandleHovered = firstHandleHasHigherZ;
601 secondHandleHovered = !firstHandleHasHigherZ;
603 first->setHovered(firstHandleHovered);
604 second->setHovered(secondHandleHovered);
609 QQuickControlPrivate::itemImplicitWidthChanged(item);
610 if (item ==
first->handle())
611 emit first->implicitHandleWidthChanged();
612 else if (item ==
second->handle())
613 emit second->implicitHandleWidthChanged();
618 QQuickControlPrivate::itemImplicitHeightChanged(item);
619 if (item ==
first->handle())
620 emit first->implicitHandleHeightChanged();
621 else if (item ==
second->handle())
622 emit second->implicitHandleHeightChanged();
627 QQuickControlPrivate::itemDestroyed(item);
628 if (item ==
first->handle())
629 first->setHandle(
nullptr);
630 else if (item ==
second->handle())
631 second->setHandle(
nullptr);
636 allValuesAreInteger = areRepresentableAsInteger(to, from, stepSize) && stepSize != 0.0;
639QQuickRangeSlider::QQuickRangeSlider(QQuickItem *parent)
640 : QQuickControl(*(
new QQuickRangeSliderPrivate), parent)
642 Q_D(QQuickRangeSlider);
643 d->first =
new QQuickRangeSliderNode(0.0,
this);
644 d->second =
new QQuickRangeSliderNode(1.0,
this);
645 d->setSizePolicy(QLayoutPolicy::Expanding, QLayoutPolicy::Fixed);
647 setFlag(QQuickItem::ItemIsFocusScope);
649 setFocusPolicy(Qt::TabFocus);
651 setFocusPolicy(Qt::StrongFocus);
653 setAcceptedMouseButtons(Qt::LeftButton);
654#if QT_CONFIG(quicktemplates2_multitouch)
655 setAcceptTouchEvents(
true);
658 setCursor(Qt::ArrowCursor);
662QQuickRangeSlider::~QQuickRangeSlider()
664 Q_D(QQuickRangeSlider);
665 d->removeImplicitSizeListener(d->first->handle());
666 d->removeImplicitSizeListener(d->second->handle());
670
671
672
673
674
675
676qreal QQuickRangeSlider::from()
const
678 Q_D(
const QQuickRangeSlider);
682void QQuickRangeSlider::setFrom(qreal from)
684 Q_D(QQuickRangeSlider);
685 if (qFuzzyCompare(d->from, from))
690 d->updateAllValuesAreInteger();
692 if (isComponentComplete()) {
693 d->first->setValue(d->first->value());
694 d->second->setValue(d->second->value());
695 auto *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
696 auto *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
697 firstPrivate->updatePosition(
true);
698 secondPrivate->updatePosition();
703
704
705
706
707
708
709qreal QQuickRangeSlider::to()
const
711 Q_D(
const QQuickRangeSlider);
715void QQuickRangeSlider::setTo(qreal to)
717 Q_D(QQuickRangeSlider);
718 if (qFuzzyCompare(d->to, to))
723 d->updateAllValuesAreInteger();
725 if (isComponentComplete()) {
726 d->first->setValue(d->first->value());
727 d->second->setValue(d->second->value());
728 auto *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
729 auto *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
730 firstPrivate->updatePosition(
true);
731 secondPrivate->updatePosition();
736
737
738
739
740
741
742
743
744
745
746qreal QQuickRangeSlider::touchDragThreshold()
const
748 Q_D(
const QQuickRangeSlider);
749 return d->touchDragThreshold;
752void QQuickRangeSlider::setTouchDragThreshold(qreal touchDragThreshold)
754 Q_D(QQuickRangeSlider);
755 if (d->touchDragThreshold == touchDragThreshold)
758 d->touchDragThreshold = touchDragThreshold;
759 emit touchDragThresholdChanged();
762void QQuickRangeSlider::resetTouchDragThreshold()
764 setTouchDragThreshold(-1);
768
769
770
771
772
773
774
775qreal QQuickRangeSlider::valueAt(qreal position)
const
777 Q_D(
const QQuickRangeSlider);
778 const qreal value = (d->to - d->from) * position;
779 if (qFuzzyIsNull(d->stepSize))
780 return d->from + value;
781 return d->from + qRound(value / d->stepSize) * d->stepSize;
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
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845QQuickRangeSliderNode *QQuickRangeSlider::first()
const
847 Q_D(
const QQuickRangeSlider);
852
853
854
855
856
857
858
859
860
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
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923QQuickRangeSliderNode *QQuickRangeSlider::second()
const
925 Q_D(
const QQuickRangeSlider);
930
931
932
933
934
935
936qreal QQuickRangeSlider::stepSize()
const
938 Q_D(
const QQuickRangeSlider);
942void QQuickRangeSlider::setStepSize(qreal step)
944 Q_D(QQuickRangeSlider);
945 if (qFuzzyCompare(d->stepSize, step))
949 emit stepSizeChanged();
950 d->updateAllValuesAreInteger();
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971QQuickRangeSlider::SnapMode QQuickRangeSlider::snapMode()
const
973 Q_D(
const QQuickRangeSlider);
977void QQuickRangeSlider::setSnapMode(SnapMode mode)
979 Q_D(QQuickRangeSlider);
980 if (d->snapMode == mode)
984 emit snapModeChanged();
988
989
990
991
992
993
994
995
996
997
998Qt::Orientation QQuickRangeSlider::orientation()
const
1000 Q_D(
const QQuickRangeSlider);
1001 return d->orientation;
1004void QQuickRangeSlider::setOrientation(Qt::Orientation orientation)
1006 Q_D(QQuickRangeSlider);
1007 if (d->orientation == orientation)
1010 if (orientation == Qt::Horizontal)
1011 d->setSizePolicy(QLayoutPolicy::Expanding, QLayoutPolicy::Fixed);
1013 d->setSizePolicy(QLayoutPolicy::Fixed, QLayoutPolicy::Expanding);
1015 d->orientation = orientation;
1016 emit orientationChanged();
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037void QQuickRangeSlider::setValues(qreal firstValue, qreal secondValue)
1039 Q_D(QQuickRangeSlider);
1041 const qreal smaller = qMin(d->to, d->from);
1042 const qreal larger = qMax(d->to, d->from);
1043 firstValue = qBound(smaller, firstValue, larger);
1044 secondValue = qBound(smaller, secondValue, larger);
1046 if (d->from > d->to) {
1049 if (secondValue > firstValue)
1050 secondValue = firstValue;
1053 if (firstValue > secondValue)
1054 firstValue = secondValue;
1058 QQuickRangeSliderNodePrivate *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
1059 if (firstValue != firstPrivate->value) {
1060 firstPrivate->value = firstValue;
1061 emit d->first->valueChanged();
1064 QQuickRangeSliderNodePrivate *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
1065 if (secondValue != secondPrivate->value) {
1066 secondPrivate->value = secondValue;
1067 emit d->second->valueChanged();
1072 firstPrivate->updatePosition(
true);
1073 secondPrivate->updatePosition();
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087bool QQuickRangeSlider::live()
const
1089 Q_D(
const QQuickRangeSlider);
1093void QQuickRangeSlider::setLive(
bool live)
1095 Q_D(QQuickRangeSlider);
1096 if (d->live == live)
1104
1105
1106
1107
1108
1109
1110
1111
1112bool QQuickRangeSlider::isHorizontal()
const
1114 Q_D(
const QQuickRangeSlider);
1115 return d->orientation == Qt::Horizontal;
1119
1120
1121
1122
1123
1124
1125
1126
1127bool QQuickRangeSlider::isVertical()
const
1129 Q_D(
const QQuickRangeSlider);
1130 return d->orientation == Qt::Vertical;
1133void QQuickRangeSlider::focusInEvent(QFocusEvent *event)
1135 Q_D(QQuickRangeSlider);
1136 QQuickControl::focusInEvent(event);
1142 QQuickItem *handle = nextItemInFocusChain();
1145 if (!handle || handle ==
this)
1146 handle = d->first->handle();
1148 handle->forceActiveFocus(event->reason());
1151void QQuickRangeSlider::keyPressEvent(QKeyEvent *event)
1153 Q_D(QQuickRangeSlider);
1154 QQuickControl::keyPressEvent(event);
1156 QQuickRangeSliderNode *focusNode = d->first->handle()->hasActiveFocus()
1157 ? d->first : (d->second->handle()->hasActiveFocus() ? d->second :
nullptr);
1161 const qreal oldValue = focusNode->value();
1162 if (d->orientation == Qt::Horizontal) {
1163 if (event->key() == Qt::Key_Left) {
1164 focusNode->setPressed(
true);
1166 focusNode->increase();
1168 focusNode->decrease();
1170 }
else if (event->key() == Qt::Key_Right) {
1171 focusNode->setPressed(
true);
1173 focusNode->decrease();
1175 focusNode->increase();
1179 if (event->key() == Qt::Key_Up) {
1180 focusNode->setPressed(
true);
1181 focusNode->increase();
1183 }
else if (event->key() == Qt::Key_Down) {
1184 focusNode->setPressed(
true);
1185 focusNode->decrease();
1189 if (!qFuzzyCompare(focusNode->value(), oldValue))
1190 emit focusNode->moved();
1193void QQuickRangeSlider::hoverEnterEvent(QHoverEvent *event)
1195 Q_D(QQuickRangeSlider);
1196 QQuickControl::hoverEnterEvent(event);
1197 d->updateHover(event->position());
1201void QQuickRangeSlider::hoverMoveEvent(QHoverEvent *event)
1203 Q_D(QQuickRangeSlider);
1204 QQuickControl::hoverMoveEvent(event);
1205 d->updateHover(event->position());
1209void QQuickRangeSlider::hoverLeaveEvent(QHoverEvent *event)
1211 Q_D(QQuickRangeSlider);
1212 QQuickControl::hoverLeaveEvent(event);
1213 d->first->setHovered(
false);
1214 d->second->setHovered(
false);
1218void QQuickRangeSlider::keyReleaseEvent(QKeyEvent *event)
1220 Q_D(QQuickRangeSlider);
1221 QQuickControl::keyReleaseEvent(event);
1222 d->first->setPressed(
false);
1223 d->second->setPressed(
false);
1226void QQuickRangeSlider::mousePressEvent(QMouseEvent *event)
1228 Q_D(QQuickRangeSlider);
1229 QQuickControl::mousePressEvent(event);
1230 d->handleMove(event->position(), event->timestamp());
1231 setKeepMouseGrab(
true);
1234#if QT_CONFIG(quicktemplates2_multitouch)
1235void QQuickRangeSlider::touchEvent(QTouchEvent *event)
1237 Q_D(QQuickRangeSlider);
1238 switch (event->type()) {
1239 case QEvent::TouchUpdate:
1240 for (
const QTouchEvent::TouchPoint &point : event->points()) {
1241 if (!d->acceptTouch(point))
1244 switch (point.state()) {
1245 case QEventPoint::Pressed:
1246 d->handlePress(point.position(), event->timestamp());
1248 case QEventPoint::Updated:
1249 if (!keepTouchGrab()) {
1250 if (d->orientation == Qt::Horizontal) {
1251 setKeepTouchGrab(QQuickDeliveryAgentPrivate::dragOverThreshold(point.position().x() - point.pressPosition().x(),
1252 Qt::XAxis, point, qRound(d->touchDragThreshold)));
1254 setKeepTouchGrab(QQuickDeliveryAgentPrivate::dragOverThreshold(point.position().y() - point.pressPosition().y(),
1255 Qt::YAxis, point, qRound(d->touchDragThreshold)));
1258 if (keepTouchGrab())
1259 d->handleMove(point.position(), event->timestamp());
1261 case QEventPoint::Released:
1262 d->handleRelease(point.position(), event->timestamp());
1271 QQuickControl::touchEvent(event);
1277void QQuickRangeSlider::mirrorChange()
1279 Q_D(QQuickRangeSlider);
1280 QQuickControl::mirrorChange();
1281 emit d->first->visualPositionChanged();
1282 emit d->second->visualPositionChanged();
1285void QQuickRangeSlider::classBegin()
1287 Q_D(QQuickRangeSlider);
1288 QQuickControl::classBegin();
1290 QQmlContext *context = qmlContext(
this);
1292 QQmlEngine::setContextForObject(d->first, context);
1293 QQmlEngine::setContextForObject(d->second, context);
1297void QQuickRangeSlider::componentComplete()
1299 Q_D(QQuickRangeSlider);
1300 QQuickRangeSliderNodePrivate *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
1301 QQuickRangeSliderNodePrivate *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
1302 firstPrivate->executeHandle(
true);
1303 secondPrivate->executeHandle(
true);
1305 QQuickControl::componentComplete();
1307 if (firstPrivate->isPendingValue || secondPrivate->isPendingValue
1308 || !qFuzzyCompare(d->from, defaultFrom) || !qFuzzyCompare(d->to, defaultTo)) {
1312 setValues(firstPrivate->isPendingValue ? firstPrivate->pendingValue : firstPrivate->value,
1313 secondPrivate->isPendingValue ? secondPrivate->pendingValue : secondPrivate->value);
1315 firstPrivate->pendingValue = 0;
1316 firstPrivate->isPendingValue =
false;
1317 secondPrivate->pendingValue = 0;
1318 secondPrivate->isPendingValue =
false;
1324 firstPrivate->updatePosition();
1325 secondPrivate->updatePosition();
1328 d->updateAllValuesAreInteger();
1332
1333
1334
1335
1336
1337
1340
1341
1342
1343
1344
1345
1348
1349
1350
1351
1352
1353
1356
1357
1358
1359
1360
1361
1363#if QT_CONFIG(accessibility)
1364QAccessible::Role QQuickRangeSlider::accessibleRole()
const
1366 return QAccessible::Slider;
1372#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)
void updateAllValuesAreInteger()
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 * pressedNode(int touchId=-1) const
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
Combined button and popup list for selecting options.
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)