on xenial help sign in
implement moving by dragging around
9035e45Lukáš Tinkl
qml/Stages/TabletSideStageTouchGesture.qml+3
@@ -106,6 +106,9 @@ TouchGestureArea {
106 }
106 }
107
107
108 onDragStarted: {
108 onDragStarted: {
109+ if (!dragComponent)
110+ return;
111+
109 if (dragComponentProperties) {
112 if (dragComponentProperties) {
110 priv.dragObject = dragComponent.createObject(root, dragComponentProperties);
113 priv.dragObject = dragComponent.createObject(root, dragComponentProperties);
111 } else {
114 } else {
qml/Stages/TabletStage.qml−1
@@ -974,7 +974,6 @@ AbstractStage {
974 id: triGestureArea
974 id: triGestureArea
975 anchors.fill: parent
975 anchors.fill: parent
976 enabled: priv.sideStageEnabled && !spreadView.active
976 enabled: priv.sideStageEnabled && !spreadView.active
977− property var dragObject: null
978 property string appId: ""
977 property string appId: ""
979 dragComponent: dragComponent
978 dragComponent: dragComponent
980 dragComponentProperties: { "appId": appId }
979 dragComponentProperties: { "appId": appId }
qml/Stages/WindowControlsOverlay.qml+36−3
@@ -17,17 +17,19 @@
17import QtQuick 2.4
17import QtQuick 2.4
18import Ubuntu.Components 1.3
18import Ubuntu.Components 1.3
19import Ubuntu.Gestures 0.1
19import Ubuntu.Gestures 0.1
20+import "../Components/PanelState"
20
21
21Item {
22Item {
23+ id: root
22 // to be set from outside
24 // to be set from outside
23 property Item target // appDelegate
25 property Item target // appDelegate
24 property int borderThickness
26 property int borderThickness
25
27
26 TabletSideStageTouchGesture {
28 TabletSideStageTouchGesture {
27 id: gestureArea
29 id: gestureArea
30+ anchors.fill: parent
28 minimumTouchPoints: 2
31 minimumTouchPoints: 2
29 maximumTouchPoints: 2
32 maximumTouchPoints: 2
30− anchors.fill: parent
31
33
32 onRecognisedPressChanged: {
34 onRecognisedPressChanged: {
33 print("Press recognized:", recognisedPress)
35 print("Press recognized:", recognisedPress)
@@ -38,9 +40,8 @@ Item {
38 onRecognisedDragChanged: {
40 onRecognisedDragChanged: {
39 print("Drag recognized:", recognisedDrag)
41 print("Drag recognized:", recognisedDrag)
40 }
42 }
41− onDragStarted: print("Drag started")
43+ onPressed: print("Pressed:", x, y)
42 onDropped: print("Dropped")
44 onDropped: print("Dropped")
43− onCancelled: print("Cancelled")
44 }
45 }
45
46
46 Timer { // dismiss timer
47 Timer { // dismiss timer
@@ -53,6 +54,38 @@ Item {
53 onClicked: overlayTimer.stop()
54 onClicked: overlayTimer.stop()
54 }
55 }
55
56
57+ QtObject {
58+ id: priv
59+ property real distanceX
60+ property real distanceY
61+ property bool dragging
62+ }
63+
64+ MouseArea {
65+ anchors.fill: parent
66+ visible: overlay.visible
67+ enabled: visible
68+
69+ onPressedChanged: {
70+ if (pressed) {
71+ var pos = mapToItem(root.target, mouseX, mouseY);
72+ priv.distanceX = pos.x;
73+ priv.distanceY = pos.y;
74+ priv.dragging = true;
75+ } else {
76+ priv.dragging = false;
77+ }
78+ }
79+
80+ onPositionChanged: {
81+ if (priv.dragging) {
82+ var pos = mapToItem(root.target.parent, mouseX, mouseY);
83+ root.target.x = pos.x - priv.distanceX;
84+ root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
85+ }
86+ }
87+ }
88+
56 Item {
89 Item {
57 id: overlay
90 id: overlay
58 anchors.fill: parent
91 anchors.fill: parent