diff --git a/applets/kickoff/package/contents/ui/FavoritesView.qml b/applets/kickoff/package/contents/ui/FavoritesView.qml --- a/applets/kickoff/package/contents/ui/FavoritesView.qml +++ b/applets/kickoff/package/contents/ui/FavoritesView.qml @@ -68,8 +68,6 @@ } DropArea { - property int startRow: -1 - anchors.fill: parent enabled: plasmoid.immutability !== PlasmaCore.Types.SystemImmutable @@ -91,9 +89,15 @@ } } - onDragEnter: { - syncTarget(event); - startRow = favoritesView.currentIndex; + onDragEnter: syncTarget(event) + + onDragLeave: { + // restore favorites order if the user + // drags the item outside (e.g. to the desktop) + var source = kickoff.dragSource; + if (isChildOf(source, favoritesView)) { + favoritesView.model.moveRow(source.itemIndex, kickoff.dragStartRow); + } } onDragMove: syncTarget(event) diff --git a/applets/kickoff/package/contents/ui/Kickoff.qml b/applets/kickoff/package/contents/ui/Kickoff.qml --- a/applets/kickoff/package/contents/ui/Kickoff.qml +++ b/applets/kickoff/package/contents/ui/Kickoff.qml @@ -128,6 +128,7 @@ } property Item dragSource: null + property int dragStartRow: -1 Kicker.ProcessRunner { id: processRunner; diff --git a/applets/kickoff/package/contents/ui/KickoffListView.qml b/applets/kickoff/package/contents/ui/KickoffListView.qml --- a/applets/kickoff/package/contents/ui/KickoffListView.qml +++ b/applets/kickoff/package/contents/ui/KickoffListView.qml @@ -165,6 +165,7 @@ if (pressed && pressX != -1 && pressed.url && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) { kickoff.dragSource = item; + kickoff.dragStartRow = item.itemIndex; dragHelper.startDrag(root, pressed.url, pressed.decoration); pressed = null; pressX = -1;