diff --git a/containments/homescreen2/package/contents/ui/launcher/Delegate.qml b/containments/homescreen2/package/contents/ui/launcher/Delegate.qml index 67d458e6..385d02f0 100644 --- a/containments/homescreen2/package/contents/ui/launcher/Delegate.qml +++ b/containments/homescreen2/package/contents/ui/launcher/Delegate.qml @@ -43,7 +43,20 @@ ContainmentLayoutManager.ItemContainer { opacity: dragging ? 0.4 : 1 - editModeCondition: model.ApplicationOnDesktopRole ? ContainmentLayoutManager.ItemContainer.AfterPressAndHold: ContainmentLayoutManager.ItemContainer.Manual + editModeCondition: ContainmentLayoutManager.ItemContainer.AfterPressAndHold//model.ApplicationOnDesktopRole ? ContainmentLayoutManager.ItemContainer.AfterPressAndHold: ContainmentLayoutManager.ItemContainer.Manual + onEditModeChanged: {//FIXME: remove + plasmoid.editMode = editMode + } + onDragActiveChanged: { + if (dragActive) { + return; + } + + plasmoid.editMode = false; + editMode = false; + launcher.forceLayout(); + favoriteStrip.forceLayout(); + } onDraggingChanged: { if (dragging) { @@ -59,9 +72,36 @@ ContainmentLayoutManager.ItemContainer { } } - contentItem: MouseArea { - drag.target: dragging ? dragDelegate : null + onUserDrag: { + // newPosition + var newRow = 0; + // Put it in the favorites strip + if (favoriteStrip.contains(favoriteStrip.mapFromItem(delegate, dragCenter.x, dragCenter.y))) { + var pos = favoriteStrip.mapFromItem(delegate, 0, 0); + newRow = Math.floor((pos.x + dragCenter.x) / delegate.width); + + // Put it on desktop + } else if (appletsLayout.contains(appletsLayout.mapFromItem(delegate, dragCenter.x, dragCenter.y))) { + var pos = appletsLayout.mapFromItem(delegate, 0, 0); + plasmoid.nativeInterface.applicationListModel.setDesktopItem(index, true); + delegate.x = pos.x + delegate.y = pos.y + return; + + // Put it in the general view + } else { + newRow = Math.round(applicationsFlow.width / delegate.width) * Math.floor((delegate.y + dragCenter.y) / delegate.height) + Math.floor((delegate.x + dragCenter.x) / delegate.width) + favoriteStrip.count; + } + + plasmoid.nativeInterface.applicationListModel.setDesktopItem(index, false); + + plasmoid.nativeInterface.applicationListModel.moveItem(modelData.index, newRow); + + //delegate.x = newPosition.x; + } + + contentItem: MouseArea { onClicked: { if (modelData.ApplicationStartupNotifyRole) { clickFedbackAnimation.target = delegate; @@ -71,45 +111,6 @@ ContainmentLayoutManager.ItemContainer { } plasmoid.nativeInterface.applicationListModel.runApplication(modelData.ApplicationStorageIdRole); } - - onPressAndHold: { - if (model.ApplicationOnDesktopRole) { - mouse.accepted = false - return - } - delegate.dragging = true; - } - - onReleased: { - delegate.dragging = false; - - } - - onCanceled: delegate.dragging = false; - - onPositionChanged: { - if (!dragging || !dragDelegate) { - return; - } - - var newRow = 0; - - // Put it in the favorites strip - if (favoriteStrip.contains(favoriteStrip.mapFromItem(dragDelegate, dragDelegate.width/2, dragDelegate.height/2))) { - newRow = Math.floor((dragDelegate.x + dragDelegate.width/2) / dragDelegate.width); - // Put it on desktop - } else if (appletsLayout.contains(appletsLayout.mapFromItem(dragDelegate, dragDelegate.width/2, dragDelegate.height/2))) { - plasmoid.nativeInterface.applicationListModel.setDesktopItem(index, true); - return; - // Put it in the general view - } else { - newRow = Math.round(applicationsFlow.width / dragDelegate.width) * Math.floor((dragDelegate.y + dragDelegate.height/2) / dragDelegate.height) + Math.floor((dragDelegate.x + dragDelegate.width/2) / dragDelegate.width) + favoriteStrip.count; - } - - plasmoid.nativeInterface.applicationListModel.setDesktopItem(index, false); - - plasmoid.nativeInterface.applicationListModel.moveItem(modelData.index, newRow); - } ColumnLayout { anchors.fill: parent diff --git a/containments/homescreen2/package/contents/ui/launcher/LauncherGrid.qml b/containments/homescreen2/package/contents/ui/launcher/LauncherGrid.qml index 727af733..9d6c8f6c 100644 --- a/containments/homescreen2/package/contents/ui/launcher/LauncherGrid.qml +++ b/containments/homescreen2/package/contents/ui/launcher/LauncherGrid.qml @@ -30,6 +30,9 @@ import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutM Controls.Control { id: root + function forceLayout() { + applicationsFlow.forceLayout(); + } readonly property bool dragging: applicationsFlow.dragData property bool reorderingApps: false diff --git a/containments/homescreen2/package/contents/ui/main.qml b/containments/homescreen2/package/contents/ui/main.qml index 5ccdbd78..10bb8643 100644 --- a/containments/homescreen2/package/contents/ui/main.qml +++ b/containments/homescreen2/package/contents/ui/main.qml @@ -59,7 +59,7 @@ Text { bottomMargin: favoriteStrip.height contentWidth: width contentHeight: flickableContents.height - interactive: !plasmoid.editMode + interactive: !plasmoid.editMode && !launcher.dragging ColumnLayout { id: flickableContents