-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.qml
110 lines (95 loc) · 3.81 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
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'
readonly property string tSemiTransparent: 'semiTransparent'
readonly property string tShowBackground: 'showBackground'
// Default values
readonly property double defMinConfidence: 0.7
readonly property bool defShowInfTime: false
readonly property int defNumThreads: 1
readonly property string defResolution: "640x480"
readonly property bool defSemiTransparent: true
readonly property bool defShowBackground: true
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 bool semiTransparent: Settings.get(tSemiTransparent,defSemiTransparent)
property bool showBackground: Settings.get(tShowBackground,defShowBackground)
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
semiTransparent: window.semiTransparent
showBackground: window.showBackground
}
Configuration{
id: configuration
visible: false
minConfidence: window.minConfidence
nThreads: window.nThreads
showInfTime: window.showInfTime
resolution: window.resolution
resolutions: home.resolutions
semiTransparent: window.semiTransparent
showBackground: window.showBackground
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}
onSemiTransparentChanged: {Settings.set(tSemiTransparent,semiTransparent); window.semiTransparent = semiTransparent}
onShowBackgroundChanged: {Settings.set(tShowBackground,showBackground); window.showBackground = showBackground}
}
}