on xenial help sign in
Added DirectionalDragArea.pressed property
commit427d712a90cbae31b763791941b1394f55930417 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 15 Apr 2015, 17:02 (12 years ago) parent3abbbd7
4 files changed+17−5
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+7−1 plugins/Ubuntu/Gestures/DirectionalDragArea.h+6 qml/Greeter/CoverPage.qml+2−2 qml/Panel/IndicatorsMenu.qml+2−2
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+7−1
@@ -176,6 +176,11 @@ bool DirectionalDragArea::dragging() const
176176 return d->status == DirectionalDragAreaPrivate::Recognized;
177177}
178178
179+bool DirectionalDragArea::pressed() const
180+{
181+ return d->status != DirectionalDragAreaPrivate::WaitingForTouch;
182+}
183+
179184bool DirectionalDragArea::immediateRecognition() const
180185{
181186 return d->immediateRecognition;
@@ -378,7 +383,6 @@ void DirectionalDragAreaPrivate::touchEvent_absent(QTouchEvent *event)
378383 allGood = false;
379384 } else {
380385 // that's our candidate
381− touchId = touchPoint.id();
382386 newTouchPoint = &touchPoint;
383387 }
384388 }
@@ -595,9 +599,11 @@ void DirectionalDragAreaPrivate::setStatus(Status newStatus)
595599 if (oldStatus == Recognized) {
596600 Q_EMIT q->draggingChanged(false);
597601 }
602+ Q_EMIT q->pressedChanged(false);
598603 break;
599604 case Undecided:
600605 recognitionTimer->start();
606+ Q_EMIT q->pressedChanged(true);
601607 break;
602608 case Recognized:
603609 Q_EMIT q->draggingChanged(true);
plugins/Ubuntu/Gestures/DirectionalDragArea.h+6
@@ -64,6 +64,9 @@ class UBUNTUGESTURESQML_EXPORT DirectionalDragArea : public QQuickItem {
6464 // Whether a drag gesture is taking place
6565 Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged)
6666
67+ // Whether the drag area is pressed.
68+ Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
69+
6770 // Whether a gesture should be Recognized as soon a touch lands on the area.
6871 // With this property enabled it will work pretty much like a MultiPointTouchArea,
6972 // just with a different API.
@@ -92,6 +95,8 @@ public:
9295
9396 bool dragging() const;
9497
98+ bool pressed() const;
99+
95100 bool immediateRecognition() const;
96101 void setImmediateRecognition(bool enabled);
97102
@@ -110,6 +115,7 @@ public:
110115Q_SIGNALS:
111116 void directionChanged(Direction::Type direction);
112117 void draggingChanged(bool value);
118+ void pressedChanged(bool value);
113119 void distanceChanged(qreal value);
114120 void sceneDistanceChanged(qreal value);
115121 void touchXChanged(qreal value);
qml/Greeter/CoverPage.qml+2−2
@@ -135,8 +135,8 @@ Showable {
135135 enabled: root.draggable
136136 direction: Direction.Horizontal
137137
138− onDraggingChanged: {
139− if (dragging) {
138+ onPressedChanged: {
139+ if (pressed) {
140140 root.tease();
141141 showLabelAnimation.start();
142142 }
qml/Panel/IndicatorsMenu.qml+2−2
@@ -183,8 +183,8 @@ Showable {
183183 autoCompleteDragThreshold: maxTotalDragDistance / 2
184184 stretch: true
185185
186− onDraggingChanged: {
187− if (dragging) {
186+ onPressedChanged: {
187+ if (pressed) {
188188 touchPressTime = new Date().getTime();
189189 } else {
190190 var touchReleaseTime = new Date().getTime();