-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.qml
138 lines (115 loc) · 4.01 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.LocalStorage 2.0
import "storage.js" as Settings
ApplicationWindow {
id: window
visible: true
title: qsTr("TensorFlow Lite & Qt")
readonly property string tMinConfidence: 'minConfidence'
readonly property string tNThreads: 'nThreads'
readonly property string tShowInfTime: 'showInfTime'
readonly property string tResolution: 'resolution'
// Default values
readonly property double defMinConfidence: 0.7
readonly property bool defShowInfTime: false
readonly property int defNumThreads: 1
readonly property bool defTFObject: true
readonly property string defResolution: "640x480"
property double minConfidence: Settings.get(tMinConfidence,defMinConfidence)
property int nThreads: Settings.get(tNThreads,defNumThreads)
property bool showInfTime: Settings.get(tShowInfTime,defShowInfTime) == 0 ? false : true
property string resolution: Settings.get(tResolution,defResolution)
property var tfObjects: []
header: ToolBar {
contentHeight: toolButton.implicitHeight
ToolButton {
id: toolButton
text: stackView.depth > 1 ? "\u25C0" : "\u2630"
font.pixelSize: Qt.application.font.pixelSize * 1.6
onClicked: {
if (stackView.depth > 1) {
stackView.pop()
} else {
drawer.open()
}
}
}
Label {
text: stackView.currentItem.title
anchors.centerIn: parent
}
}
Drawer {
id: drawer
width: window.width * 0.3
height: window.height
Column {
anchors.fill: parent
ItemDelegate {
text: qsTr("Settings")
width: parent.width
onClicked: {
stackView.push(configuration)
drawer.close()
}
}
}
}
StackView {
id: stackView
initialItem: home
anchors.fill: parent
}
Home{
id: home
visible: false
minConfidence: window.minConfidence
nThreads: window.nThreads
showInfTime: window.showInfTime
resolution: window.resolution
}
Configuration{
id: configuration
visible: false
minConfidence: window.minConfidence
nThreads: window.nThreads
showInfTime: window.showInfTime
resolution: window.resolution
resolutions: home.resolutions
onMinConfidenceChanged: {Settings.set(tMinConfidence,minConfidence); window.minConfidence = minConfidence }
onNThreadsChanged: {Settings.set(tNThreads,nThreads); window.nThreads = nThreads }
onShowInfTimeChanged: {Settings.set(tShowInfTime,showInfTime); window.showInfTime = showInfTime }
onResolutionUpdated: {Settings.set(tResolution,resolution); window.resolution = resolution}
onObjectChanged: {
tfObjects[label] = checked
Settings.set(label,checked)
setActiveLabel(label,checked)
}
}
Component.onCompleted: init()
function init()
{
console.log("Initialization")
var labels = auxUtils.getLabels()
tfObjects = []
for(var i=0;i<labels.length;i++)
{
var value = Settings.get(labels[i],defTFObject) == 0 ? false : true
tfObjects[labels[i]] = value
}
home.tfObjects = Qt.binding(function() { return tfObjects })
configuration.tfObjects = Qt.binding(function() { return tfObjects })
setAllLabels()
}
function setActiveLabel(key,value)
{
home.setActiveLabel(key,value)
}
function setAllLabels()
{
var labels = auxUtils.getLabels()
for(var i=0;i<labels.length;i++)
setActiveLabel(labels[i],tfObjects[labels[i]])
}
}