From 6a8255f67aed1e26e5a2ad96dfd6c4b578b834ae Mon Sep 17 00:00:00 2001 From: Epicalert Date: Tue, 10 Sep 2024 23:47:18 +0800 Subject: [PATCH] Make TexSlots draggable --- TexSlot.qml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/TexSlot.qml b/TexSlot.qml index 2ba4eb4..551616c 100644 --- a/TexSlot.qml +++ b/TexSlot.qml @@ -11,7 +11,6 @@ DropArea { width: 128 height: 128 - Rectangle { id: rectangle anchors.fill: parent @@ -25,7 +24,30 @@ DropArea { width: 96 height: 96 + MouseArea { + id: imageMouseArea + anchors.fill: parent + + Drag.dragType: Drag.Automatic + Drag.supportedActions: Qt.CopyAction + Drag.mimeData: { + "text/uri-list": filePath + } + + DragHandler { + id: dragHandler + onActiveChanged: + if (active) { + parent.grabToImage(function(result) { + parent.Drag.imageSource = result.url + parent.Drag.active = true + }) + } else { + parent.Drag.active = false + } + } + } } }