25
25
enabled: target && !target.fullscreen
27
28
// to be set from outside
28
29
property Item target // appDelegate
30
property alias stageWidth: moveHandler.stageWidth
31
property alias stageHeight: moveHandler.stageHeight
30
33
// to be read from outside
31
34
readonly property alias overlayShown: overlay.visible
35
readonly property alias dragging: priv.dragging
37
signal fakeMaximizeAnimationRequested(real amount)
38
signal fakeMaximizeLeftAnimationRequested(real amount)
39
signal fakeMaximizeRightAnimationRequested(real amount)
40
signal fakeMaximizeTopLeftAnimationRequested(real amount)
41
signal fakeMaximizeTopRightAnimationRequested(real amount)
42
signal fakeMaximizeBottomLeftAnimationRequested(real amount)
43
signal fakeMaximizeBottomRightAnimationRequested(real amount)
44
signal stopFakeAnimation()
51
65
readonly property bool recognizedDrag: recognizedPress && dragging
52
66
onRecognizedDragChanged: {
53
67
if (recognizedDrag) {
54
priv.handlePressedChanged(true, tp.x, tp.y);
55
} else if (!moveHandler.containsPress) { // prevent interfering with the central piece drag/move
56
priv.dragging = false;
68
moveHandler.handlePressedChanged(true, Qt.LeftButton, tp.x, tp.y);
69
} else if (!mouseArea.containsPress) { // prevent interfering with the central piece drag/move
70
moveHandler.handlePressedChanged(false, Qt.LeftButton);
72
moveHandler.handleReleased(true);
60
76
readonly property point tp: recognizedPress ? Qt.point(touchPoints[0].x, touchPoints[0].y) : Qt.point(-1, -1)
62
78
if (recognizedDrag) {
63
priv.handlePositionChanged(tp.x, tp.y);
79
moveHandler.handlePositionChanged(tp, priv.getSensingPoints());
72
repeat: priv.dragging || (priv.resizeArea && priv.resizeArea.dragging)
77
property real distanceX
78
property real distanceY
79
property bool dragging
81
93
readonly property var resizeArea: root.target && root.target.resizeArea ? root.target.resizeArea : null
94
readonly property bool ensureWindow: root.target.state == "normal" || root.target.state == "restored"
95
readonly property bool dragging: moveHandler.dragging || (resizeArea && resizeArea.dragging)
83
function handlePressedChanged(pressed, mouseX, mouseY) {
85
var pos = mapToItem(root.target, mouseX, mouseY);
86
priv.distanceX = pos.x;
87
priv.distanceY = pos.y;
90
priv.dragging = false;
97
function getSensingPoints() {
100
for (var i = 0; i < gestureArea.touchPoints.length; i++) {
101
var pt = gestureArea.touchPoints[i];
94
function handlePositionChanged(mouseX, mouseY) {
96
var pos = mapToItem(root.target.parent, mouseX, mouseY);
97
root.target.requestedX = Math.round(pos.x - priv.distanceX);
98
root.target.requestedY = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
106
var leftmost = Math.min.apply(Math, xPoints);
107
var rightmost = Math.max.apply(Math, xPoints);
108
var topmost = Math.min.apply(Math, yPoints);
109
var bottommost = Math.max.apply(Math, yPoints);
112
left: mapToItem(target.parent, leftmost, (topmost+bottommost)/2),
113
top: mapToItem(target.parent, (leftmost+rightmost)/2, topmost),
114
right: mapToItem(target.parent, rightmost, (topmost+bottommost)/2),
115
topLeft: mapToItem(target.parent, leftmost, topmost),
116
topRight: mapToItem(target.parent, rightmost, topmost),
117
bottomLeft: mapToItem(target.parent, leftmost, bottommost),
118
bottomRight: mapToItem(target.parent, rightmost, bottommost)
148
visible: overlay.visible
152
onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
153
onPositionChanged: moveHandler.handlePositionChanged(mouse)
156
moveHandler.handleReleased();
130
visible: overlay.visible
133
cursorShape: priv.dragging ? Qt.ClosedHandCursor : (overlay.visible ? Qt.OpenHandCursor : Qt.ArrowCursor)
162
objectName: "moveHandler"
135
onPressedChanged: priv.handlePressedChanged(pressed, mouseX, mouseY)
136
onPositionChanged: priv.handlePositionChanged(mouseX, mouseY)
165
onFakeMaximizeAnimationRequested: root.fakeMaximizeAnimationRequested(amount)
166
onFakeMaximizeLeftAnimationRequested: root.fakeMaximizeLeftAnimationRequested(amount)
167
onFakeMaximizeRightAnimationRequested: root.fakeMaximizeRightAnimationRequested(amount)
168
onFakeMaximizeTopLeftAnimationRequested: root.fakeMaximizeTopLeftAnimationRequested(amount)
169
onFakeMaximizeTopRightAnimationRequested: root.fakeMaximizeTopRightAnimationRequested(amount)
170
onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(amount)
171
onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(amount)
172
onStopFakeAnimation: root.stopFakeAnimation()
157
193
ResizeGrip { // top left
158
194
anchors.horizontalCenter: parent.left
159
195
anchors.verticalCenter: parent.top
160
visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
196
visible: priv.ensureWindow || target.maximizedBottomRight
161
197
resizeTarget: priv.resizeArea
165
201
anchors.horizontalCenter: parent.horizontalCenter
166
202
anchors.verticalCenter: parent.top
168
visible: target && !overlay.anyMaximized && !target.maximizedVertically
204
visible: priv.ensureWindow || target.maximizedHorizontally || target.maximizedBottomLeft || target.maximizedBottomRight
169
205
resizeTarget: priv.resizeArea
173
209
anchors.horizontalCenter: parent.right
174
210
anchors.verticalCenter: parent.top
176
visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
212
visible: priv.ensureWindow || target.maximizedBottomLeft
177
213
resizeTarget: priv.resizeArea
181
217
anchors.horizontalCenter: parent.right
182
218
anchors.verticalCenter: parent.verticalCenter
184
visible: target && !target.maximizedRight && !target.maximized && !target.maximizedHorizontally
220
visible: priv.ensureWindow || target.maximizedVertically || target.maximizedLeft ||
221
target.maximizedTopLeft || target.maximizedBottomLeft
185
222
resizeTarget: priv.resizeArea
188
225
ResizeGrip { // bottom right
189
226
anchors.horizontalCenter: parent.right
190
227
anchors.verticalCenter: parent.bottom
191
visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
228
visible: priv.ensureWindow || target.maximizedTopLeft
192
229
resizeTarget: priv.resizeArea
196
233
anchors.horizontalCenter: parent.horizontalCenter
197
234
anchors.verticalCenter: parent.bottom
199
visible: target && !overlay.anyMaximized && !target.maximizedVertically
236
visible: priv.ensureWindow || target.maximizedHorizontally || target.maximizedTopLeft || target.maximizedTopRight
200
237
resizeTarget: priv.resizeArea
204
241
anchors.horizontalCenter: parent.left
205
242
anchors.verticalCenter: parent.bottom
207
visible: target && !overlay.anyMaximized && !target.maximizedHorizontally && !target.maximizedVertically
244
visible: priv.ensureWindow || target.maximizedTopRight
208
245
resizeTarget: priv.resizeArea
212
249
anchors.horizontalCenter: parent.left
213
250
anchors.verticalCenter: parent.verticalCenter
215
visible: target && !target.maximizedLeft && !target.maximized && !target.maximizedHorizontally
252
visible: priv.ensureWindow || target.maximizedVertically || target.maximizedRight ||
253
target.maximizedTopRight || target.maximizedBottomRight
216
254
resizeTarget: priv.resizeArea