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