-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathConfiguration.qml
462 lines (383 loc) · 14.6 KB
/
Configuration.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
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
import QtQuick 2.9
import QtQuick.Controls 2.2
Page {
id: root
title: qsTr("Settings")
property double minConfidence
property int nThreads
property bool showInfTime
property var tfObjects: []
property string resolution
property var resolutions: []
property bool loadingRes
readonly property int leftMargin: 100
readonly property int rightMargin: 100
signal objectChanged(string label, bool checked)
signal resolutionUpdated()
onResolutionsChanged: {
console.log("Camera resolutions: " + resolutions)
loadingRes = true
sbResolution.to = resolutions.length - 1
sbResolution.items = resolutions
sbResolution.value = -1
loadingRes = false
sbResolution.value = sbResolution.valueFromText(resolution)
}
// TabBar
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("Neural Network && Camera")
}
TabButton {
text: qsTr("Screen info")
}
TabButton {
text: qsTr("Hardware info && Close app")
}
}
// tab contents
SwipeView {
id: swipeView
anchors.fill: parent
clip: true
currentIndex: tabBar.currentIndex
Flickable {
contentHeight: column.height
contentWidth: column.width
flickableDirection: Flickable.VerticalFlick
Column{
id: column
width: root.width
Item{
height: 20
width: 1
}
Text{
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
width: parent.width
wrapMode: Text.WordWrap
elide: Text.ElideRight
text: qsTr("Minimum confidence")
}
Item{
width: 1
height: 10
}
Slider{
id: slider
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - (leftMargin+rightMargin)
from: 0
to: 1
value: minConfidence
live: true
onValueChanged: minConfidence = value
}
Text {
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
width: parent.width
wrapMode: Text.WordWrap
elide: Text.ElideRight
text: Math.round(slider.position * 100) + " %"
}
Item{
width: 1
height: 10
}
Row {
width: parent.width
spacing: 2
Item{
height: 1
width: (parent.width - parent.spacing - tThread.width)*0.5
}
Text{
id: tThread
anchors.leftMargin: 30
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
elide: Text.ElideRight
text: qsTr("Number of threads")
}
}
Slider{
id: sThreads
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - (leftMargin+rightMargin)
from: 1
to: auxUtils.numberThreads()
enabled: to>1
live: true
snapMode: Slider.SnapAlways
stepSize: 1
value: nThreads
onValueChanged: nThreads = value
}
Text {
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
width: parent.width
wrapMode: Text.WordWrap
elide: Text.ElideRight
text: sThreads.value + " " + (sThreads.value>1 ? qsTr("threads") : qsTr("thread"))
}
Item{
width: 1
height: 20
}
Text{
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
width: parent.width
wrapMode: Text.WordWrap
elide: Text.ElideRight
text: qsTr("Camera resolution")
}
Item{
width: 1
height: 10
}
SpinBox {
id: sbResolution
anchors.horizontalCenter: parent.horizontalCenter
from: 0
editable: false
property var items
textFromValue: function(value) {
return items[value];
}
valueFromText: function(text) {
for (var i = 0; i < items.length; i++)
{
if (items[i].toLowerCase() === text.toLowerCase())
return i
}
return value
}
onValueChanged:
if (value>=0 && !loadingRes)
{
resolution = textFromValue(value)
console.log("Resolution to save: " + resolution)
resolutionUpdated()
}
}
Item{
height: 30
width: 1
}
}
}
Flickable {
id: flickInfo
contentHeight: column3.height
contentWidth: column3.width
flickableDirection: Flickable.VerticalFlick
Column{
id: column3
width: root.width
Item{
height: 20
width: 1
}
Text{
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
width: parent.width
wrapMode: Text.WordWrap
elide: Text.ElideRight
text: qsTr("General information")
}
Item{
width: 1
height: 10
}
Row{
width: parent.width - (leftMargin+rightMargin)
anchors.horizontalCenter: parent.horizontalCenter
spacing: width - tShowInfTime.width - sShowInfTime.width
Text {
id: tShowInfTime
text: qsTr("Show inference time")
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
}
Switch{
anchors.verticalCenter: parent.verticalCenter
id: sShowInfTime
checked: showInfTime
onToggled: showInfTime = checked
}
}
Item{
height: 20
width: 1
}
Text{
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
width: parent.width
wrapMode: Text.WordWrap
elide: Text.ElideRight
text: qsTr("Detected objects")
}
Item{
width: 1
height: 10
}
Repeater{
model: auxUtils.getLabels()
Column{
width: root.width
Row{
width: parent.width - (leftMargin+rightMargin)
anchors.horizontalCenter: parent.horizontalCenter
spacing: width - rObject.width - sObject.width
Row {
id: rObject
spacing: 2
width: tObject.width + spacing
Text {
id: tObject
text: modelData.replace(/\b\w/g, function(l){ return l.toUpperCase() })
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.NoWrap
elide: Text.ElideRight
}
}
Switch{
anchors.verticalCenter: parent.verticalCenter
id: sObject
checked: tfObjects[modelData]
onToggled: objectChanged(modelData,checked)
}
}
Item{
width: 1
height: 10
}
}
}
}
}
Flickable {
contentHeight: column2.height
contentWidth: column2.width
flickableDirection: Flickable.VerticalFlick
Column{
id: column2
width: root.width
Item{
height: 20
width: 1
}
Text{
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
width: parent.width
wrapMode: Text.WordWrap
elide: Text.ElideRight
height: 30
text: qsTr("Hardware info")
}
Item{
width: 1
height: 10
}
Column{
width: root.width
Repeater{
model: auxUtils.networkInterfaces()
Text{
anchors.leftMargin: leftMargin
anchors.rightMargin: rightMargin
horizontalAlignment: Text.AlignHCenter
width: parent.width
height: 30
wrapMode: Text.WordWrap
elide: Text.ElideRight
text: modelData
}
}
}
Item{
width: 1
height: 30
}
Button{
id: bClose
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Close app")
onClicked: dialog.open()
contentItem: Text {
text: bClose.text
font: bClose.font
opacity: enabled ? 1.0 : 0.3
color: "white"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
background: Rectangle {
implicitWidth: 100
implicitHeight: 40
color: bClose.down ? "#ff0000" : "#aa0000"
border.color: "#7e181a"
border.width: 1
radius: 0
}
}
}
}
}
Rectangle{
id: backPageIndicator
anchors.bottom: parent.bottom
height: 20
width: parent.width
}
PageIndicator {
id: pageIndicator
count: swipeView.count
currentIndex: swipeView.currentIndex
anchors.centerIn: backPageIndicator
delegate: Rectangle{
implicitWidth: 10
implicitHeight: 10
radius: width
}
}
Dialog {
id: dialog
x: 0.5*(parent.width - width)
y: 0.5*(parent.height - height)
title: "Close app"
standardButtons: Dialog.Ok | Dialog.Cancel
modal: true
Label{
text: qsTr("Do you really want to close this app?")
}
onAccepted: Qt.callLater(Qt.quit)
onRejected: dialog.close()
}
}