QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VehicleSummary.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8Rectangle {
9 id: _summaryRoot
10 anchors.fill: parent
11 anchors.rightMargin: ScreenTools.defaultFontPixelWidth
12 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
13 color: qgcPal.window
14
15 property real _minSummaryW: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelWidth * 28 : ScreenTools.defaultFontPixelWidth * 36
16 property real _summaryBoxWidth: _minSummaryW
17 property real _summaryBoxSpace: ScreenTools.defaultFontPixelWidth * 2
18 property real _margins: ScreenTools.defaultFontPixelHeight / 2
19
20 function computeSummaryBoxSize() {
21 var sw = 0
22 var rw = 0
23 var idx = Math.floor(_summaryRoot.width / (_minSummaryW + ScreenTools.defaultFontPixelWidth))
24 if(idx < 1) {
25 _summaryBoxWidth = _summaryRoot.width
26 _summaryBoxSpace = 0
27 } else {
28 _summaryBoxSpace = 0
29 if(idx > 1) {
30 _summaryBoxSpace = ScreenTools.defaultFontPixelWidth * 2
31 sw = _summaryBoxSpace * (idx - 1)
32 }
33 rw = _summaryRoot.width - sw
34 _summaryBoxWidth = rw / idx
35 }
36 }
37
38 function capitalizeWords(sentence) {
39 return sentence.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
40 }
41
42 QGCPalette {
43 id: qgcPal
44 colorGroupEnabled: enabled
45 }
46
47 Component.onCompleted: {
48 computeSummaryBoxSize()
49 }
50
51 onWidthChanged: {
52 computeSummaryBoxSize()
53 }
54
55 QGCFlickable {
56 clip: true
57 anchors.fill: parent
58 contentHeight: summaryColumn.height
59 contentWidth: _summaryRoot.width
60 flickableDirection: Flickable.VerticalFlick
61
62 Column {
63 id: summaryColumn
64 width: _summaryRoot.width
65 spacing: ScreenTools.defaultFontPixelHeight
66
67 QGCLabel {
68 width: parent.width
69 wrapMode: Text.WordWrap
70 color: setupComplete ? qgcPal.text : qgcPal.warningText
71 font.bold: true
72 horizontalAlignment: Text.AlignHCenter
73 text: setupComplete ?
74 qsTr("Your vehicle configuration summary appears below. Select components on the left to review or fine-tune settings.") :
75 qsTr("WARNING: Configuration tasks remain before this vehicle is ready to fly. Open the red-marked components on the left to finish setup.")
76
77 property bool setupComplete: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.autopilotPlugin.setupComplete : false
78 }
79
80 Flow {
81 id: _flowCtl
82 width: _summaryRoot.width
83 spacing: _summaryBoxSpace
84
85 Repeater {
86 model: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.autopilotPlugin.vehicleComponents : undefined
87
88 // Outer summary item rectangle
89 Rectangle {
90 width: mainLayout.width + (_margins * 2)
91 height: mainLayout.height + (_margins * 2)
92 color: qgcPal.windowShade
93 visible: modelData.summaryQmlSource.toString() !== ""
94 border.width: 1
95 border.color: qgcPal.text
96
97 Component.onCompleted: {
98 border.color = Qt.rgba(border.color.r, border.color.g, border.color.b, 0.1)
99 }
100
101 readonly property real titleHeight: ScreenTools.defaultFontPixelHeight * 2
102
103 ColumnLayout {
104 id: mainLayout
105 anchors.margins: _margins
106 anchors.left: parent.left
107 anchors.top: parent.top
108 spacing: ScreenTools.defaultFontPixelHeight / 2
109
110 // Title bar
111 QGCButton {
112 Layout.fillWidth: true
113 Layout.preferredHeight: titleHeight
114 text: capitalizeWords(modelData.name)
115
116 // Setup indicator
117 Rectangle {
118 anchors.rightMargin: ScreenTools.defaultFontPixelWidth
119 anchors.right: parent.right
120 anchors.verticalCenter: parent.verticalCenter
121 width: ScreenTools.defaultFontPixelWidth * 1.75
122 height: width
123 radius: width / 2
124 color: modelData.setupComplete ? "#00d932" : "red"
125 visible: modelData.requiresSetup && modelData.setupSource !== ""
126 }
127
128 onClicked : {
129 if (modelData.setupSource !== "") {
130 setupView.showVehicleComponentPanel(modelData)
131 }
132 }
133 }
134
135 // Summary Qml
136 Loader {
137 id: summaryLoader
138 Layout.fillWidth: true
139 Layout.preferredWidth: item ? item.implicitWidth : 0
140 Layout.preferredHeight: item ? item.implicitHeight : 0
141 source: modelData.summaryQmlSource
142
143 property var vehicleComponent: modelData
144 }
145 }
146 }
147 }
148 }
149 }
150 }
151}