QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
TerrainProgress.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6
7Rectangle {
8 implicitWidth: mainLayout.width + (_margins * 2)
9 implicitHeight: mainLayout.height + (_margins * 2)
10 color: qgcPal.window
11 radius: ScreenTools.defaultBorderRadius
12 visible: false
13
14 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
15 property real _margins: ScreenTools.defaultFontPixelWidth / 2
16 property real _totalBlocks: _activeVehicle ? _activeVehicle.terrain.blocksPending.rawValue + _activeVehicle.terrain.blocksLoaded.rawValue : 0
17 property real _blocksLoaded: _activeVehicle ? _activeVehicle.terrain.blocksLoaded.rawValue : 0
18 property real _blocksPending: _activeVehicle ? _activeVehicle.terrain.blocksPending.rawValue : 0
19 property real _pctComplete: _activeVehicle && _totalBlocks ? _blocksLoaded / _totalBlocks : 0
20
21 on_BlocksPendingChanged: {
22 if (_blocksPending == 0) {
23 // UI doesn't go away immediately
24 visibilityTimer.restart()
25 } else {
26 visible = true
27 visibilityTimer.stop()
28 }
29 }
30
31 on_BlocksLoadedChanged: {
32 if (_blocksLoaded != 0) {
33 // This causes the progress indicator to display even if it starts out as complete
34 visible = true
35 if (_blocksPending == 0) {
36 visibilityTimer.restart()
37 }
38 }
39 }
40
41 Timer {
42 id: visibilityTimer
43 interval: 15 * 1000
44 onTriggered: parent.visible = false
45 }
46
47 QGCPalette { id: qgcPal }
48
49 ColumnLayout {
50 id: mainLayout
51 anchors.margins: _margins
52 anchors.top: parent.top
53 anchors.left: parent.left
54 spacing: _margins
55
56 QGCLabel {
57 Layout.alignment: Qt.AlignHCenter
58 text: qsTr("Terrain Load Progress")
59 font.pointSize: ScreenTools.smallFontPointSize
60 }
61
62 Rectangle {
63 Layout.fillWidth: true
64 height: ScreenTools.defaultFontPixelHeight
65 color: "transparent"
66 border.color: "green"
67
68 Rectangle {
69 anchors.top: parent.top
70 anchors.bottom: parent.bottom
71 color: "green"
72 width: parent.width * _pctComplete
73
74 QGCLabel {
75 anchors.centerIn: parent
76 text: qsTr("Done")
77 visible: _blocksPending == 0
78 }
79 }
80 }
81 }
82}