blob: 4587ba2101caa1dd26a02d10e4368eb97b588a1f (
plain)
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
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
ApplicationWindow {
id: root
readonly property int defaultFontSize: 22
readonly property int imageSize: width / 2
width: 420
height: 760
visible: true
title: "Sensors Showcase"
header : ToolBar {
RowLayout {
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 10
ToolButton {
id: back
text: qsTr("Back")
font.pixelSize: root.defaultFontSize - 4
visible: stack.depth > 1
onClicked: {
stack.pop();
heading.text = root.title;
}
Layout.alignment: Qt.AlignLeft
}
Label {
id: heading
text: root.title
font.pixelSize: root.defaultFontSize
font.weight: Font.Medium
verticalAlignment: Qt.AlignVCenter
Layout.alignment: Qt.AlignCenter
Layout.preferredHeight: 55
}
Item {
visible: back.visible
Layout.preferredWidth: back.width
}
}
}
StackView {
id: stack
// Pushes the object and forwards the properties
function pusher(object : string) : void {
// Trim the suffix and set it as new heading
heading.text = object.split(".")[0]
return stack.push(object, {
fontSize: root.defaultFontSize,
imageSize: root.imageSize
})
}
anchors.fill: parent
anchors.margins: width / 12
initialItem: Item {
ColumnLayout {
id: initialItem
anchors.fill: parent
anchors.topMargin: 20
anchors.bottomMargin: 20
spacing: 5
component CustomButton: Button {
highlighted: true
font.pixelSize: root.defaultFontSize
font.letterSpacing: 1.5
Layout.alignment: Qt.AlignCenter
Layout.fillHeight: true
Layout.fillWidth: true
}
CustomButton {
text: "Accelerometer"
onClicked: stack.pusher("Accelerometer.qml")
enabled: SensorSupport.hasAccelerometer()
}
CustomButton {
text: "Proximity"
onClicked: stack.pusher("Proximity.qml")
enabled: SensorSupport.hasProximity()
}
CustomButton {
text: "Compass"
onClicked: stack.pusher("Compass.qml")
enabled: SensorSupport.hasCompass()
}
CustomButton {
text: "Magnetometer"
onClicked: stack.pusher("Magnetometer.qml")
enabled: SensorSupport.hasMagnetometer()
}
CustomButton {
text: "Gyroscope"
onClicked: stack.pusher("Gyroscope.qml")
enabled: SensorSupport.hasGyroscope()
}
}
}
}
}
|