-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgramComponent.qml
More file actions
91 lines (77 loc) · 2.08 KB
/
ProgramComponent.qml
File metadata and controls
91 lines (77 loc) · 2.08 KB
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
import QtQuick
import QtQuick.Controls
Item {
property string programName: ""
property string programExecPath: ""
property string programIcon: ""
signal itemLeftClicked()
signal itemRightClicked()
signal fileDraggedin(var fileUrlList)
width: 40
height: 40
anchors.verticalCenter: parent.verticalCenter
Rectangle {
anchors.fill: parent
color: "transparent"
ToolTip {
id: toolTip
text: programName
visible: false
x: parent.x
y: parent.y + 100
}
Image {
id: icon
width: 40
height: 40
source: programIcon
fillMode: Image.PreserveAspectFit
smooth: true
antialiasing: true
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
hoverEnabled: true
Timer {
id: timer
interval: 1000
onTriggered: {
toolTip.visible = true
}
}
onEntered: {
icon.scale = 1.3
timer.start()
}
onExited: {
timer.stop()
icon.scale = 1
toolTip.visible = false
}
onClicked: function(mouse) {
if (mouse.button === Qt.LeftButton) {
itemLeftClicked()
}
}
}
DropArea {
anchors.fill: parent
// 当文件被拖入时触发
onEntered: {
icon.scale = 1.3
}
onExited: {
icon.scale = 1
}
// 当文件被释放时触发
onDropped: function(drop) {
var fileUrls = [""]
for (var i = 0; i < drop.urls.length; ++i) {
fileUrls.push(drop.urls[i].toString().slice(8))
}
fileDraggedin(fileUrls)
}
}
}
}