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 text: qsTr("Load from file for review...")
65 fileDialog.title = qsTr("Load Parameters")
66 fileDialog.openForLoad()
70 text: qsTr("Save to file...")
72 fileDialog.title = qsTr("Save Parameters")
73 fileDialog.openForSave()
78 text: qsTr("Clear all favorites")
79 onTriggered: controller.clearAllFavorites()
81 QGCMenuSeparator { visible: _showRCToParam }
83 text: qsTr("Clear all RC to Param")
84 onTriggered: _activeVehicle.clearAllParamMapRC()
85 visible: _showRCToParam
89 text: qsTr("Reboot Vehicle")
90 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reboot Vehicle"),
91 qsTr("Select Ok to reboot vehicle."),
92 Dialog.Cancel | Dialog.Ok,
93 function() { _activeVehicle.rebootVehicle() })
100 folder: _appSettings.parameterSavePath
101 nameFilters: [ qsTr("Parameter Files (*.%1)").arg(_appSettings.parameterFileExtension) , qsTr("All Files (*)") ]
103 onAcceptedForSave: (file) => {
104 controller.saveToFile(file)
108 onAcceptedForLoad: (file) => {
110 if (controller.buildDiffFromFile(file)) {
111 parameterDiffDialogFactory.open()
116 QGCPopupDialogFactory {
117 id: editorDialogFactory
119 dialogComponent: editorDialogComponent
123 id: editorDialogComponent
125 ParameterEditorDialog {
126 fact: _editorDialogFact
127 showRCToParam: _showRCToParam
131 QGCPopupDialogFactory {
132 id: parameterDiffDialogFactory
134 dialogComponent: parameterDiffDialog
138 id: parameterDiffDialog
140 ParameterDiffDialog {
141 paramController: _controller
147 anchors.left: parent.left
148 anchors.right: parent.right
151 Layout.alignment: Qt.AlignLeft
152 spacing: ScreenTools.defaultFontPixelWidth
156 placeholderText: qsTr("Search")
157 onDisplayTextChanged: controller.searchText = displayText
163 if(ScreenTools.isMobile) {
164 Qt.inputMethod.hide();
171 text: qsTr("Hide read-only")
172 checked: controller.hideReadOnly
173 onClicked: controller.hideReadOnly = checked
178 Layout.alignment: Qt.AlignRight
180 onClicked: toolsMenu.popup()
186 anchors.left: parent.left
187 anchors.right: parent.right
188 anchors.top: header.bottom
189 anchors.topMargin: _margins
191 QGCTabButton { text: qsTr("Full List") }
192 QGCTabButton { text: qsTr("Modified") }
193 QGCTabButton { text: qsTr("Favorites") }
195 onCurrentIndexChanged: {
196 controller.showModifiedOnly = (currentIndex === 1)
197 controller.showFavoritesOnly = (currentIndex === 2)
204 width: ScreenTools.defaultFontPixelWidth * 25
205 anchors.top: tabBar.bottom
206 anchors.topMargin: _margins
207 anchors.bottom: parent.bottom
210 contentHeight: groupedViewCategoryColumn.height
211 flickableDirection: Flickable.VerticalFlick
212 visible: !_searchFilter
215 id: groupedViewCategoryColumn
216 anchors.left: parent.left
217 anchors.right: parent.right
218 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
221 model: controller.categories
224 Layout.fillWidth: true
225 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
230 anchors.left: parent.left
231 anchors.right: parent.right
233 checked: object == controller.currentCategory
237 controller.currentCategory = object
243 model: categoryHeader.checked ? object.groups : 0
246 width: ScreenTools.defaultFontPixelWidth * 25
249 checked: object == controller.currentGroup
253 if (!checked) _rowWidth = 10
255 controller.currentGroup = object
264 HorizontalHeaderView {
266 anchors.left: tableView.left
267 anchors.right: tableView.right
268 anchors.top: tabBar.bottom
269 anchors.topMargin: _margins
273 delegate: Rectangle {
274 implicitWidth: column === 0 ? ScreenTools.implicitCheckBoxHeight + ScreenTools.defaultFontPixelWidth
275 : headerLabel.contentWidth + ScreenTools.defaultFontPixelWidth
276 implicitHeight: headerLabel.contentHeight + ScreenTools.defaultFontPixelHeight * 0.5
277 color: qgcPal.windowShade
281 anchors.left: parent.left
282 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
283 anchors.verticalCenter: parent.verticalCenter
290 anchors.top: parent.top
293 color: qgcPal.groupBorder
298 anchors.left: parent.left
299 height: parent.height
301 color: qgcPal.groupBorder
304 // Right border (last column only)
306 anchors.right: parent.right
307 height: parent.height
309 color: qgcPal.groupBorder
315 anchors.bottom: parent.bottom
318 color: qgcPal.groupBorder
325 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
326 anchors.top: headerView.bottom
327 anchors.bottom: parent.bottom
328 anchors.left: _searchFilter ? parent.left : groupScroll.right
329 anchors.right: parent.right
332 model: controller.parameters
336 // Qt is supposed to adjust column widths automatically when larger widths come into view.
337 // But it doesn't work. So we have to do it force a layout manually when we scroll.
342 onTriggered: tableView.forceLayout()
345 onTopRowChanged: forceLayoutTimer.start()
347 positionViewAtRow(0, TableView.AlignLeft | TableView.AlignTop)
348 forceLayoutTimer.start()
351 delegate: Rectangle {
352 implicitWidth: column === 0 ? ScreenTools.implicitCheckBoxHeight + ScreenTools.defaultFontPixelWidth
353 : column === 1 ? nameRow.implicitWidth + ScreenTools.defaultFontPixelWidth
354 : column === 2 ? ScreenTools.defaultFontPixelWidth * 16
355 : label.contentWidth + ScreenTools.defaultFontPixelWidth
356 implicitHeight: label.contentHeight + ScreenTools.defaultFontPixelHeight * 0.5
357 color: row % 2 === 0 ? "transparent" : qgcPal.windowShade
362 anchors.bottom: parent.bottom
365 color: qgcPal.groupBorder
370 anchors.left: parent.left
371 height: parent.height
373 color: qgcPal.groupBorder
376 // Right grid line (last column only)
378 anchors.right: parent.right
379 height: parent.height
381 color: qgcPal.groupBorder
386 visible: column === 0
387 anchors.centerIn: parent
388 checked: _root._favorites.indexOf(fact.name) >= 0
390 onClicked: controller.toggleFavorite(fact.name)
395 visible: column === 1
396 anchors.left: parent.left
397 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
398 anchors.verticalCenter: parent.verticalCenter
399 spacing: lockIcon.visible ? ScreenTools.defaultFontPixelWidth / 3 : 0
402 text: column === 1 ? display : ""
403 anchors.verticalCenter: parent.verticalCenter
408 visible: fact.readOnly
409 source: "qrc:/InstrumentValueIcons/lock-closed.svg"
411 width: ScreenTools.defaultFontPixelHeight * 0.8
413 sourceSize.width: width
414 anchors.verticalCenter: parent.verticalCenter
420 visible: column !== 0 && column !== 1
421 anchors.left: parent.left
422 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
423 anchors.verticalCenter: parent.verticalCenter
424 width: column == 2 ? ScreenTools.defaultFontPixelWidth * 15 : implicitWidth
425 text: column == 2 ? col1String() : display
426 color: column == 2 && fact.defaultValueAvailable && !fact.valueEqualsDefault ? qgcPal.modifiedParamValue : qgcPal.text
427 font.bold: column == 2 && fact.defaultValueAvailable && !fact.valueEqualsDefault
429 elide: column == 2 ? Text.ElideRight : Text.ElideNone
431 function col1String() {
432 if (fact.enumStrings.length === 0) {
433 return fact.valueString + " " + fact.units
435 if (fact.bitmaskStrings.length != 0) {
436 return fact.selectedBitmaskStrings.join(',')
438 return fact.enumStringValue
444 visible: column !== 0
445 onClicked: mouse => {
446 _editorDialogFact = fact
447 editorDialogFactory.open()