-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsView.qml
184 lines (167 loc) · 5.64 KB
/
SettingsView.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
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtPositioning
Page {
id: root
title: "Settings"
property bool debug
property bool useHardCodedPosition
property real hardcodedLongitude
property real hardcodedLatitude
property real selfHeight: 2.0
Header {
id: header
text: "Settings"
}
ScrollView {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: header.bottom
anchors.bottom: parent.bottom
ListModel {
id: contactModel
ListElement {
name: "Use current location"
}
ListElement {
name: "Use hardcoded location"
}
}
Column {
width: parent.width
Label {
text: "Observer height"
onTextChanged: {
const parsedValue = parseFloat(text)
if (!isNaN(parsedValue)) {
root.selfHeight = parsedValue
}
}
}
SpinBox {
from: 0
editable: true
stepSize: 1
value: root.selfHeight
onValueChanged: {
root.selfHeight = value
}
}
Label {
text: "Location"
}
Rectangle {
width: root.width; height: 80
Component {
id: contactDelegate
Item {
width: root.width; height: 40
Column {
Text { text: name }
}
MouseArea {
anchors.fill: parent
onClicked: listView.currentIndex = index
}
}
}
ListView {
id: listView
currentIndex: useHardCodedPosition ? 1 : 0
onCurrentIndexChanged: {
root.useHardCodedPosition = currentIndex === 1
}
anchors.fill: parent
model: contactModel
delegate: contactDelegate
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
focus: true
}
}
ComboBox {
visible: listView.currentIndex === 1
model: ListModel {
id: model
ListElement {
text: "Custom"
}
// ListElement {
// text: "Herfølhytta"
// }
ListElement {
text: "Herfølrenna nord"
}
ListElement {
text: "Lauersvelgen"
}
ListElement {
text: "Sørenga"
}
ListElement {
text: "Ytre Oslofjord"
}
// ListElement {
// text: "Special place"
// }
}
onCurrentTextChanged: {
const locations = {
// "Herfølhytta": QtPositioning.coordinate(58.9952381,11.0584886),
"Herfølrenna nord": QtPositioning.coordinate(59.006630, 11.057814),
"Lauersvelgen": QtPositioning.coordinate(59.01487, 11.0295),
"Sørenga": QtPositioning.coordinate(59.901484, 10.751129),
"Ytre Oslofjord": QtPositioning.coordinate(58.982769, 10.763596),
// "Special place": QtPositioning.coordinate(59.014167, 11.042647)
}
const location = locations[currentText]
if (location) {
longitudeText.text = location.longitude
latitudeText.text = location.latitude
}
}
}
Label {
text: "Latitude"
visible: listView.currentIndex === 1
}
TextField {
id: latitudeText
visible: listView.currentIndex === 1
width: root.width
height: 40
placeholderText: "Enter latitude"
text: root.hardcodedLatitude
onTextChanged: {
const parsedValue = parseFloat(text)
if (!isNaN(parsedValue)) {
root.hardcodedLatitude = parsedValue
}
}
}
Label {
text: "Longitude"
visible: listView.currentIndex === 1
}
TextField {
id: longitudeText
visible: listView.currentIndex === 1
width: root.width
height: 40
placeholderText: "Enter longitude"
text: root.hardcodedLongitude
onTextChanged: {
const parsedValue = parseFloat(text)
if (!isNaN(parsedValue)) {
root.hardcodedLongitude = parsedValue
}
}
}
// Switch {
// text: "Debug"
// onToggled: {
// root.debug = checked
// }
// }
}
}
}