7import QGroundControl.Controls
8import QGroundControl.FactControls
12 title: fact.componentId > 0 ? fact.name : qsTr("Value Editor")
14 buttons: fact.readOnly ? Dialog.Close : (Dialog.Save | (validate ? 0 : Dialog.Cancel))
17 property bool showRCToParam: false
18 property bool validate: false
19 property string validateValue
20 property bool setFocus: true ///< true: focus is set to text field on display, false: focus not set (works around strange virtual keyboard bug with FactValueSlider
22 property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 20
23 property bool _longDescriptionAvailable: fact.longDescription != ""
24 property bool _editingParameter: fact.componentId != 0
25 property bool _allowForceSave: QGroundControl.corePlugin.showAdvancedUI && _editingParameter
26 property bool _allowDefaultReset: fact.defaultValueAvailable
27 property bool _showCombo: fact.enumStrings.length !== 0 && fact.bitmaskStrings.length === 0 && !validate
29 ParameterEditorController { id: controller; }
31 QGCPalette { id: qgcPal; colorGroupEnabled: true }
34 if (fact.readOnly) return
35 if (bitmaskColumn.visible && !manualEntry.checked) {
36 fact.value = bitmaskValue();
37 fact.valueChanged(fact.value)
38 } else if (factCombo.visible && !manualEntry.checked) {
39 fact.enumIndex = factCombo.currentIndex
41 var errorString = fact.validate(valueField.text, forceSave.checked)
42 if (errorString === "") {
43 fact.value = valueField.text
44 fact.valueChanged(fact.value)
46 validationError.text = errorString
47 if (_allowForceSave) {
48 forceSave.visible = true
55 function bitmaskValue() {
57 for (var i = 0; i < fact.bitmaskValues.length; ++i) {
58 var checkbox = bitmaskRepeater.itemAt(i)
59 if (checkbox.checked) {
60 value |= fact.bitmaskValues[i];
66 Component.onCompleted: {
68 valueField.text = validateValue
69 validationError.text = fact.validate(validateValue, false /* convertOnly */)
70 if (_allowForceSave) {
71 forceSave.visible = true
74 valueField.text = fact.valueString
79 width: Math.min(mainWindow.width * .75, Math.max(ScreenTools.defaultFontPixelWidth * 60, editRow.width))
80 spacing: globals.defaultTextHeight
83 Layout.fillWidth: true
84 wrapMode: Text.WordWrap
85 text: qsTr("This parameter is read-only and cannot be modified.")
86 visible: fact.readOnly
91 Layout.fillWidth: true
92 wrapMode: Text.WordWrap
93 color: qgcPal.warningText
99 spacing: ScreenTools.defaultFontPixelWidth
100 visible: !fact.readOnly
104 width: _editFieldWidth
105 unitsLabel: fact.units
106 showUnits: fact.units != ""
107 focus: setFocus && visible
108 inputMethodHints: (fact.typeIsString || ScreenTools.isiOS) ? // iOS numeric keyboard has no done button, we can't use it
110 Qt.ImhFormattedNumbersOnly // Forces use of virtual numeric keyboard
111 visible: !_showCombo || validate || manualEntry.checked
116 width: _editFieldWidth
117 model: fact.enumStrings
120 focus: setFocus && visible
122 Component.onCompleted: {
123 // We can't bind directly to fact.enumIndex since that would add an unknown value
124 // if there are no enum strings.
126 currentIndex = fact.enumIndex
130 onCurrentIndexChanged: {
131 if (currentIndex >=0 && currentIndex < model.length) {
132 valueField.text = fact.enumValues[currentIndex]
138 visible: _allowDefaultReset
139 text: qsTr("Reset To Default")
142 fact.value = fact.defaultValue
143 fact.valueChanged(fact.value)
150 visible: fact.readOnly
151 text: qsTr("Value: ") + fact.valueString + (fact.units != "" ? (" " + fact.units) : "")
156 spacing: ScreenTools.defaultFontPixelHeight / 2
157 visible: fact.bitmaskStrings.length > 0 && !fact.readOnly
161 model: fact.bitmaskStrings
163 delegate : QGCCheckBox {
165 checked : fact.value & fact.bitmaskValues[index]
168 valueField.text = bitmaskValue()
175 Layout.fillWidth: true
176 wrapMode: Text.WordWrap
177 visible: !longDescriptionLabel.visible
178 text: fact.shortDescription
182 id: longDescriptionLabel
183 Layout.fillWidth: true
184 wrapMode: Text.WordWrap
185 visible: fact.longDescription != ""
186 text: fact.longDescription
190 spacing: ScreenTools.defaultFontPixelWidth
194 text: qsTr("Min: ") + fact.minString
195 visible: !fact.minIsDefaultForType
199 text: qsTr("Max: ") + fact.maxString
200 visible: !fact.maxIsDefaultForType
204 text: qsTr("Default: ") + fact.defaultValueString
205 visible: _allowDefaultReset
210 visible: fact.vehicleRebootRequired
211 text: qsTr("Vehicle reboot required after change")
215 visible: fact.qgcRebootRequired
216 text: qsTr("Application restart required after change")
220 Layout.fillWidth: true
221 wrapMode: Text.WordWrap
222 text: qsTr("Warning: Modifying values while vehicle is in flight can lead to vehicle instability and possible vehicle loss. ") +
223 qsTr("Make sure you know what you are doing and double-check your values before Save!")
224 visible: fact.componentId != -1 && !fact.readOnly
230 text: qsTr("Force save (dangerous!)")
235 text: qsTr("Advanced settings")
236 visible: !fact.readOnly && (showRCToParam || factCombo.visible || bitmaskColumn.visible)
239 // Checkbox to allow manual entry of enumerated or bitmask parameters
242 visible: _advanced.checked && (factCombo.visible || bitmaskColumn.visible)
243 text: qsTr("Manual Entry")
246 valueField.text = fact.valueString
251 text: qsTr("Set RC to Param")
252 visible: _advanced.checked && !validate && showRCToParam
253 onClicked: rcToParamDialogFactory.open()
257 QGCPopupDialogFactory {
258 id: rcToParamDialogFactory
260 dialogComponent: rcToParamDialog