mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-27 14:33:08 +00:00
fix dragging to appletslayout
still a crash on the other way around
This commit is contained in:
parent
8c1b75a777
commit
0d78a4e1d7
2 changed files with 182 additions and 161 deletions
|
|
@ -46,57 +46,25 @@ ContainmentLayoutManager.ItemContainer {
|
||||||
property real dragCenterX
|
property real dragCenterX
|
||||||
property real dragCenterY
|
property real dragCenterY
|
||||||
|
|
||||||
editModeCondition: ContainmentLayoutManager.ItemContainer.AfterPressAndHold//model.ApplicationOnDesktopRole ? ContainmentLayoutManager.ItemContainer.AfterPressAndHold: ContainmentLayoutManager.ItemContainer.Manual
|
editModeCondition: ContainmentLayoutManager.ItemContainer.AfterPressAndHold
|
||||||
onEditModeChanged: {//FIXME: remove
|
onEditModeChanged: {//FIXME: remove
|
||||||
plasmoid.editMode = editMode
|
plasmoid.editMode = editMode
|
||||||
}
|
}
|
||||||
onDragActiveChanged: {
|
onDragActiveChanged: {
|
||||||
if (dragActive) {
|
if (dragActive) {
|
||||||
// Must be 0, 0 as at this point dragCenterX and dragCenterY are on the drag before"
|
// Must be 0, 0 as at this point dragCenterX and dragCenterY are on the drag before"
|
||||||
launcherDragManager.showSpacer(delegate, 0, 0);
|
launcherDragManager.startDrag(delegate);
|
||||||
} else {
|
} else {
|
||||||
launcherDragManager.positionItem(delegate, dragCenterX, dragCenterY);
|
launcherDragManager.dropItem(delegate, dragCenterX, dragCenterY);
|
||||||
plasmoid.editMode = false;
|
plasmoid.editMode = false;
|
||||||
editMode = false;
|
editMode = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onUserDrag: {
|
onUserDrag: {
|
||||||
// newPosition
|
|
||||||
var newRow = 0;
|
|
||||||
|
|
||||||
dragCenterX = dragCenter.x;
|
dragCenterX = dragCenter.x;
|
||||||
dragCenterY = dragCenter.y;
|
dragCenterY = dragCenter.y;
|
||||||
var newContainer = launcherDragManager.containerForItem(delegate, dragCenter.x, dragCenter.y);
|
launcherDragManager.dragItem(delegate, index, dragCenter.x, dragCenter.y);
|
||||||
|
|
||||||
// Put it in the favorites strip
|
|
||||||
if (newContainer == favoriteStrip) {
|
|
||||||
var pos = favoriteStrip.mapFromItem(delegate, 0, 0);
|
|
||||||
newRow = Math.floor((pos.x + dragCenter.x) / delegate.width);
|
|
||||||
|
|
||||||
plasmoid.nativeInterface.applicationListModel.setLocation(index, ApplicationListModel.Favorites);
|
|
||||||
|
|
||||||
// Put it on desktop
|
|
||||||
} else if (newContainer == appletsLayout) {
|
|
||||||
var pos = appletsLayout.mapFromItem(delegate, 0, 0);
|
|
||||||
plasmoid.nativeInterface.applicationListModel.setLocation(index, ApplicationListModel.Desktop);
|
|
||||||
print("!!!!!!!!!!!!"+pos.x+" "+pos.y)
|
|
||||||
// delegate.x = pos.x
|
|
||||||
// delegate.y = pos.y
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Put it in the general view
|
|
||||||
} else {
|
|
||||||
newRow = Math.round(newContainer.flow.width / delegate.width) * Math.floor((delegate.y + dragCenter.y) / delegate.height) + Math.floor((delegate.x + dragCenter.x) / delegate.width) + favoriteStrip.count;
|
|
||||||
|
|
||||||
plasmoid.nativeInterface.applicationListModel.setLocation(index, ApplicationListModel.Grid);
|
|
||||||
}
|
|
||||||
|
|
||||||
launcherDragManager.showSpacer(delegate, dragCenter.x, dragCenter.y);
|
|
||||||
|
|
||||||
plasmoid.nativeInterface.applicationListModel.setDesktopItem(index, false);
|
|
||||||
|
|
||||||
plasmoid.nativeInterface.applicationListModel.moveItem(modelData.index, newRow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: MouseArea {
|
contentItem: MouseArea {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ import QtQuick 2.4
|
||||||
|
|
||||||
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
|
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
|
||||||
|
|
||||||
|
import org.kde.phone.homescreen 1.0
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
|
@ -33,6 +35,55 @@ QtObject {
|
||||||
height: width
|
height: width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function startDrag(item) {
|
||||||
|
internal.showSpacer(item, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dragItem(delegate, index, dragCenterX, dragCenterY) {
|
||||||
|
// newPosition
|
||||||
|
var newRow = 0;
|
||||||
|
|
||||||
|
var newContainer = internal.containerForItem(delegate, dragCenterX, dragCenterY);
|
||||||
|
|
||||||
|
// Put it in the favorites strip
|
||||||
|
if (newContainer == favoriteStrip) {
|
||||||
|
var pos = favoriteStrip.mapFromItem(delegate, 0, 0);
|
||||||
|
newRow = Math.floor((pos.x + dragCenterX) / delegate.width);
|
||||||
|
|
||||||
|
plasmoid.nativeInterface.applicationListModel.setLocation(index, ApplicationListModel.Favorites);
|
||||||
|
|
||||||
|
internal.showSpacer(delegate, dragCenterX, dragCenterY);
|
||||||
|
plasmoid.nativeInterface.applicationListModel.moveItem(modelData.index, newRow);
|
||||||
|
|
||||||
|
// Put it on desktop
|
||||||
|
} else if (newContainer == appletsLayout) {
|
||||||
|
var pos = appletsLayout.mapFromItem(delegate, 0, 0);
|
||||||
|
plasmoid.nativeInterface.applicationListModel.setLocation(index, ApplicationListModel.Desktop);
|
||||||
|
|
||||||
|
internal.showSpacer(delegate, dragCenterX, dragCenterY);
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Put it in the general view
|
||||||
|
} else {
|
||||||
|
newRow = Math.round(newContainer.flow.width / delegate.width) * Math.floor((delegate.y + dragCenterY) / delegate.height) + Math.floor((delegate.x + dragCenterX) / delegate.width) + favoriteStrip.count;
|
||||||
|
|
||||||
|
plasmoid.nativeInterface.applicationListModel.setLocation(index, ApplicationListModel.Grid);
|
||||||
|
|
||||||
|
internal.showSpacer(delegate, dragCenterX, dragCenterY);
|
||||||
|
plasmoid.nativeInterface.applicationListModel.moveItem(modelData.index, newRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal.showSpacer(delegate, dragCenterX, dragCenterY);
|
||||||
|
plasmoid.nativeInterface.applicationListModel.moveItem(modelData.index, newRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropItem(item, dragCenterX, dragCenterY) {
|
||||||
|
internal.positionItem(item, dragCenterX, dragCenterY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Those should never be accessed from outside
|
||||||
|
property QtObject __internal: QtObject {
|
||||||
|
id: internal
|
||||||
function raiseContainer(container) {
|
function raiseContainer(container) {
|
||||||
container.z = 1;
|
container.z = 1;
|
||||||
|
|
||||||
|
|
@ -60,7 +111,7 @@ QtObject {
|
||||||
|
|
||||||
function changeContainer(item, container) {
|
function changeContainer(item, container) {
|
||||||
var pos;
|
var pos;
|
||||||
print("$$$$$$$$"+container)
|
|
||||||
if (container == appletsLayout) {
|
if (container == appletsLayout) {
|
||||||
pos = container.mapFromItem(item, 0, 0);
|
pos = container.mapFromItem(item, 0, 0);
|
||||||
item.parent = container;
|
item.parent = container;
|
||||||
|
|
@ -75,7 +126,7 @@ print("$$$$$$$$"+container)
|
||||||
|
|
||||||
function putInContainerLayout(item, container) {
|
function putInContainerLayout(item, container) {
|
||||||
var pos = container.contentItem.mapFromItem(item, 0, 0);
|
var pos = container.contentItem.mapFromItem(item, 0, 0);
|
||||||
print("££££££££££££££££"+container)
|
|
||||||
if (container == appletsLayout) {
|
if (container == appletsLayout) {
|
||||||
item.parent = container;
|
item.parent = container;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -125,7 +176,7 @@ print("££££££££££££££££"+container)
|
||||||
var container = containerForItem(item, dragCenterX, dragCenterY);
|
var container = containerForItem(item, dragCenterX, dragCenterY);
|
||||||
|
|
||||||
raiseContainer(container);
|
raiseContainer(container);
|
||||||
print("&&&&&&&&&&&"+container)
|
|
||||||
if (container == appletsLayout) {
|
if (container == appletsLayout) {
|
||||||
spacer.visible = false;
|
spacer.visible = false;
|
||||||
changeContainer(item, container);
|
changeContainer(item, container);
|
||||||
|
|
@ -160,6 +211,7 @@ print("&&&&&&&&&&&"+container)
|
||||||
raiseContainer(container);
|
raiseContainer(container);
|
||||||
|
|
||||||
if (container == appletsLayout) {
|
if (container == appletsLayout) {
|
||||||
|
appletsLayout.positionItem(item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,6 +233,7 @@ print("&&&&&&&&&&&"+container)
|
||||||
plasmoid.nativeInterface.stackAfter(item, child);
|
plasmoid.nativeInterface.stackAfter(item, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue