-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingWindow.qml
More file actions
381 lines (327 loc) · 13 KB
/
Copy pathSettingWindow.qml
File metadata and controls
381 lines (327 loc) · 13 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
ApplicationWindow {
id: rootWindow
width: 600
height: 400
visible: true
title: "设置"
property int currentIndex: 0
TabBar {
id: tabBar
width: parent.width
TabButton {
text: "常规"
onClicked: swipeView.currentIndex = 0
}
TabButton {
text: "程序"
onClicked: swipeView.currentIndex = 1
}
TabButton {
text: "关于"
onClicked: swipeView.currentIndex = 2
}
}
SwipeView {
id: swipeView
width: parent.width
anchors.top: tabBar.bottom
anchors.bottom: parent.bottom
orientation: Qt.Horizontal
interactive: false
currentIndex: 1
Page {
Rectangle {
id: firstPage
anchors.fill: parent
color: "red"
}
}
Page {
Rectangle {
id: secondPage
anchors.fill: parent
ScrollView {
anchors.left: parent.left
width: 0.8 * parent.width
height: parent.height
ListView {
id: listView
anchors.top: listView.top
height: parent.height
width: parent.width
spacing: 20
model: UserDataModel
delegate: Item {
Rectangle {
id: item
width: listView.width
height: 30
color: {
if (index === currentIndex) {
return "#4079FC"
} else {
if (index % 2 == 0) {
return "#E5F3FF"
} else {
return "#ffffff"
}
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
currentIndex = index
}
}
Row {
width: parent.width
height: 30
spacing: 0.03 * parent.width
Text {
height: 30
width: 0.2 * parent.width
text: NameRole
elide: Text.ElideRight
}
Text {
height: 30
width: 0.15 * parent.width
text: IconRole
x: 0.4 * parent
elide: Text.ElideRight
}
Text {
height: 30
width: 0.45 * parent.width
text: ExecRole
elide: Text.ElideRight
}
Text {
height: 30
width: 0.1 * parent.width
text: ParaRole
elide: Text.ElideRight
}
}
}
}
}
}
Rectangle {
anchors.right: parent.right
width: 0.2 * parent.width
height: parent.height
Column {
height: parent.height - 30
width: 0.6 * parent.width
anchors.horizontalCenter: parent.horizontalCenter
y: 30
spacing: 20
Button {
id: addBtn
width: parent.width
height: 20
text: "添 加"
onClicked: {
for (var i = 0; i < 4; i++) {
listModel.get(i)["value"] = ""
}
editDialog.open()
}
}
Button {
id: deleteBtn
width: parent.width
height: 20
text: "删 除"
onClicked: {
}
}
Button {
id: editBtn
width: parent.width
height: 20
text: "编 辑"
onClicked: {
var list = UserDataModel.getItem(currentIndex)
for (var i = 0; i < 4; i++) {
listModel.get(i)["value"] = list[i]
}
editDialog.open()
}
}
Button {
id: upperBtn
width: parent.width
height: 20
text: "上 移"
enabled: currentIndex <= 0 ? false : true
onClicked: {
if (currentIndex >= 1) {
UserDataModel.exchangeItem(currentIndex, currentIndex - 1)
currentIndex -= 1
}
}
}
Button {
id: downBtn
width: parent.width
height: 20
text: "下 移"
enabled: currentIndex >= (listView.count - 1) ? false : true
onClicked: {
if (currentIndex <= listView.count - 2) {
UserDataModel.exchangeItem(currentIndex, currentIndex + 1)
currentIndex += 1
}
}
}
Button {
id: restoreBtn
width: parent.width
height: 20
text: "恢 复"
onClicked: {
}
}
Button {
id: saveBtn
width: parent.width
height: 20
text: "保 存"
onClicked: {
UserDataModel.writeToFile()
}
}
}
}
}
ListModel {
id: listModel
ListElement {
key: "程序名:"
value: ""
}
ListElement {
key: "程序图标:"
value: ""
}
ListElement {
key: "执行命令:"
value: ""
}
ListElement {
key: "命令参数:"
value: ""
}
}
Dialog {
id: editDialog
width: 400
height: 200
anchors.centerIn: parent
modal: true
standardButtons: Dialog.Save | Dialog.Cancel
FileDialog {
id: execFileDialog
title: "Choose Exec File"
currentFolder: "file:///C:/"
nameFilters: ["Executable files (*.exe)"]
onAccepted: {
var execUrl = execFileDialog.selectedFile.toString().slice(8)
listModel.get(2).value = execUrl
}
}
FileDialog {
id: iconFileDialog
title: "Choose Icon File"
currentFolder: "file:///C:/Users/hrkkk/Desktop/Dock/ProgramDock/resource/"
nameFilters: ["Image files (*.png *.jpg *.bmp *.gif)"]
onAccepted: {
var iconUrl = iconFileDialog.selectedFile.toString().slice(8)
var newUrl = iconUrl.slice(iconUrl.lastIndexOf("/") + 1)
listModel.get(1).value = newUrl
}
}
Column {
anchors.fill: parent
spacing: 5
Repeater {
id: repeater
model: listModel
delegate: Rectangle {
width: parent.width
height: 20
color: "transparent"
property alias dynamicText: textInput.text
Text {
id: firstText
anchors.left: parent.left
width: 70
height: parent.height
text: key
}
Rectangle {
id: secondInput
anchors.left: firstText.right
anchors.leftMargin: 20
width: parent.width - 130
height: parent.height
color: "grey"
border.width: 1
TextInput {
id: textInput
anchors.fill: parent
text: value
}
}
Button {
anchors.left: secondInput.right
anchors.leftMargin: 20
width: 20
height: 20
visible: (index === 1 || index === 2) ? true :false
onClicked: {
if (index === 1) { // 程序图标选择
iconFileDialog.open()
} else if (index === 2) { // 执行程序选择
execFileDialog.open()
}
}
Image {
anchors.fill: parent
source: "qrc:/resource/microsoft.png"
fillMode: Image.PreserveAspectFit
}
}
}
}
}
onAccepted: {
var strList = []
for (var i = 0; i < repeater.count; ++i) {
strList.push(repeater.itemAt(i).dynamicText)
}
UserDataModel.setItem(currentIndex, strList)
}
onRejected: {
editDialog.close()
for (var i = 0; i < 4; i++) {
listModel.get(i)["value"] = ""
}
}
}
}
Page {
Rectangle {
id: thirdPage
anchors.fill: parent
color: "green"
}
}
}
}