on xenial help sign in
delay move operations if the start dragging operation is running
691883cMichael Zanetti
Launcher/LauncherPanel.qml+30−4
@@ -121,6 +121,12 @@ Item {
121 property real realContentY: contentY - originY + topMargin
121 property real realContentY: contentY - originY + topMargin
122 property int realItemHeight: itemHeight + spacing
122 property int realItemHeight: itemHeight + spacing
123
123
124+ // In case the start dragging transition is running, we need to delay the
125+ // move because the displaced transition would clash with it and cause items
126+ // to be moved to wrong places
127+ property bool draggingTransitionRunning: false
128+ property int scheduledMoveTo: -1
129+
124 displaced: Transition {
130 displaced: Transition {
125 NumberAnimation { properties: "x,y"; duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
131 NumberAnimation { properties: "x,y"; duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
126 }
132 }
@@ -202,10 +208,26 @@ Item {
202 UbuntuNumberAnimation { properties: "angle,offset" }
208 UbuntuNumberAnimation { properties: "angle,offset" }
203 },
209 },
204 Transition {
210 Transition {
211+ id: draggingTransition
205 from: "selected"
212 from: "selected"
206 to: "dragging"
213 to: "dragging"
214+ SequentialAnimation {
215+ PropertyAction { target: launcherListView; property: "draggingTransitionRunning"; value: true }
216+ ParallelAnimation {
207− UbuntuNumberAnimation { properties: "height" }
217+ UbuntuNumberAnimation { properties: "height" }
208− NumberAnimation { target: dropIndicator; properties: "opacity"; duration: UbuntuAnimation.FastDuration }
218+ NumberAnimation { target: dropIndicator; properties: "opacity"; duration: UbuntuAnimation.FastDuration }
219+ }
220+ ScriptAction {
221+ script: {
222+ if (launcherListView.scheduledMoveTo > -1) {
223+ launcherListView.model.move(dndArea.draggedIndex, launcherListView.scheduledMoveTo)
224+ dndArea.draggedIndex = launcherListView.scheduledMoveTo
225+ launcherListView.scheduledMoveTo = -1
226+ }
227+ }
228+ }
229+ PropertyAction { target: launcherListView; property: "draggingTransitionRunning"; value: false }
230+ }
209 },
231 },
210 Transition {
232 Transition {
211 from: "dragging"
233 from: "dragging"
@@ -387,8 +409,12 @@ Item {
387 }
409 }
388
410
389 if (newIndex >= 0 && newIndex < launcherListView.count) {
411 if (newIndex >= 0 && newIndex < launcherListView.count) {
412+ if (launcherListView.draggingTransitionRunning) {
413+ launcherListView.scheduledMoveTo = newIndex
414+ } else {
390− launcherListView.model.move(draggedIndex, newIndex)
415+ launcherListView.model.move(draggedIndex, newIndex)
391− draggedIndex = newIndex
416+ draggedIndex = newIndex
417+ }
392 }
418 }
393 }
419 }
394 }
420 }
tests/qmltests/Launcher/tst_Launcher.qml+33−13
@@ -277,8 +277,9 @@ Item {
277
277
278 function test_dragndrop_data() {
278 function test_dragndrop_data() {
279 return [
279 return [
280− {tag: "startDrag", fullDrag: false},
280+ {tag: "startDrag", fullDrag: false },
281+ {tag: "fullDrag horizontal", fullDrag: true, orientation: ListView.Horizontal },
281− {tag: "fullDrag", fullDrag: true},
282+ {tag: "fullDrag vertical", fullDrag: true, orientation: ListView.Vertical },
282 ];
283 ];
283 }
284 }
284
285
@@ -288,8 +289,8 @@ Item {
288 var item0 = findChild(launcher, "launcherDelegate0")
289 var item0 = findChild(launcher, "launcherDelegate0")
289 var fakeDragItem = findChild(launcher, "fakeDragItem")
290 var fakeDragItem = findChild(launcher, "fakeDragItem")
290 var initialItemHeight = draggedItem.height
291 var initialItemHeight = draggedItem.height
291− var item5Name = LauncherModel.get(5).iconName
292+ var item5 = LauncherModel.get(5).appId
292− var item4Name = LauncherModel.get(4).iconName
293+ var item4 = LauncherModel.get(4).appId
293
294
294 // Initial state
295 // Initial state
295 compare(draggedItem.itemOpacity, 1, "Item's opacity is not 1 at beginning")
296 compare(draggedItem.itemOpacity, 1, "Item's opacity is not 1 at beginning")
@@ -297,28 +298,43 @@ Item {
297 tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 0)
298 tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 0)
298
299
299 // Doing longpress
300 // Doing longpress
301+ var currentMouseX = draggedItem.width / 2
300− mousePress(draggedItem, draggedItem.width / 2, draggedItem.height / 2)
302+ var currentMouseY = draggedItem.height / 2
303+ mousePress(draggedItem, currentMouseX, currentMouseY)
301 // DraggedItem needs to hide and fakeDragItem become visible
304 // DraggedItem needs to hide and fakeDragItem become visible
302 tryCompare(draggedItem, "itemOpacity", 0)
305 tryCompare(draggedItem, "itemOpacity", 0)
303 tryCompare(fakeDragItem, "visible", true)
306 tryCompare(fakeDragItem, "visible", true)
304
307
305 // Dragging a bit (> 1.5 gu)
308 // Dragging a bit (> 1.5 gu)
306− mouseMove(draggedItem, -units.gu(2), draggedItem.height / 2)
309+ currentMouseX -= units.gu(2)
310+ mouseMove(draggedItem, currentMouseX, currentMouseY)
307 // Other items need to expand and become 0.6 opaque
311 // Other items need to expand and become 0.6 opaque
308 tryCompare(item0, "angle", 0)
312 tryCompare(item0, "angle", 0)
309 tryCompare(item0, "itemOpacity", 0.6)
313 tryCompare(item0, "itemOpacity", 0.6)
310
314
311 if (data.fullDrag) {
315 if (data.fullDrag) {
312 // Dragging a bit more
316 // Dragging a bit more
317+ if (data.orientation == ListView.Horizontal) {
318+ currentMouseX -= units.gu(15)
319+ mouseMove(draggedItem, currentMouseX, currentMouseY, 100)
320+
321+ tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 1)
313− mouseMove(draggedItem, -units.gu(15), draggedItem.height / 2, 100)
322+ tryCompare(draggedItem, "height", units.gu(1))
323+
324+ // Dragging downwards. Item needs to move in the model
325+ currentMouseY -= initialItemHeight * 1.5
326+ mouseMove(draggedItem, currentMouseX, currentMouseY)
327+ } else if (data.orientation == ListView.Vertical) {
328+ currentMouseY -= initialItemHeight * 1.5
329+ mouseMove(draggedItem, currentMouseX, currentMouseY, 100)
330+
314− tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 1)
331+ tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 1)
315− tryCompare(draggedItem, "height", units.gu(1))
332+ tryCompare(draggedItem, "height", units.gu(1))
333+ }
316
334
317− // Dragging downwards. Item needs to move in the model
318− mouseMove(draggedItem, -units.gu(15), -initialItemHeight)
319 waitForRendering(draggedItem)
335 waitForRendering(draggedItem)
320− compare(LauncherModel.get(5).iconName, item4Name)
336+ compare(LauncherModel.get(5).appId, item4)
321− compare(LauncherModel.get(5).iconName, item5Name)
337+ compare(LauncherModel.get(4).appId, item5)
322 }
338 }
323
339
324 // Releasing and checking if initial values are restored
340 // Releasing and checking if initial values are restored
@@ -326,6 +342,10 @@ Item {
326 tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 0)
342 tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 0)
327 tryCompare(draggedItem, "itemOpacity", 1)
343 tryCompare(draggedItem, "itemOpacity", 1)
328 tryCompare(fakeDragItem, "visible", false)
344 tryCompare(fakeDragItem, "visible", false)
345+
346+ // Click somewhere in the empty space to make it hide in case it isn't
347+ mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
348+ revealer.waitUntilLauncherDisappears();
329 }
349 }
330
350
331 function test_quicklist_dismiss() {
351 function test_quicklist_dismiss() {