QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SetupPage.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4import QtQuick.Layouts
5
6import QGroundControl
7import QGroundControl.FactControls
8import QGroundControl.Controls
9
10/// Base view control for all Setup pages
11Item {
12 id: setupView
13 enabled: !_disableDueToArmed && !_disableDueToFlying
14
15 property alias pageComponent: pageLoader.sourceComponent
16 property string pageName: vehicleComponent ? vehicleComponent.name : ""
17 property string pageDescription: vehicleComponent ? vehicleComponent.description : ""
18 property real availableWidth: width - pageLoader.x
19 property real availableHeight: height - pageLoader.y
20 property bool showAdvanced: false
21 property alias advanced: advancedCheckBox.checked
22
23 property bool _vehicleIsRover: globals.activeVehicle ? globals.activeVehicle.rover : false
24 property bool _vehicleArmed: globals.activeVehicle ? globals.activeVehicle.armed : false
25 property bool _vehicleFlying: globals.activeVehicle ? globals.activeVehicle.flying : false
26 property bool _disableDueToArmed: vehicleComponent ? (!vehicleComponent.allowSetupWhileArmed && _vehicleArmed) : false
27 // FIXME: The _vehicleIsRover checkl is a hack to work around https://github.com/PX4/Firmware/issues/10969
28 property bool _disableDueToFlying: vehicleComponent ? (!_vehicleIsRover && !vehicleComponent.allowSetupWhileFlying && _vehicleFlying) : false
29 property string _disableReason: _disableDueToArmed ? qsTr("armed") : qsTr("flying")
30 property real _margins: ScreenTools.defaultFontPixelHeight * 0.5
31 property string _pageTitle: qsTr("%1 Config").arg(pageName)
32
33 Component.onCompleted: {
34 if(pageLoader.item && pageLoader.item.setupPageCompleted) {
35 pageLoader.item.setupPageCompleted()
36 }
37 }
38
39 QGCFlickable {
40 anchors.fill: parent
41 contentWidth: Math.max(availableWidth, pageLoader.x + pageLoader.item.width)
42 contentHeight: Math.max(availableHeight, pageLoader.y + pageLoader.item.height)
43 clip: true
44
45 RowLayout {
46 id: headingRow
47 width: availableWidth
48 spacing: _margins
49 layoutDirection: Qt.RightToLeft
50 visible: showAdvanced || (pageDescription !== "" && !ScreenTools.isShortScreen)
51
52 QGCCheckBox {
53 id: advancedCheckBox
54 text: qsTr("Advanced")
55 visible: showAdvanced
56 }
57
58 ColumnLayout {
59 spacing: _margins
60 Layout.fillWidth: true
61
62 QGCLabel {
63 Layout.fillWidth: true
64 font.pointSize: ScreenTools.largeFontPointSize
65 text: !setupView.enabled ? _pageTitle + "<font color=\"red\">" + qsTr(" (Disabled while the vehicle is %1)").arg(_disableReason) + "</font>" : _pageTitle
66 visible: !ScreenTools.isShortScreen
67 }
68
69 QGCLabel {
70 Layout.fillWidth: true
71 wrapMode: Text.WordWrap
72 text: pageDescription
73 visible: pageDescription !== "" && !ScreenTools.isShortScreen
74 }
75 }
76 }
77
78 Loader {
79 id: pageLoader
80 anchors.topMargin: _margins
81 anchors.top: headingRow.bottom
82 }
83
84 // Overlay to display when vehicle is armed and this setup page needs
85 // to be disabled
86 Rectangle {
87 visible: !setupView.enabled
88 anchors.fill: parent
89 color: "black"
90 opacity: 0.5
91 }
92 }
93}