59 lines
1,023 B
QML
59 lines
1,023 B
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import QtQuick.Controls
|
|
|
|
DropArea {
|
|
property string rectColor: "white"
|
|
property url filePath: ""
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
width: 128
|
|
height: 128
|
|
|
|
|
|
Rectangle {
|
|
id: rectangle
|
|
anchors.fill: parent
|
|
color: rectColor
|
|
|
|
Image {
|
|
id: image
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: 96
|
|
height: 96
|
|
|
|
|
|
}
|
|
}
|
|
|
|
Label {
|
|
id: huh
|
|
|
|
text: "無"
|
|
}
|
|
|
|
onEntered: {
|
|
rectangle.color = "cyan";
|
|
drag.accept (Qt.LinkAction);
|
|
}
|
|
onDropped: {
|
|
// TODO: handle dragging all channels at once
|
|
var firstUrl = new URL(drop.urls[0]);
|
|
if (firstUrl.protocol === "file:")
|
|
{
|
|
console.log(drop.urls);
|
|
|
|
filePath = drop.urls[0];
|
|
huh.text = drop.urls[0];
|
|
image.source = drop.urls[0];
|
|
}
|
|
rectangle.color = rectColor;
|
|
}
|
|
onExited: {
|
|
rectangle.color = rectColor;
|
|
}
|
|
}
|