feat(EditCroppedImagePanel): Extended to be able to drag/drop images

Added `DropArea` to enable drag/drop images.
This commit is contained in:
Noelia 2023-05-08 14:00:26 +02:00 committed by Noelia
parent 6602ab15e2
commit 21abe5fca7
2 changed files with 25 additions and 1 deletions

View File

@ -87,6 +87,7 @@ StatusScrollView {
title: qsTr("Collectible artwork")
acceptButtonText: qsTr("Upload collectible artwork")
roundedImage: false
isDraggable: true
NoImageUploadedPanel {
width: parent.width

View File

@ -37,6 +37,8 @@ Item {
readonly property alias cropWorkflow : imageCropWorkflow
property bool isDraggable: false
function chooseImageToCrop() {
imageCropWorkflow.chooseImageToCrop()
}
@ -145,9 +147,18 @@ Item {
Layout.fillHeight: true
visible: root.state === d.noImageState
radius: roundedImage ? Math.max(width, height)/2 : croppedPreview.radius
color: Style.current.inputBackground
states: [
State {
when: dropArea.containsDrag
PropertyChanges {target: imageCropEditor; border.color: Theme.palette.primaryColor1 }
},
State {
when: !dropArea.containsDrag
PropertyChanges {target: imageCropEditor; border.color: Theme.palette.baseColor2 }
}
]
StatusRoundButton {
id: addButton
@ -202,6 +213,18 @@ Item {
}
}
DropArea {
id: dropArea
anchors.fill: parent
enabled: root.isDraggable
onDropped: {
if (drop.urls.length > 0) {
imageCropWorkflow.cropImage(drop.urls[0])
}
}
}
StatusMenu {
id: imageEditMenu
width: 200