some fixes to dragging behaviors

This commit is contained in:
Chris Cochrun 2022-09-16 06:57:03 -05:00
parent f74332d85d
commit 05c457be85
3 changed files with 29 additions and 13 deletions

View file

@ -37,7 +37,7 @@ ColumnLayout {
id: serviceDropEnd
Layout.fillHeight: true
Layout.fillWidth: true
onDropped: {
onDropped: (drag) => {
print("DROPPED AT END");
appendItem(dragItemTitle,
dragItemType,
@ -45,9 +45,21 @@ ColumnLayout {
dragItemBackgroundType,
dragItemText,
dragItemIndex);
dropHighlightLine.visible = false;
}
keys: ["library"]
onEntered: (drag) => {
if (drag.keys[0] === "library") {
dropHighlightLine.visible = true;
var lastItem = serviceItemList.itemAtIndex(serviceItemModel.rowCount() - 1);
dropHighlightLine.y = lastItem.y + lastItem.height;
}
}
/* onExited: dropHighlightLine.visible = false; */
ListView {
id: serviceItemList
anchors.fill: parent
@ -89,14 +101,17 @@ ColumnLayout {
id: serviceDrop
implicitWidth: serviceItemList.width
height: 50
/* enabled: false */
onEntered: (drag) => {
if (drag.keys[0] === "library") {
indexedHLRec.visible = true;
indexedHLRec.y = y - 2;
dropHighlightLine.visible = true;
dropHighlightLine.y = y - 2;
}
}
/* onExited: dropHighlightLine.visible = false; */
onDropped: (drag) => {
print("DROPPED IN ITEM AREA: " + drag.keys);
print(dragItemIndex + " " + index);
@ -114,7 +129,7 @@ ColumnLayout {
serviceItemList.moveToIndex);
serviceItemList.currentIndex = moveToIndex;
}
indexedHLRec.visible = false;
dropHighlightLine.visible = false;
}
keys: ["library","serviceitem"]
@ -277,7 +292,7 @@ ColumnLayout {
}
Rectangle {
id: indexedHLRec
id: dropHighlightLine
width: parent.width
height: 4
color: Kirigami.Theme.hoverColor
@ -286,8 +301,8 @@ ColumnLayout {
}
Canvas {
/* asynchronous: true; */
x: indexedHLRec.width - 8
y: indexedHLRec.y - 17
x: dropHighlightLine.width - 8
y: dropHighlightLine.y - 17
z: 1
width: 100; height: 100;
contextType: "2d"
@ -299,12 +314,12 @@ ColumnLayout {
ctx.path = tearDropPath;
ctx.fill();
}
visible: indexedHLRec.visible
visible: dropHighlightLine.visible
}
Path {
id: tearDropPath
startX: indexedHLRec.width
startY: indexedHLRec.y + 4
startX: dropHighlightLine.width
startY: dropHighlightLine.y + 4
PathSvg {
path: "M15 3
Q16.5 6.8 25 18
@ -374,7 +389,4 @@ ColumnLayout {
totalServiceItems++;
}
function changeItem() {
serviceItemList.currentIndex = currentServiceItem;
}
}

View file

@ -218,12 +218,14 @@ Item {
dragItemType = "song";
dragItemBackgroundType = backgroundType;
dragItemBackground = background;
draggedLibraryItem = self;
} else {
songListItem.Drag.drop()
}
}
filterChildren: true
threshold: 10
/* onDropped: songDropped = true; */
}
MouseArea {
id: songClickHandler

View file

@ -34,6 +34,8 @@ Controls.Page {
property var song
property var draggedLibraryItem
property bool songDragged: false
property string editType
Item {