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()
188 anchors.left: parent.left
189 anchors.right: parent.right
190 anchors.top: header.bottom
191 anchors.topMargin: _margins
193 QGCTabButton { text: qsTr("Full List") }
194 QGCTabButton { text: qsTr("Modified") }
195 QGCTabButton { text: qsTr("Favorites") }
197 onCurrentIndexChanged: {
198 controller.showModifiedOnly = (currentIndex === 1)
199 controller.showFavoritesOnly = (currentIndex === 2)
206 width: ScreenTools.defaultFontPixelWidth * 25
207 anchors.top: tabBar.bottom
208 anchors.topMargin: _margins
209 anchors.bottom: parent.bottom
212 contentHeight: groupedViewCategoryColumn.height
213 flickableDirection: Flickable.VerticalFlick
214 visible: !_searchFilter
217 id: groupedViewCategoryColumn
218 anchors.left: parent.left
219 anchors.right: parent.right
220 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
223 model: controller.categories
226 Layout.fillWidth: true
227 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
232 anchors.left: parent.left
233 anchors.right: parent.right
235 checked: object == controller.currentCategory
239 controller.currentCategory = object
245 model: categoryHeader.checked ? object.groups : 0
248 width: ScreenTools.defaultFontPixelWidth * 25
251 checked: object == controller.currentGroup
255 if (!checked) _rowWidth = 10
257 controller.currentGroup = object
266 HorizontalHeaderView {
268 anchors.left: tableView.left
269 anchors.right: tableView.right
270 anchors.top: tabBar.bottom
271 anchors.topMargin: _margins
275 delegate: Rectangle {
276 implicitWidth: column === 0 ? ScreenTools.implicitCheckBoxHeight + ScreenTools.defaultFontPixelWidth
277 : headerLabel.contentWidth + ScreenTools.defaultFontPixelWidth
278 implicitHeight: headerLabel.contentHeight + ScreenTools.defaultFontPixelHeight * 0.5
279 color: qgcPal.windowShade
283 anchors.left: parent.left
284 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
285 anchors.verticalCenter: parent.verticalCenter
292 anchors.top: parent.top
295 color: qgcPal.groupBorder
300 anchors.left: parent.left
301 height: parent.height
303 color: qgcPal.groupBorder
306 // Right border (last column only)
308 anchors.right: parent.right
309 height: parent.height
311 color: qgcPal.groupBorder
317 anchors.bottom: parent.bottom
320 color: qgcPal.groupBorder
327 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
328 anchors.top: headerView.bottom
329 anchors.bottom: parent.bottom
330 anchors.left: _searchFilter ? parent.left : groupScroll.right
331 anchors.right: parent.right
334 model: controller.parameters
338 // Qt is supposed to adjust column widths automatically when larger widths come into view.
339 // But it doesn't work. So we have to do it force a layout manually when we scroll.
344 onTriggered: tableView.forceLayout()
347 onTopRowChanged: forceLayoutTimer.start()
349 positionViewAtRow(0, TableView.AlignLeft | TableView.AlignTop)
350 forceLayoutTimer.start()
353 delegate: Rectangle {
354 implicitWidth: column === 0 ? ScreenTools.implicitCheckBoxHeight + ScreenTools.defaultFontPixelWidth
355 : column === 1 ? nameRow.implicitWidth + ScreenTools.defaultFontPixelWidth
356 : column === 2 ? ScreenTools.defaultFontPixelWidth * 16
357 : label.contentWidth + ScreenTools.defaultFontPixelWidth
358 implicitHeight: label.contentHeight + ScreenTools.defaultFontPixelHeight * 0.5
359 color: row % 2 === 0 ? "transparent" : qgcPal.windowShade
364 anchors.bottom: parent.bottom
367 color: qgcPal.groupBorder
372 anchors.left: parent.left
373 height: parent.height
375 color: qgcPal.groupBorder
378 // Right grid line (last column only)
380 anchors.right: parent.right
381 height: parent.height
383 color: qgcPal.groupBorder
388 visible: column === 0
389 anchors.centerIn: parent
390 checked: _root._favorites.indexOf(fact.name) >= 0
392 onClicked: controller.toggleFavorite(fact.name)
397 visible: column === 1
398 anchors.left: parent.left
399 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
400 anchors.verticalCenter: parent.verticalCenter
401 spacing: lockIcon.visible ? ScreenTools.defaultFontPixelWidth / 3 : 0
404 text: column === 1 ? display : ""
405 anchors.verticalCenter: parent.verticalCenter
410 visible: fact.readOnly
411 source: "qrc:/InstrumentValueIcons/lock-closed.svg"
413 width: ScreenTools.defaultFontPixelHeight * 0.8
415 sourceSize.width: width
416 anchors.verticalCenter: parent.verticalCenter
422 visible: column !== 0 && column !== 1
423 anchors.left: parent.left
424 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
425 anchors.verticalCenter: parent.verticalCenter
426 width: column == 2 ? ScreenTools.defaultFontPixelWidth * 15 : implicitWidth
427 text: column == 2 ? col1String() : display
428 color: column == 2 && fact.defaultValueAvailable && !fact.valueEqualsDefault ? qgcPal.modifiedParamValue : qgcPal.text
429 font.bold: column == 2 && fact.defaultValueAvailable && !fact.valueEqualsDefault
431 elide: column == 2 ? Text.ElideRight : Text.ElideNone
433 function col1String() {
434 if (fact.enumStrings.length === 0) {
435 return fact.valueString + " " + fact.units
437 if (fact.bitmaskStrings.length != 0) {
438 return fact.selectedBitmaskStrings.join(',')
440 return fact.enumStringValue
446 visible: column !== 0
447 onClicked: mouse => {
448 _editorDialogFact = fact
449 editorDialogFactory.open()