Compare commits

...

1 Commits

Author SHA1 Message Date
Fushan Wen
a61976ae91 Allow to drag image from image delegate 2023-07-22 23:54:11 +08:00

View File

@@ -105,6 +105,10 @@ TimelineContainer {
Layout.preferredHeight: imageHeight Layout.preferredHeight: imageHeight
source: root.mediaInfo.source source: root.mediaInfo.source
Drag.active: dragHandler.active
Drag.dragType: Drag.Automatic
Drag.supportedActions: Qt.CopyAction
Image { Image {
anchors.fill: parent anchors.fill: parent
source: root.mediaInfo.tempInfo.source source: root.mediaInfo.tempInfo.source
@@ -141,6 +145,28 @@ TimelineContainer {
} }
} }
Item {
anchors.fill: parent
DragHandler {
id: dragHandler
enabled: img.status === Image.Ready
onActiveChanged: {
if (active) {
img.grabToImage((result) => {
img.Drag.mimeData = {
"image/png": result.image,
};
img.Drag.active = dragHandler.active;
});
} else {
img.Drag.active = false;
}
}
}
}
TapHandler { TapHandler {
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
onTapped: { onTapped: {