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 ///< 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
23 ParameterEditorController {
34 controller.searchText = ""
42 onTriggered: controller.refresh()
45 text: qsTr("Reset all to firmware's defaults")
46 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reset All"),
47 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."),
48 Dialog.Cancel | Dialog.Reset,
49 function() { controller.resetAllToDefaults() })
52 text: qsTr("Reset to vehicle's configuration defaults")
53 visible: !_activeVehicle.apmFirmware
54 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reset All"),
55 qsTr("Select Reset to reset all parameters to the vehicle's configuration defaults."),
56 Dialog.Cancel | Dialog.Reset,
57 function() { controller.resetAllToVehicleConfiguration() })
61 text: qsTr("Load from file for review...")
63 fileDialog.title = qsTr("Load Parameters")
64 fileDialog.openForLoad()
68 text: qsTr("Save to file...")
70 fileDialog.title = qsTr("Save Parameters")
71 fileDialog.openForSave()
74 QGCMenuSeparator { visible: _showRCToParam }
76 text: qsTr("Clear all RC to Param")
77 onTriggered: _activeVehicle.clearAllParamMapRC()
78 visible: _showRCToParam
82 text: qsTr("Reboot Vehicle")
83 onTriggered: QGroundControl.showMessageDialog(_root, qsTr("Reboot Vehicle"),
84 qsTr("Select Ok to reboot vehicle."),
85 Dialog.Cancel | Dialog.Ok,
86 function() { _activeVehicle.rebootVehicle() })
93 folder: _appSettings.parameterSavePath
94 nameFilters: [ qsTr("Parameter Files (*.%1)").arg(_appSettings.parameterFileExtension) , qsTr("All Files (*)") ]
96 onAcceptedForSave: (file) => {
97 controller.saveToFile(file)
101 onAcceptedForLoad: (file) => {
103 if (controller.buildDiffFromFile(file)) {
104 parameterDiffDialogFactory.open()
109 QGCPopupDialogFactory {
110 id: editorDialogFactory
112 dialogComponent: editorDialogComponent
116 id: editorDialogComponent
118 ParameterEditorDialog {
119 fact: _editorDialogFact
120 showRCToParam: _showRCToParam
124 QGCPopupDialogFactory {
125 id: parameterDiffDialogFactory
127 dialogComponent: parameterDiffDialog
131 id: parameterDiffDialog
133 ParameterDiffDialog {
134 paramController: _controller
140 anchors.left: parent.left
141 anchors.right: parent.right
144 Layout.alignment: Qt.AlignLeft
145 spacing: ScreenTools.defaultFontPixelWidth
149 placeholderText: qsTr("Search")
150 onDisplayTextChanged: controller.searchText = displayText
156 if(ScreenTools.isMobile) {
157 Qt.inputMethod.hide();
164 text: qsTr("Show modified only")
165 checked: controller.showModifiedOnly
166 onClicked: controller.showModifiedOnly = checked
167 visible: QGroundControl.multiVehicleManager.activeVehicle.px4Firmware
172 Layout.alignment: Qt.AlignRight
174 onClicked: toolsMenu.popup()
181 width: ScreenTools.defaultFontPixelWidth * 25
182 anchors.top: header.bottom
183 anchors.bottom: parent.bottom
186 contentHeight: groupedViewCategoryColumn.height
187 flickableDirection: Flickable.VerticalFlick
188 visible: !_searchFilter
191 id: groupedViewCategoryColumn
192 anchors.left: parent.left
193 anchors.right: parent.right
194 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
197 model: controller.categories
200 Layout.fillWidth: true
201 spacing: Math.ceil(ScreenTools.defaultFontPixelHeight * 0.25)
206 anchors.left: parent.left
207 anchors.right: parent.right
209 checked: object == controller.currentCategory
213 controller.currentCategory = object
219 model: categoryHeader.checked ? object.groups : 0
222 width: ScreenTools.defaultFontPixelWidth * 25
225 checked: object == controller.currentGroup
229 if (!checked) _rowWidth = 10
231 controller.currentGroup = object
242 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
243 anchors.top: header.bottom
244 anchors.bottom: parent.bottom
245 anchors.left: _searchFilter ? parent.left : groupScroll.right
246 anchors.right: parent.right
247 columnSpacing: ScreenTools.defaultFontPixelWidth
248 rowSpacing: ScreenTools.defaultFontPixelHeight / 4
249 model: controller.parameters
253 // Qt is supposed to adjust column widths automatically when larger widths come into view.
254 // But it doesn't work. So we have to do it force a layout manually when we scroll.
259 onTriggered: tableView.forceLayout()
262 onTopRowChanged: forceLayoutTimer.start()
264 positionViewAtRow(0, TableView.AlignLeft | TableView.AlignTop)
265 forceLayoutTimer.start()
269 implicitWidth: label.contentWidth
270 implicitHeight: label.contentHeight
275 width: column == 1 ? ScreenTools.defaultFontPixelWidth * 15 : contentWidth
276 text: column == 1 ? col1String() : display
277 color: column == 1 ? col1Color() : qgcPal.text
279 elide: column == 1 ? Text.ElideRight : Text.ElideNone
281 Component.onCompleted: {
283 if (tableView.columnWidth(column) < width) {
284 console.log("setColumnWidth", column, width)
285 tableView.setColumnWidth(column, width)
289 function col1String() {
290 if (fact.enumStrings.length === 0) {
291 return fact.valueString + " " + fact.units
293 if (fact.bitmaskStrings.length != 0) {
294 return fact.selectedBitmaskStrings.join(',')
296 return fact.enumStringValue
299 function col1Color() {
300 if (fact.defaultValueAvailable) {
301 return fact.valueEqualsDefault ? qgcPal.text : qgcPal.warningText
310 onClicked: mouse => {
311 _editorDialogFact = fact
312 editorDialogFactory.open()