forked from mavlink/qgroundcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVehicleSummary.qml
156 lines (135 loc) · 6.36 KB
/
VehicleSummary.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QGroundControl 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.MultiVehicleManager 1.0
import QGroundControl.Palette 1.0
Rectangle {
id: _summaryRoot
anchors.fill: parent
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
color: qgcPal.window
property real _minSummaryW: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelWidth * 28 : ScreenTools.defaultFontPixelWidth * 36
property real _summaryBoxWidth: _minSummaryW
property real _summaryBoxSpace: ScreenTools.defaultFontPixelWidth * 2
function computeSummaryBoxSize() {
var sw = 0
var rw = 0
var idx = Math.floor(_summaryRoot.width / (_minSummaryW + ScreenTools.defaultFontPixelWidth))
if(idx < 1) {
_summaryBoxWidth = _summaryRoot.width
_summaryBoxSpace = 0
} else {
_summaryBoxSpace = 0
if(idx > 1) {
_summaryBoxSpace = ScreenTools.defaultFontPixelWidth * 2
sw = _summaryBoxSpace * (idx - 1)
}
rw = _summaryRoot.width - sw
_summaryBoxWidth = rw / idx
}
}
function capitalizeWords(sentence) {
return sentence.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
}
QGCPalette {
id: qgcPal
colorGroupEnabled: enabled
}
Component.onCompleted: {
computeSummaryBoxSize()
}
onWidthChanged: {
computeSummaryBoxSize()
}
QGCFlickable {
clip: true
anchors.fill: parent
contentHeight: summaryColumn.height
contentWidth: _summaryRoot.width
flickableDirection: Flickable.VerticalFlick
Column {
id: summaryColumn
width: _summaryRoot.width
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
color: setupComplete ? qgcPal.text : qgcPal.warningText
font.family: ScreenTools.demiboldFontFamily
horizontalAlignment: Text.AlignHCenter
text: setupComplete ?
qsTr("Below you will find a summary of the settings for your vehicle. To the left are the setup menus for each component.") :
qsTr("WARNING: Your vehicle requires setup prior to flight. Please resolve the items marked in red using the menu on the left.")
property bool setupComplete: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.autopilot.setupComplete : false
}
Flow {
id: _flowCtl
width: _summaryRoot.width
spacing: _summaryBoxSpace
Repeater {
model: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents : undefined
// Outer summary item rectangle
Rectangle {
width: _summaryBoxWidth
height: ScreenTools.defaultFontPixelHeight * 13
color: qgcPal.windowShade
visible: modelData.summaryQmlSource.toString() !== ""
border.width: 1
border.color: qgcPal.text
Component.onCompleted: {
border.color = Qt.rgba(border.color.r, border.color.g, border.color.b, 0.1)
}
readonly property real titleHeight: ScreenTools.defaultFontPixelHeight * 2
// Title bar
QGCButton {
id: titleBar
width: parent.width
height: titleHeight
text: capitalizeWords(modelData.name)
// Setup indicator
Rectangle {
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
width: ScreenTools.defaultFontPixelWidth * 1.75
height: width
radius: width / 2
color: modelData.setupComplete ? "#00d932" : "red"
visible: modelData.requiresSetup && modelData.setupSource !== ""
}
onClicked : {
console.log(modelData.setupSource)
if (modelData.setupSource !== "") {
setupView.showVehicleComponentPanel(modelData)
}
}
}
// Summary Qml
Rectangle {
anchors.top: titleBar.bottom
width: parent.width
Loader {
anchors.fill: parent
anchors.margins: ScreenTools.defaultFontPixelWidth
source: modelData.summaryQmlSource
}
}
}
}
}
}
}
}