7import QGroundControl.Controls
8import QGroundControl.FactControls
13 property Fact _editorDialogFact: Fact { }
14 property int _rowHeight: ScreenTools.defaultFontPixelHeight * 2
15 property int _rowWidth: 10 // Dynamic adjusted at runtime
16 property bool _searchFilter: searchText.text.trim() != "" || controller.showModifiedOnly || controller.showFavoritesOnly ///< true: showing results of search
17 property var _searchResults ///< List of parameter names from search results
18 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
19 property bool _showRCToParam: _activeVehicle.px4Firmware
20 property var _appSettings: QGroundControl.settingsManager.appSettings
21 property var _controller: controller
22 property var _favorites: controller.favoriteParameterNames
23 property real _margins: ScreenTools.defaultFontPixelHeight / 2
25 ParameterEditorController {
36 controller.searchText = ""
44 onTriggered: controller.refresh()
47 text: qsTr("Reset all to firmware's defaults")
48 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reset All"),
49 qsTr("Select Reset to reset all parameters to their defaults.\n\nNote that this will also completely reset everything, including UAVCAN nodes, all vehicle settings, setup and calibrations."),
50 Dialog.Cancel | Dialog.Reset,
51 function() { controller.resetAllToDefaults() })
54 text: qsTr("Reset to vehicle's configuration defaults")
55 visible: !_activeVehicle.apmFirmware
56 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reset All"),
57 qsTr("Select Reset to reset all parameters to the vehicle's configuration defaults."),
58 Dialog.Cancel | Dialog.Reset,
59 function() { controller.resetAllToVehicleConfiguration() })
63 objectName: "parameterEditor_toolLoadFromFile"
64 text: qsTr("Load from file for review...")
66 fileDialog.title = qsTr("Load Parameters")
67 fileDialog.openForLoad()
71 text: qsTr("Save to file...")
73 fileDialog.title = qsTr("Save Parameters")
74 fileDialog.openForSave()
79 text: qsTr("Clear all favorites")
80 onTriggered: controller.clearAllFavorites()
82 QGCMenuSeparator { visible: _showRCToParam }
84 text: qsTr("Clear all RC to Param")
85 onTriggered: _activeVehicle.clearAllParamMapRC()
86 visible: _showRCToParam
90 text: qsTr("Reboot Vehicle")
91 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reboot Vehicle"),
92 qsTr("Select Ok to reboot vehicle."),
93 Dialog.Cancel | Dialog.Ok,
94 function() { _activeVehicle.rebootVehicle() })
101 folder: _appSettings.parameterSavePath
102 nameFilters: [ qsTr("Parameter Files (*.%1)").arg(_appSettings.parameterFileExtension), qsTr("Mission Planner Files (*.param)"), qsTr("All Files (*)") ]
104 onAcceptedForSave: (file) => {
105 controller.saveToFile(file)
109 onAcceptedForLoad: (file) => {
111 if (controller.buildDiffFromFile(file)) {
112 parameterDiffDialogFactory.open()
117 QGCPopupDialogFactory {
118 id: editorDialogFactory
120 dialogComponent: editorDialogComponent
124 id: editorDialogComponent
126 ParameterEditorDialog {
127 fact: _editorDialogFact
128 showRCToParam: _showRCToParam
132 QGCPopupDialogFactory {
133 id: parameterDiffDialogFactory
135 dialogComponent: parameterDiffDialog
139 id: parameterDiffDialog
141 ParameterDiffDialog {
142 paramController: _controller
148 anchors.left: parent.left
149 anchors.right: parent.right
152 Layout.alignment: Qt.AlignLeft
153 spacing: ScreenTools.defaultFontPixelWidth
157 placeholderText: qsTr("Search")
158 onDisplayTextChanged: controller.searchText = displayText
164 if(ScreenTools.isMobile) {
165 Qt.inputMethod.hide();
172 text: qsTr("Hide read-only")
173 checked: controller.hideReadOnly
174 onClicked: controller.hideReadOnly = checked
179 Layout.alignment: Qt.AlignRight
180 objectName: "parameterEditor_toolsButton"
182 onClicked: toolsMenu.popup()
187 anchors.left: parent.left
188 anchors.right: parent.right
189 anchors.top: header.bottom
190 anchors.topMargin: _margins
191 anchors.bottom: parent.bottom
195 onCurrentIndexChanged: {
196 controller.showModifiedOnly = (currentIndex === 1)
197 controller.showFavoritesOnly = (currentIndex === 2)
200 QGCGroupBoxTab { title: qsTr("Full List") }
201 QGCGroupBoxTab { title: qsTr("Modified") }
202 QGCGroupBoxTab { title: qsTr("Favorites") }
205 Layout.fillWidth: true
206 Layout.fillHeight: true
211 width: ScreenTools.defaultFontPixelWidth * 25
212 anchors.top: parent.top
213 anchors.bottom: parent.bottom
216 contentHeight: groupedViewCategoryColumn.height
217 flickableDirection: Flickable.VerticalFlick
218 visible: !_searchFilter
221 id: groupedViewCategoryColumn
222 anchors.left: parent.left
223 anchors.right: parent.right
224 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
227 model: controller.categories
230 Layout.fillWidth: true
231 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
236 anchors.left: parent.left
237 anchors.right: parent.right
239 checked: object == controller.currentCategory
243 controller.currentCategory = object
249 model: categoryHeader.checked ? object.groups : 0
252 width: ScreenTools.defaultFontPixelWidth * 25
255 checked: object == controller.currentGroup
259 if (!checked) _rowWidth = 10
261 controller.currentGroup = object
270 HorizontalHeaderView {
272 anchors.left: tableView.left
273 anchors.right: tableView.right
274 anchors.top: parent.top
278 delegate: Rectangle {
279 implicitWidth: column === 0 ? ScreenTools.implicitCheckBoxHeight + ScreenTools.defaultFontPixelWidth
280 : headerLabel.contentWidth + ScreenTools.defaultFontPixelWidth
281 implicitHeight: headerLabel.contentHeight + ScreenTools.defaultFontPixelHeight * 0.5
282 color: qgcPal.windowCard
286 anchors.left: parent.left
287 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
288 anchors.verticalCenter: parent.verticalCenter
295 anchors.top: parent.top
298 color: qgcPal.borderSubtle
303 anchors.left: parent.left
304 height: parent.height
306 color: qgcPal.borderSubtle
309 // Right border (last column only)
311 anchors.right: parent.right
312 height: parent.height
314 color: qgcPal.borderSubtle
320 anchors.bottom: parent.bottom
323 color: qgcPal.borderSubtle
330 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
331 anchors.top: headerView.bottom
332 anchors.bottom: parent.bottom
333 anchors.left: _searchFilter ? parent.left : groupScroll.right
334 anchors.right: parent.right
337 model: controller.parameters
341 // Qt is supposed to adjust column widths automatically when larger widths come into view.
342 // But it doesn't work. So we have to do it force a layout manually when we scroll.
347 onTriggered: tableView.forceLayout()
350 onTopRowChanged: forceLayoutTimer.start()
352 positionViewAtRow(0, TableView.AlignLeft | TableView.AlignTop)
353 forceLayoutTimer.start()
356 delegate: Rectangle {
357 implicitWidth: column === 0 ? ScreenTools.implicitCheckBoxHeight + ScreenTools.defaultFontPixelWidth
358 : column === 1 ? nameRow.implicitWidth + ScreenTools.defaultFontPixelWidth
359 : column === 2 ? ScreenTools.defaultFontPixelWidth * 16
360 : label.contentWidth + ScreenTools.defaultFontPixelWidth
361 implicitHeight: label.contentHeight + ScreenTools.defaultFontPixelHeight * 0.5
362 color: row % 2 === 0 ? "transparent" : qgcPal.windowCard
367 anchors.bottom: parent.bottom
370 color: qgcPal.borderSubtle
375 anchors.left: parent.left
376 height: parent.height
378 color: qgcPal.borderSubtle
381 // Right grid line (last column only)
383 anchors.right: parent.right
384 height: parent.height
386 color: qgcPal.borderSubtle
391 visible: column === 0
392 anchors.centerIn: parent
393 checked: _root._favorites.indexOf(fact.name) >= 0
395 onClicked: controller.toggleFavorite(fact.name)
400 visible: column === 1
401 anchors.left: parent.left
402 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
403 anchors.verticalCenter: parent.verticalCenter
404 spacing: lockIcon.visible ? ScreenTools.defaultFontPixelWidth / 3 : 0
407 text: column === 1 ? display : ""
408 anchors.verticalCenter: parent.verticalCenter
413 visible: fact.readOnly
414 source: "qrc:/InstrumentValueIcons/lock-closed.svg"
415 color: qgcPal.textPrimary
416 width: ScreenTools.defaultFontPixelHeight * 0.8
418 sourceSize.width: width
419 anchors.verticalCenter: parent.verticalCenter
425 visible: column !== 0 && column !== 1
426 anchors.left: parent.left
427 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
428 anchors.verticalCenter: parent.verticalCenter
429 width: column == 2 ? ScreenTools.defaultFontPixelWidth * 15 : implicitWidth
430 text: column == 2 ? col1String() : display
431 color: column == 2 && fact.defaultValueAvailable && !fact.valueEqualsDefault ? qgcPal.modifiedParamValue : qgcPal.textPrimary
432 font.bold: column == 2 && fact.defaultValueAvailable && !fact.valueEqualsDefault
434 elide: column == 2 ? Text.ElideRight : Text.ElideNone
436 function col1String() {
437 if (fact.enumStrings.length === 0) {
438 return fact.valueString + " " + fact.units
440 if (fact.bitmaskStrings.length != 0) {
441 return fact.selectedBitmaskStrings.join(',')
443 return fact.enumStringValue
449 visible: column !== 0
450 onClicked: mouse => {
451 _editorDialogFact = fact
452 editorDialogFactory.open()