blob: 5585aff8d70770747a3704a090291718c3cc3e5c (
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
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
463
464
465
466
467
468
469
470
471
472
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import QtQuick.Shapes
import SatelliteInformation
Rectangle {
id: root
required property SatelliteModel satellitesModel
required property color inViewColor
required property color inUseColor
color: Theme.darkBackgroundColor
// A rectangle which is rounded only from the top side
component SemiRoundedRectangle : Shape {
id: roundRect
property int radius: 4
property color color: "white"
visible: roundRect.height > 0
ShapePath {
id: path
readonly property int radius: Math.min(roundRect.radius,
roundRect.width / 2,
roundRect.height / 2)
strokeWidth: 1
strokeColor: roundRect.color
fillColor: roundRect.color
startX: 0
startY: roundRect.height
PathLine {
x: 0
y: path.radius
}
PathArc {
x: path.radius
y: 0
radiusX: path.radius
radiusY: path.radius
useLargeArc: false
}
PathLine {
x: roundRect.width - path.radius
y: 0
}
PathArc {
x: roundRect.width
y: path.radius
radiusX: path.radius
radiusY: path.radius
useLargeArc: false
}
PathLine {
x: roundRect.width
y: roundRect.height
}
PathLine {
x: 0
y: roundRect.height
}
}
}
component DashedLine : Shape {
id: line
property color color: "white"
ShapePath {
strokeWidth: line.height
strokeColor: line.color
strokeStyle: ShapePath.DashLine
dashPattern: [4, 4]
fillColor: "transparent"
startX: 0
startY: 0
PathLine {
x: line.width
y: 0
}
}
}
component SatelliteBox : Rectangle {
id: satBox
required property var modelData
implicitWidth: satRect.border.width * 2 + satRect.anchors.margins * 2
+ satRectLayout.anchors.leftMargin
+ satRectLayout.anchors.rightMargin
+ satIdText.width + satImg.width
implicitHeight: satRect.border.width * 2 + satRect.anchors.margins * 2
+ satRectLayout.anchors.bottomMargin + rssiText.height
+ Math.max(satIdText.height + satRectLayout.anchors.topMargin,
satImg.height)
color: "transparent"
Rectangle {
id: satRect
anchors {
fill: parent
margins: Theme.defaultSpacing
}
border {
width: 1
color: Theme.satelliteItemBorderColor
}
radius: 8
color: "transparent"
ColumnLayout {
id: satRectLayout
anchors {
fill: parent
topMargin: Theme.defaultSpacing
bottomMargin: Theme.defaultSpacing
leftMargin: Theme.defaultSpacing * 2
rightMargin: Theme.defaultSpacing * 2
}
spacing: 0
Text {
id: satIdText
text: qsTr("Sat #") + satBox.modelData.id
color: Theme.satelliteItemMainColor
font.pixelSize: Theme.mediumFontSize
font.weight: Theme.fontDefaultWeight
Layout.alignment: Qt.AlignLeft
}
Text {
id: rssiText
text: satBox.modelData.rssi >= 0 ? satBox.modelData.rssi + qsTr(" dBm")
: qsTr("N/A")
color: Theme.satelliteItemSecondaryColor
font.pixelSize: Theme.smallFontSize
font.weight: Theme.fontLightWeight
Layout.alignment: Qt.AlignCenter
}
}
}
Image {
id: satImg
anchors {
top: parent.top
right: satRect.right
rightMargin: Theme.defaultSpacing
}
source: "icons/satellite_small.png"
}
}
// Hidden SatelliteBox instance to determine a proper height for the ListView
SatelliteBox {
id: hiddenSatelliteBox
visible: false
modelData: ({"id": 999, "rssi": 999})
}
Rectangle {
id: satListRect
readonly property int spacing: Theme.defaultSpacing * 2
anchors.top: parent.top
color: Theme.backgroundColor
height: hiddenSatelliteBox.height + spacing * 2
width: parent.width
ListView {
id: satView
anchors {
fill: parent
topMargin: satListRect.spacing
bottomMargin: satListRect.spacing
}
model: root.satellitesModel
delegate: SatelliteBox {
id: satDelegate
}
orientation: ListView.Horizontal
}
}
Rectangle {
id: separator
anchors {
top: satListRect.bottom
}
color: Theme.separatorColor
height: 1
width: root.width
}
ColumnLayout {
anchors{
top: separator.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
margins: Theme.defaultSpacing
}
spacing: Theme.defaultSpacing
LegendBox {
id: legend
Layout.alignment: Qt.AlignRight
}
Item {
id: rect
readonly property int maxVisibleLevel: 70
Layout.fillHeight: true
Layout.fillWidth: true
Rectangle {
id: axis
readonly property int scaleWidth: 2
readonly property int scaleSpacing: 2
readonly property int offset: maxRssiLabel.width + scaleWidth + scaleSpacing
color: "transparent"
height: rect.height - maxRssiLabel.height
width: rect.width
Text {
id: maxRssiLabel
anchors {
top: axis.top
left: axis.left
}
text: "70"
color: Theme.textSecondaryColor
font.pixelSize: Theme.smallFontSize
font.weight: Theme.fontLightWeight
}
Rectangle {
id: greenRect
width: axis.scaleWidth
height: axis.height * 20 / rect.maxVisibleLevel
anchors {
top: axis.top
left: maxRssiLabel.right
leftMargin: axis.scaleSpacing
}
color: "#489d22"
}
DashedLine {
anchors {
top: greenRect.top
left: greenRect.right
right: axis.right
}
height: 1
color: "#338e8e8e"
}
Text {
anchors {
bottom: greenRect.bottom
right: maxRssiLabel.right
}
text: "50"
color: Theme.textSecondaryColor
font.pixelSize: Theme.smallFontSize
font.weight: Theme.fontLightWeight
}
Rectangle {
id: lightgreenRect
width: axis.scaleWidth
height: axis.height * 10 / rect.maxVisibleLevel
anchors {
top: greenRect.bottom
left: greenRect.left
}
color: "#2cde85"
}
DashedLine {
anchors {
top: lightgreenRect.top
left: lightgreenRect.right
right: axis.right
}
height: 1
color: "#338e8e8e"
}
Text {
anchors {
bottom: lightgreenRect.bottom
right: maxRssiLabel.right
}
text: "40"
color: Theme.textSecondaryColor
font.pixelSize: Theme.smallFontSize
font.weight: Theme.fontLightWeight
}
Rectangle {
id: yellowRect
width: axis.scaleWidth
height: axis.height * 10 / rect.maxVisibleLevel
anchors {
top: lightgreenRect.bottom
left: lightgreenRect.left
}
color: "#ffcc00"
}
DashedLine {
anchors {
top: yellowRect.top
left: yellowRect.right
right: axis.right
}
height: 1
color: "#338e8e8e"
}
Text {
anchors {
bottom: yellowRect.bottom
right: maxRssiLabel.right
}
text: "30"
color: Theme.textSecondaryColor
font.pixelSize: Theme.smallFontSize
font.weight: Theme.fontLightWeight
}
Rectangle {
id: goldRect
width: axis.scaleWidth
height: axis.height * 10 / rect.maxVisibleLevel
anchors {
top: yellowRect.bottom
left: yellowRect.left
}
color: "#ffb800"
}
DashedLine {
anchors {
top: goldRect.top
left: goldRect.right
right: axis.right
}
height: 1
color: "#338e8e8e"
}
Text {
anchors {
bottom: goldRect.bottom
right: maxRssiLabel.right
}
text: "20"
color: Theme.textSecondaryColor
font.pixelSize: Theme.smallFontSize
font.weight: Theme.fontLightWeight
}
Rectangle {
id: orangeRect
width: axis.scaleWidth
height: axis.height * 10 / rect.maxVisibleLevel
anchors {
top: goldRect.bottom
left: goldRect.left
}
color: "#f9a70e"
}
DashedLine {
anchors {
top: orangeRect.top
left: orangeRect.right
right: axis.right
}
height: 1
color: "#338e8e8e"
}
Text {
anchors {
bottom: orangeRect.bottom
right: maxRssiLabel.right
}
text: "10"
color: Theme.textSecondaryColor
font.pixelSize: Theme.smallFontSize
font.weight: Theme.fontLightWeight
}
Rectangle {
id: redRect
width: axis.scaleWidth
height: axis.height * 10 / rect.maxVisibleLevel
anchors {
top: orangeRect.bottom
left: orangeRect.left
}
color: "#c50000"
}
DashedLine {
anchors {
top: redRect.top
left: redRect.right
right: axis.right
}
height: 1
color: "#338e8e8e"
}
Text {
anchors {
bottom: redRect.bottom
right: maxRssiLabel.right
}
text: "0"
color: Theme.textSecondaryColor
font.pixelSize: Theme.smallFontSize
font.weight: Theme.fontLightWeight
}
Rectangle {
anchors {
top: redRect.bottom
left: redRect.left
right: axis.right
}
height: 1
color: "#8e8e8e"
}
}
Row {
id: view
anchors {
fill: rect
leftMargin: axis.offset + view.spacing
}
property int rows: repeater.model.size
property int singleWidth: view.width / rows - spacing
spacing: Theme.defaultSpacing
//! [0]
Repeater {
id: repeater
model: root.satellitesModel
delegate: Rectangle {
required property var modelData
height: rect.height
width: view.singleWidth
color: "transparent"
SemiRoundedRectangle {
anchors.bottom: satId.top
width: parent.width
height: (parent.height - satId.height)
* Math.min(parent.modelData.rssi, rect.maxVisibleLevel)
/ rect.maxVisibleLevel
color: parent.modelData.inUse ? root.inUseColor : root.inViewColor
}
Text {
id: satId
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
text: parent.modelData.id
color: Theme.textSecondaryColor
font.pixelSize: Theme.smallFontSize
font.weight: Theme.fontLightWeight
}
}
}
//! [0]
}
}
}
}
|