6import QGroundControl.Controls
11 anchors.rightMargin: ScreenTools.defaultFontPixelWidth
12 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
15 signal componentRequested(var vehicleComponent)
17 readonly property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle
18 readonly property var _components: _vehicle ? _vehicle.autopilotPlugin.vehicleComponents : []
19 // Components are listed in the order recommended for setting up a vehicle
20 readonly property var _requiredComponents: _components.filter(vehicleComponent => vehicleComponent.requiresSetup).sort((a, b) => a.setupOrder - b.setupOrder)
21 readonly property int _readyCount: _requiredComponents.filter(vehicleComponent => vehicleComponent.setupComplete).length
22 readonly property int _remainingCount: _requiredComponents.length - _readyCount
23 readonly property var _nextComponent: _findNextComponent()
24 readonly property real _minCardWidth: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelWidth * 28 : ScreenTools.defaultFontPixelWidth * 36
25 readonly property real _spacing: ScreenTools.defaultFontPixelHeight * 0.5
26 // Column counts come from the page width rather than the grid's own, which a grid cannot size itself from
27 readonly property real _panelContentWidth: width - _spacing * 2
28 readonly property real _readinessWidth: ScreenTools.defaultFontPixelWidth * 34
29 readonly property bool _wideTop: width >= ScreenTools.defaultFontPixelWidth * 90
30 readonly property real _checklistWidth: _panelContentWidth - _spacing * 2 - (_wideTop ? _readinessWidth + _spacing : 0)
32 function _findNextComponent() {
33 for (let i = 0; i < _requiredComponents.length; i++) {
34 const vehicleComponent = _requiredComponents[i]
35 if (!vehicleComponent.setupComplete && vehicleComponent.setupSource.toString() !== "") {
36 return vehicleComponent
44 colorGroupEnabled: enabled
49 contentHeight: summaryColumn.height
50 contentWidth: _summaryRoot.width
51 flickableDirection: Flickable.VerticalFlick
55 width: _summaryRoot.width
56 spacing: _summaryRoot._spacing
59 Layout.fillWidth: true
60 columns: _summaryRoot._wideTop ? 2 : 1
61 columnSpacing: _summaryRoot._spacing
62 rowSpacing: _summaryRoot._spacing
63 visible: _summaryRoot._requiredComponents.length > 0
66 Layout.fillHeight: true
67 Layout.preferredWidth: _summaryRoot._readinessWidth
68 implicitHeight: readinessLayout.implicitHeight + _summaryRoot._spacing * 2
69 color: qgcPal.windowPanel
70 border.color: qgcPal.borderSubtle
71 radius: ScreenTools.defaultBorderRadius * 2
76 anchors.margins: _summaryRoot._spacing
77 spacing: _summaryRoot._spacing
80 Layout.alignment: Qt.AlignHCenter
81 text: qsTr("Vehicle setup")
86 Layout.alignment: Qt.AlignHCenter
87 Layout.preferredWidth: ScreenTools.defaultFontPixelHeight * 7
88 Layout.preferredHeight: Layout.preferredWidth
90 readonly property real progress: _summaryRoot._readyCount / Math.max(1, _summaryRoot._requiredComponents.length)
91 readonly property real _lineWidth: ScreenTools.defaultFontPixelHeight * 0.6
93 onProgressChanged: requestPaint()
94 onWidthChanged: requestPaint()
96 const context = getContext("2d")
97 const center = width / 2
98 const radius = center - _lineWidth / 2
100 context.lineWidth = _lineWidth
101 context.strokeStyle = qgcPal.borderSubtle
103 context.arc(center, center, radius, 0, 2 * Math.PI)
106 context.strokeStyle = qgcPal.colorGreen
108 context.arc(center, center, radius, -Math.PI / 2, -Math.PI / 2 + 2 * Math.PI * progress)
115 function onPaletteChanged() {
121 anchors.centerIn: parent
125 Layout.alignment: Qt.AlignHCenter
126 text: qsTr("%1/%2").arg(_summaryRoot._readyCount).arg(_summaryRoot._requiredComponents.length)
127 font.pointSize: ScreenTools.largeFontPointSize
132 Layout.alignment: Qt.AlignHCenter
133 text: qsTr("required")
134 font.pointSize: ScreenTools.smallFontPointSize
135 color: qgcPal.textSecondary
141 Layout.alignment: Qt.AlignHCenter
142 text: _summaryRoot._remainingCount > 0 ?
143 qsTr("%n component(s) need setup", "", _summaryRoot._remainingCount) :
144 qsTr("Required setup complete")
145 textColor: _summaryRoot._remainingCount > 0 ? qgcPal.errorText : qgcPal.successText
149 objectName: "vehicleSummary_continueSetup"
150 Layout.alignment: Qt.AlignHCenter
152 text: _summaryRoot._nextComponent ? qsTr("Continue setup: %1").arg(_summaryRoot._nextComponent.name) : ""
153 visible: _summaryRoot._nextComponent !== null
154 onClicked: _summaryRoot.componentRequested(_summaryRoot._nextComponent)
160 Layout.fillWidth: true
161 Layout.fillHeight: true
162 implicitHeight: checklistLayout.implicitHeight + _summaryRoot._spacing * 2
163 color: qgcPal.windowPanel
164 border.color: qgcPal.borderSubtle
165 radius: ScreenTools.defaultBorderRadius * 2
170 anchors.margins: _summaryRoot._spacing
171 spacing: _summaryRoot._spacing
173 VehicleSummaryHeader {
174 text: qsTr("Required setup")
178 Layout.fillWidth: true
179 columns: Math.max(1, Math.floor(_summaryRoot._checklistWidth / (ScreenTools.defaultFontPixelWidth * 28)))
180 columnSpacing: ScreenTools.defaultFontPixelWidth
181 rowSpacing: ScreenTools.defaultFontPixelWidth
184 model: _summaryRoot._requiredComponents
187 objectName: "vehicleSummary_tile_" + modelData.name
189 done: modelData.setupComplete
190 next: modelData === _summaryRoot._nextComponent
191 clickable: modelData.setupSource.toString() !== ""
192 onClicked: _summaryRoot.componentRequested(modelData)
194 required property var modelData
200 Layout.fillWidth: true
201 Layout.fillHeight: true
202 wrapMode: Text.WordWrap
203 font.pointSize: ScreenTools.smallFontPointSize
204 color: qgcPal.textSecondary
205 text: qsTr("Select a component to open its setup page. The other components are listed below.")
212 Layout.fillWidth: true
213 implicitHeight: settingsLayout.implicitHeight + _summaryRoot._spacing * 2
214 color: qgcPal.windowPanel
215 border.color: qgcPal.borderSubtle
216 radius: ScreenTools.defaultBorderRadius * 2
221 anchors.margins: _summaryRoot._spacing
222 spacing: _summaryRoot._spacing
224 VehicleSummaryHeader {
225 text: qsTr("Current settings")
228 VehicleSummaryMasonry {
229 Layout.fillWidth: true
230 minColumnWidth: _summaryRoot._minCardWidth
231 spacing: _summaryRoot._spacing
232 model: _summaryRoot._components
234 delegate: VehicleSummaryCard {
235 vehicleComponent: modelData
237 onClicked: _summaryRoot.componentRequested(modelData)
239 required property var modelData