-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
118 lines (96 loc) · 3.05 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QmlFileItem 1.0
Window {
width: 160
height: 450
Component.onCompleted: {
x = Screen.width
y = Screen.height / 2 - height / 2
}
visible: true
flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint
SystemPalette {
id: palette
}
color: palette.window
ListView {
id: itemsView
anchors.margins: 10
boundsBehavior: Flickable.StopAtBounds
anchors.fill: parent
orientation: ListView.Vertical
spacing: 5
model: QmlFileItemModel {
id: fileList
}
delegate: Item {
width: itemsView.width
height: layout.height
Drag.dragType: Drag.Automatic
Drag.active: dragArea.drag.active
Drag.hotSpot.x: 10
Drag.hotSpot.y: 10
Drag.mimeData: {"text/uri-list": model.url}
Drag.keys: model.keys
Drag.onDragFinished:
(dropAction) => {
removeDelayTimer.start();
}
Timer {
id: removeDelayTimer
interval: 250
onTriggered: {
fileList.removeItem(model.url);
}
}
ToolTip.delay: 500
ToolTip.visible: dragArea.containsMouse
ToolTip.text: model.url
ColumnLayout {
width: parent.width
id: layout
z:0
Image {
width: parent.width-10
height: width
source: model.icon
Layout.alignment: Qt.AlignHCenter
}
Label {
text: model.name
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: parent.width
horizontalAlignment: Qt.AlignHCenter
elide: Label.ElideMiddle
wrapMode: Label.WrapAtWordBoundaryOrAnywhere
}
}
MouseArea {
z:2
id: dragArea
anchors.fill: parent
hoverEnabled: true
drag.target: parent
onPressed: {
parent.grabToImage(function(result) {
parent.Drag.imageSource = result.url
})}
}
}
}
DropArea {
anchors.fill: parent
onDropped: (drop) => {
fileList.addItem(drop.urls[0], drop.keys)
drop.acceptProposedAction()
}
Rectangle {
anchors.fill: parent
color: "green"
visible: parent.containsDrag
}
}
}