on xenial help sign in
Added DirectionalDragArea.pressed property
427d712Daniel d'Andrada
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+7−1
@@ -176,6 +176,11 @@ bool DirectionalDragArea::dragging() const
176 return d->status == DirectionalDragAreaPrivate::Recognized;
176 return d->status == DirectionalDragAreaPrivate::Recognized;
177}
177}
178
178
179+bool DirectionalDragArea::pressed() const
180+{
181+ return d->status != DirectionalDragAreaPrivate::WaitingForTouch;
182+}
183+
179bool DirectionalDragArea::immediateRecognition() const
184bool DirectionalDragArea::immediateRecognition() const
180{
185{
181 return d->immediateRecognition;
186 return d->immediateRecognition;
@@ -378,7 +383,6 @@ void DirectionalDragAreaPrivate::touchEvent_absent(QTouchEvent *event)
378 allGood = false;
383 allGood = false;
379 } else {
384 } else {
380 // that's our candidate
385 // that's our candidate
381− touchId = touchPoint.id();
382 newTouchPoint = &touchPoint;
386 newTouchPoint = &touchPoint;
383 }
387 }
384 }
388 }
@@ -595,9 +599,11 @@ void DirectionalDragAreaPrivate::setStatus(Status newStatus)
595 if (oldStatus == Recognized) {
599 if (oldStatus == Recognized) {
596 Q_EMIT q->draggingChanged(false);
600 Q_EMIT q->draggingChanged(false);
597 }
601 }
602+ Q_EMIT q->pressedChanged(false);
598 break;
603 break;
599 case Undecided:
604 case Undecided:
600 recognitionTimer->start();
605 recognitionTimer->start();
606+ Q_EMIT q->pressedChanged(true);
601 break;
607 break;
602 case Recognized:
608 case Recognized:
603 Q_EMIT q->draggingChanged(true);
609 Q_EMIT q->draggingChanged(true);
plugins/Ubuntu/Gestures/DirectionalDragArea.h+6
@@ -64,6 +64,9 @@ class UBUNTUGESTURESQML_EXPORT DirectionalDragArea : public QQuickItem {
64 // Whether a drag gesture is taking place
64 // Whether a drag gesture is taking place
65 Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged)
65 Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged)
66
66
67+ // Whether the drag area is pressed.
68+ Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
69+
67 // Whether a gesture should be Recognized as soon a touch lands on the area.
70 // Whether a gesture should be Recognized as soon a touch lands on the area.
68 // With this property enabled it will work pretty much like a MultiPointTouchArea,
71 // With this property enabled it will work pretty much like a MultiPointTouchArea,
69 // just with a different API.
72 // just with a different API.
@@ -92,6 +95,8 @@ public:
92
95
93 bool dragging() const;
96 bool dragging() const;
94
97
98+ bool pressed() const;
99+
95 bool immediateRecognition() const;
100 bool immediateRecognition() const;
96 void setImmediateRecognition(bool enabled);
101 void setImmediateRecognition(bool enabled);
97
102
@@ -110,6 +115,7 @@ public:
110Q_SIGNALS:
115Q_SIGNALS:
111 void directionChanged(Direction::Type direction);
116 void directionChanged(Direction::Type direction);
112 void draggingChanged(bool value);
117 void draggingChanged(bool value);
118+ void pressedChanged(bool value);
113 void distanceChanged(qreal value);
119 void distanceChanged(qreal value);
114 void sceneDistanceChanged(qreal value);
120 void sceneDistanceChanged(qreal value);
115 void touchXChanged(qreal value);
121 void touchXChanged(qreal value);
qml/Greeter/CoverPage.qml+2−2
@@ -135,8 +135,8 @@ Showable {
135 enabled: root.draggable
135 enabled: root.draggable
136 direction: Direction.Horizontal
136 direction: Direction.Horizontal
137
137
138− onDraggingChanged: {
138+ onPressedChanged: {
139− if (dragging) {
139+ if (pressed) {
140 root.tease();
140 root.tease();
141 showLabelAnimation.start();
141 showLabelAnimation.start();
142 }
142 }
qml/Panel/IndicatorsMenu.qml+2−2
@@ -183,8 +183,8 @@ Showable {
183 autoCompleteDragThreshold: maxTotalDragDistance / 2
183 autoCompleteDragThreshold: maxTotalDragDistance / 2
184 stretch: true
184 stretch: true
185
185
186− onDraggingChanged: {
186+ onPressedChanged: {
187− if (dragging) {
187+ if (pressed) {
188 touchPressTime = new Date().getTime();
188 touchPressTime = new Date().getTime();
189 } else {
189 } else {
190 var touchReleaseTime = new Date().getTime();
190 var touchReleaseTime = new Date().getTime();