/
TasksList.qml
159 lines (144 loc) · 5.11 KB
/
TasksList.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import QtQuick 2.5
Image {
id: root
source: "qrc:/icons/bg.png"
signal nobtn
function createOutput(cmd, output, duration){
var compoment = Qt.createComponent("qrc:/OutPut.qml");
var obj = compoment.createObject(root, {"x":0, "y":100, "width": root.width, "height": root.height-200,
"cmdText": cmd, "outputText": output, "durationText": qsTr("cost time: %1").arg(duration)});
}
ListView {
id: listView1
anchors.bottom: rectangle2.top
anchors.bottomMargin: 0
clip: true
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.top: parent.top
anchors.topMargin: 0
orientation: ListView.Vertical
spacing: 1
maximumFlickVelocity: 6000
model: mc.taskModel
// highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
focus: true
delegate: Image {
id: listItem
height: listView1.height/8
width: listView1.width
opacity: ListView.isCurrentItem ? 1.0:0.5
source: "qrc:/icons/itembg.png"
MouseArea {
anchors.fill: parent
onClicked: listView1.currentIndex = index
}
Image {
id: icon
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: parent.height/10
width: height
// asynchronous: true
source: "image://FileImageProvider/"+model.modelData.state
Connections {
target: model.modelData
onStateChanged: {icon.source = "";icon.source = "image://FileImageProvider/"+model.modelData.state;}
}
}
Text {
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
left: icon.right
}
wrapMode: Text.WordWrap
text: model.modelData.cmd
color: mc.colorValue("user/textColor")
font.pixelSize: parent.height/6
}
}
ScrollBar {
flickable: listView1
}
}
Rectangle {
id: rectangle2
height: root.height/7
color: "#00000000"
border.width: 1
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
Grid {
id: grid1
anchors.fill: parent
spacing: 1
rows: 2
columns: 3
property real btnWid: width/3
property real btnHei: height/2
property int fs: btnHei/3
MyButton {
id: myButton1
text: qsTr("Stop selected")
width: parent.btnWid
height: parent.btnHei
fontsize: parent.fs
enabled: mc.taskModel.length===0?false:(mc.taskModel[listView1.currentIndex].state === "task_running")
onClicked: mc.taskModel[listView1.currentIndex].stopTask()
}
MyButton {
id: myButton2
text: qsTr("Read output")
width: parent.btnWid
height: parent.btnHei
fontsize: parent.fs
enabled: mc.taskModel.length===0?false:(mc.taskModel[listView1.currentIndex].state !== "task_running")
onClicked: createOutput(mc.taskModel[listView1.currentIndex].cmd, mc.taskModel[listView1.currentIndex].output, mc.taskModel[listView1.currentIndex].duration)
}
MyButton {
id: myButton3
text: qsTr("Remove task")
width: parent.btnWid
height: parent.btnHei
fontsize: parent.fs
enabled: mc.taskModel.length===0?false:true
onClicked: mc.removeTask(listView1.currentIndex)
}
MyButton {
id: myButton4
text: qsTr("Remove finished")
width: parent.btnWid
height: parent.btnHei
fontsize: parent.fs
enabled: mc.taskModel.length===0?false:true
onClicked: mc.removeFinishedTasks()
}
MyButton {
id: myButton5
text: qsTr("Stop all")
width: parent.btnWid
height: parent.btnHei
fontsize: parent.fs
enabled: mc.taskModel.length===0?false:true
onClicked: mc.stopAllTasks();
}
MyButton {
id: myButton6
text: qsTr("Back")
width: parent.btnWid
height: parent.btnHei
fontsize: parent.fs
onClicked: root.nobtn()
}
}
}
}