5import QGroundControl.Controls
6import QGroundControl.FactControls
8import "PX4ConfigRows.js" as ConfigRows
9import "PX4FailsafeRows.js" as FailsafeRows
13 pageComponent: pageComponent
15 property bool _showActiveOnly: false
16 // Parameter values when the page first showed them, so a reboot is only flagged after a change
17 property var _initialValues: Object.create(null)
19 readonly property var _vehicle: controller.vehicle
20 readonly property var _allRows: FailsafeRows.failsafeRows()
21 readonly property var _rows: ConfigRows.visibleRows(
24 "multiRotor": _vehicle ? _vehicle.multiRotor : false,
25 "fixedWing": _vehicle ? _vehicle.fixedWing : false,
26 "vtol": _vehicle ? _vehicle.vtol : false
28 function (name) { return controller.parameterExists(-1, name) })
29 readonly property var _groups: ConfigRows.groupRows(_rows)
30 readonly property int _shownCount: {
32 for (const row of _rows) {
40 function _fact(name) {
41 return controller.getParameterFact(-1, name, false)
44 function _rowActive(row) {
45 return ConfigRows.isRowActive(row, function (name) {
46 const fact = _fact(name)
47 return fact ? fact.rawValue : undefined
51 function _rowShown(row) {
52 return !_showActiveOnly || _rowActive(row)
55 function _groupShown(group) {
56 return group.rows.some(row => _rowShown(row))
61 // Reboot-required settings are marked on the page instead
62 suppressRebootMessage: true
69 component SeverityDot: Rectangle {
70 property string severity: "none"
72 implicitWidth: ScreenTools.defaultFontPixelHeight * 0.5
73 implicitHeight: implicitWidth
74 radius: ScreenTools.defaultBorderRadius / 2
77 case "warning": return dotPal.colorYellow
78 case "fallback": return dotPal.colorYellowGreen
79 case "hold": return dotPal.colorBlue
80 case "return": return dotPal.accent
81 case "land": return dotPal.colorOrange
82 case "terminate": return dotPal.colorRed
83 default: return dotPal.textSecondary
96 width: Math.max(availableWidth, implicitWidth)
100 ConfigRowsFilterBar {
101 objectName: "failsafes_filter"
102 filterLabels: [ qsTr("All Failsafes"), qsTr("Active") ]
103 filterIndex: _showActiveOnly ? 1 : 0
104 summary: _showActiveOnly ?
105 qsTr("Showing %1 of %2 failsafes.").arg(_shownCount).arg(_rows.length) :
106 qsTr("Showing all %1 failsafes.").arg(_rows.length)
107 onFilterActivated: (index) => { _showActiveOnly = index === 1 }
111 spacing: ScreenTools.defaultFontPixelWidth * 2
115 { "severity": "warning", "text": qsTr("Warning") },
116 { "severity": "hold", "text": qsTr("Hold") },
117 { "severity": "fallback", "text": qsTr("Mode fallback") },
118 { "severity": "return", "text": qsTr("Return") },
119 { "severity": "land", "text": qsTr("Land") },
120 { "severity": "terminate", "text": qsTr("Terminate / Disarm") }
124 spacing: ScreenTools.defaultFontPixelWidth / 2
126 required property var modelData
129 severity: modelData.severity
134 font.pointSize: ScreenTools.smallFontPointSize
135 color: qgcPal.textSecondary
142 // A wrapped label reports its unwrapped width as its implicit width, which would widen the page
143 Layout.preferredWidth: 0
144 text: qsTr("Return actions use the settings on the Return & Land page.")
149 groupShown: failsafesPage._groupShown
150 objectNamePrefix: "failsafes"
152 rowDelegate: ConfigRow {
154 objectName: "failsafes_row_" + row.id
157 active: _rowActive(row)
158 showSeparator: index > 0
159 visible: _rowShown(row)
161 required property var modelData
162 required property int index
164 readonly property var row: modelData
167 text: qsTr("Warning only")
168 visible: rowLayout.row.warnOnly
172 text: rowLayout.row.description
175 cellsData: Repeater {
176 model: rowLayout.row.cells
181 factFor: failsafesPage._fact
182 initialValues: failsafesPage._initialValues
183 objectNamePrefix: "failsafes"
184 enumLeading: modelData.severity !== undefined ? severityDotComponent : null
186 required property var modelData
189 id: severityDotComponent
192 severity: FailsafeRows.actionSeverity(paramCell.modelData, paramCell.fact ? paramCell.fact.rawValue : undefined)
196 extraData: RowLayout {
197 spacing: ScreenTools.defaultFontPixelWidth
198 visible: paramCell.modelData.fixed !== undefined
201 severity: FailsafeRows.actionSeverity(paramCell.modelData)
202 visible: paramCell.modelData.severity !== undefined
206 text: paramCell.modelData.fixed !== undefined ? paramCell.modelData.fixed : ""