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 {
31 function onMissingParamsFromFile(missingParams) {
32 QGroundControl.showMessageDialog(_root, qsTr("Missing Parameters"),
33 qsTr("The following parameters from the file were not found on the vehicle and were skipped: %1").arg(missingParams.join("\n")))
44 controller.searchText = ""
52 onTriggered: controller.refresh()
55 text: qsTr("Reset all to firmware's defaults")
56 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reset All"),
57 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."),
58 Dialog.Cancel | Dialog.Reset,
59 function() { controller.resetAllToDefaults() })
62 text: qsTr("Reset to vehicle's configuration defaults")
63 visible: !_activeVehicle.apmFirmware
64 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reset All"),
65 qsTr("Select Reset to reset all parameters to the vehicle's configuration defaults."),
66 Dialog.Cancel | Dialog.Reset,
67 function() { controller.resetAllToVehicleConfiguration() })
71 text: qsTr("Load from file for review...")
73 fileDialog.title = qsTr("Load Parameters")
74 fileDialog.openForLoad()
78 text: qsTr("Save to file...")
80 fileDialog.title = qsTr("Save Parameters")
81 fileDialog.openForSave()
86 text: qsTr("Clear all favorites")
87 onTriggered: controller.clearAllFavorites()
89 QGCMenuSeparator { visible: _showRCToParam }
91 text: qsTr("Clear all RC to Param")
92 onTriggered: _activeVehicle.clearAllParamMapRC()
93 visible: _showRCToParam
97 text: qsTr("Reboot Vehicle")
98 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reboot Vehicle"),
99 qsTr("Select Ok to reboot vehicle."),
100 Dialog.Cancel | Dialog.Ok,
101 function() { _activeVehicle.rebootVehicle() })
108 folder: _appSettings.parameterSavePath
109 nameFilters: [ qsTr("Parameter Files (*.%1)").arg(_appSettings.parameterFileExtension), qsTr("Mission Planner Files (*.param)"), qsTr("All Files (*)") ]
111 onAcceptedForSave: (file) => {
112 controller.saveToFile(file)
116 onAcceptedForLoad: (file) => {
118 if (controller.buildDiffFromFile(file)) {
119 parameterDiffDialogFactory.open()
124 QGCPopupDialogFactory {
125 id: editorDialogFactory
127 dialogComponent: editorDialogComponent
131 id: editorDialogComponent
133 ParameterEditorDialog {
134 fact: _editorDialogFact
135 showRCToParam: _showRCToParam
139 QGCPopupDialogFactory {
140 id: parameterDiffDialogFactory
142 dialogComponent: parameterDiffDialog
146 id: parameterDiffDialog
148 ParameterDiffDialog {
149 paramController: _controller
155 anchors.left: parent.left
156 anchors.right: parent.right
159 Layout.alignment: Qt.AlignLeft
160 spacing: ScreenTools.defaultFontPixelWidth
164 placeholderText: qsTr("Search")
165 onDisplayTextChanged: controller.searchText = displayText
171 if(ScreenTools.isMobile) {
172 Qt.inputMethod.hide();
179 text: qsTr("Hide read-only")
180 checked: controller.hideReadOnly
181 onClicked: controller.hideReadOnly = checked
186 Layout.alignment: Qt.AlignRight
188 onClicked: toolsMenu.popup()
194 anchors.left: parent.left
195 anchors.right: parent.right
196 anchors.top: header.bottom
197 anchors.topMargin: _margins
199 QGCTabButton { text: qsTr("Full List") }
200 QGCTabButton { text: qsTr("Modified") }
201 QGCTabButton { text: qsTr("Favorites") }
203 onCurrentIndexChanged: {
204 controller.showModifiedOnly = (currentIndex === 1)
205 controller.showFavoritesOnly = (currentIndex === 2)
212 width: ScreenTools.defaultFontPixelWidth * 25
213 anchors.top: tabBar.bottom
214 anchors.topMargin: _margins
215 anchors.bottom: parent.bottom
218 contentHeight: groupedViewCategoryColumn.height
219 flickableDirection: Flickable.VerticalFlick
220 visible: !_searchFilter
223 id: groupedViewCategoryColumn
224 anchors.left: parent.left
225 anchors.right: parent.right
226 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
229 model: controller.categories
232 Layout.fillWidth: true
233 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
238 anchors.left: parent.left
239 anchors.right: parent.right
241 checked: object == controller.currentCategory
245 controller.currentCategory = object
251 model: categoryHeader.checked ? object.groups : 0
254 width: ScreenTools.defaultFontPixelWidth * 25
257 checked: object == controller.currentGroup
261 if (!checked) _rowWidth = 10
263 controller.currentGroup = object
272 HorizontalHeaderView {
274 anchors.left: tableView.left
275 anchors.right: tableView.right
276 anchors.top: tabBar.bottom
277 anchors.topMargin: _margins
281 delegate: Rectangle {
282 implicitWidth: column === 0 ? ScreenTools.implicitCheckBoxHeight + ScreenTools.defaultFontPixelWidth
283 : headerLabel.contentWidth + ScreenTools.defaultFontPixelWidth
284 implicitHeight: headerLabel.contentHeight + ScreenTools.defaultFontPixelHeight * 0.5
285 color: qgcPal.windowShade
289 anchors.left: parent.left
290 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
291 anchors.verticalCenter: parent.verticalCenter
298 anchors.top: parent.top
301 color: qgcPal.groupBorder
306 anchors.left: parent.left
307 height: parent.height
309 color: qgcPal.groupBorder
312 // Right border (last column only)
314 anchors.right: parent.right
315 height: parent.height
317 color: qgcPal.groupBorder
323 anchors.bottom: parent.bottom
326 color: qgcPal.groupBorder
333 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
334 anchors.top: headerView.bottom
335 anchors.bottom: parent.bottom
336 anchors.left: _searchFilter ? parent.left : groupScroll.right
337 anchors.right: parent.right
340 model: controller.parameters
344 // Qt is supposed to adjust column widths automatically when larger widths come into view.
345 // But it doesn't work. So we have to do it force a layout manually when we scroll.
350 onTriggered: tableView.forceLayout()
353 onTopRowChanged: forceLayoutTimer.start()
355 positionViewAtRow(0, TableView.AlignLeft | TableView.AlignTop)
356 forceLayoutTimer.start()
359 delegate: Rectangle {
360 implicitWidth: column === 0 ? ScreenTools.implicitCheckBoxHeight + ScreenTools.defaultFontPixelWidth
361 : column === 1 ? nameRow.implicitWidth + ScreenTools.defaultFontPixelWidth
362 : column === 2 ? ScreenTools.defaultFontPixelWidth * 16
363 : label.contentWidth + ScreenTools.defaultFontPixelWidth
364 implicitHeight: label.contentHeight + ScreenTools.defaultFontPixelHeight * 0.5
365 color: row % 2 === 0 ? "transparent" : qgcPal.windowShade
370 anchors.bottom: parent.bottom
373 color: qgcPal.groupBorder
378 anchors.left: parent.left
379 height: parent.height
381 color: qgcPal.groupBorder
384 // Right grid line (last column only)
386 anchors.right: parent.right
387 height: parent.height
389 color: qgcPal.groupBorder
394 visible: column === 0
395 anchors.centerIn: parent
396 checked: _root._favorites.indexOf(fact.name) >= 0
398 onClicked: controller.toggleFavorite(fact.name)
403 visible: column === 1
404 anchors.left: parent.left
405 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
406 anchors.verticalCenter: parent.verticalCenter
407 spacing: lockIcon.visible ? ScreenTools.defaultFontPixelWidth / 3 : 0
410 text: column === 1 ? display : ""
411 anchors.verticalCenter: parent.verticalCenter
416 visible: fact.readOnly
417 source: "qrc:/InstrumentValueIcons/lock-closed.svg"
419 width: ScreenTools.defaultFontPixelHeight * 0.8
421 sourceSize.width: width
422 anchors.verticalCenter: parent.verticalCenter
428 visible: column !== 0 && column !== 1
429 anchors.left: parent.left
430 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
431 anchors.verticalCenter: parent.verticalCenter
432 width: column == 2 ? ScreenTools.defaultFontPixelWidth * 15 : implicitWidth
433 text: column == 2 ? col1String() : display
434 color: column == 2 && fact.defaultValueAvailable && !fact.valueEqualsDefault ? qgcPal.modifiedParamValue : qgcPal.text
435 font.bold: column == 2 && fact.defaultValueAvailable && !fact.valueEqualsDefault
437 elide: column == 2 ? Text.ElideRight : Text.ElideNone
439 function col1String() {
440 if (fact.enumStrings.length === 0) {
441 return fact.valueString + " " + fact.units
443 if (fact.bitmaskStrings.length != 0) {
444 return fact.selectedBitmaskStrings.join(',')
446 return fact.enumStringValue
452 visible: column !== 0
453 onClicked: mouse => {
454 _editorDialogFact = fact
455 editorDialogFactory.open()