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 _summaryBoxSpace: ScreenTools.defaultFontPixelWidth * 2
17 property real _margins: ScreenTools.defaultFontPixelHeight / 2
18
19 function capitalizeWords(sentence) {
20 return sentence.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
21 }
22
23 QGCPalette {
24 id: qgcPal
25 colorGroupEnabled: enabled
26 }
27
28 QGCFlickable {
29 clip: true
30 anchors.fill: parent
31 contentHeight: summaryColumn.height
32 contentWidth: _summaryRoot.width
33 flickableDirection: Flickable.VerticalFlick
34
35 Column {
36 id: summaryColumn
37 width: _summaryRoot.width
38 spacing: ScreenTools.defaultFontPixelHeight
39
40 QGCLabel {
41 width: parent.width
42 wrapMode: Text.WordWrap
43 color: setupComplete ? qgcPal.text : qgcPal.warningText
44 font.bold: true
45 horizontalAlignment: Text.AlignHCenter
46 text: setupComplete ?
47 qsTr("Your vehicle configuration summary appears below. Select components on the left to review or fine-tune settings.") :
48 qsTr("WARNING: Configuration tasks remain before this vehicle is ready to fly. Open the red-marked components on the left to finish setup.")
49
50 property bool setupComplete: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.autopilotPlugin.setupComplete : false
51 }
52
53 GridLayout {
54 id: _gridCtl
55 width: _summaryRoot.width
56 columns: Math.max(1, Math.floor((_summaryRoot.width + _summaryBoxSpace) / (_minSummaryW + _summaryBoxSpace)))
57 columnSpacing: _summaryBoxSpace
58 rowSpacing: ScreenTools.defaultFontPixelHeight
59
60 Repeater {
61 model: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.autopilotPlugin.vehicleComponents : undefined
62
63 // Outer summary item rectangle
64 Rectangle {
65 Layout.fillWidth: true
66 Layout.fillHeight: true
67 implicitWidth: _minSummaryW
68 implicitHeight: mainLayout.implicitHeight + (_margins * 2)
69 radius: ScreenTools.defaultFontPixelHeight / 4
70 color: qgcPal.windowShade
71 visible: modelData.summaryQmlSource.toString() !== ""
72 border.width: 1
73 border.color: Qt.rgba(qgcPal.text.r, qgcPal.text.g, qgcPal.text.b, 0.1)
74
75 readonly property real titleHeight: ScreenTools.defaultFontPixelHeight * 2
76
77 ColumnLayout {
78 id: mainLayout
79 anchors.margins: _margins
80 anchors.left: parent.left
81 anchors.right: parent.right
82 anchors.top: parent.top
83 spacing: ScreenTools.defaultFontPixelHeight / 2
84
85 // Title bar
86 QGCButton {
87 Layout.fillWidth: true
88 Layout.preferredHeight: titleHeight
89 text: capitalizeWords(modelData.name)
90 rightPadding: setupIndicator.visible ? setupIndicator.width + ScreenTools.defaultFontPixelWidth * 2 : leftPadding
91
92 // Setup indicator
93 Rectangle {
94 id: setupIndicator
95 anchors.rightMargin: ScreenTools.defaultFontPixelWidth
96 anchors.right: parent.right
97 anchors.verticalCenter: parent.verticalCenter
98 width: ScreenTools.defaultFontPixelWidth * 1.5
99 height: width
100 radius: width / 2
101 color: modelData.setupComplete ? qgcPal.colorGreen : qgcPal.colorRed
102 visible: modelData.requiresSetup && modelData.setupSource !== ""
103 }
104
105 onClicked : {
106 if (modelData.setupSource !== "") {
107 setupView.showVehicleComponentPanel(modelData)
108 }
109 }
110 }
111
112 // Summary Qml
113 Loader {
114 id: summaryLoader
115 Layout.fillWidth: true
116 Layout.preferredWidth: item ? item.implicitWidth : 0
117 Layout.preferredHeight: item ? item.implicitHeight : 0
118 source: modelData.summaryQmlSource
119
120 property var vehicleComponent: modelData
121 }
122 }
123 }
124 }
125 }
126 }
127 }
128}