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") title: qsTr("Collectible artwork")
acceptButtonText: qsTr("Upload collectible artwork") acceptButtonText: qsTr("Upload collectible artwork")
roundedImage: false roundedImage: false
isDraggable: true
NoImageUploadedPanel { NoImageUploadedPanel {
width: parent.width width: parent.width

View File

@ -37,6 +37,8 @@ Item {
readonly property alias cropWorkflow : imageCropWorkflow readonly property alias cropWorkflow : imageCropWorkflow
property bool isDraggable: false
function chooseImageToCrop() { function chooseImageToCrop() {
imageCropWorkflow.chooseImageToCrop() imageCropWorkflow.chooseImageToCrop()
} }
@ -145,9 +147,18 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
visible: root.state === d.noImageState visible: root.state === d.noImageState
radius: roundedImage ? Math.max(width, height)/2 : croppedPreview.radius radius: roundedImage ? Math.max(width, height)/2 : croppedPreview.radius
color: Style.current.inputBackground 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 { StatusRoundButton {
id: addButton 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 { StatusMenu {
id: imageEditMenu id: imageEditMenu
width: 200 width: 200