diff --git a/src/QmlControls/ParameterEditorDialog.qml b/src/QmlControls/ParameterEditorDialog.qml index c6622eeae23754ac046f1328a31da5478aa4efaf..56d95ebd6eed4b744f88c685351635a1403e52de 100644 --- a/src/QmlControls/ParameterEditorDialog.qml +++ b/src/QmlControls/ParameterEditorDialog.qml @@ -35,6 +35,8 @@ import QGroundControl.FactControls 1.0 import QGroundControl.ScreenTools 1.0 QGCViewDialog { + id: root + property Fact fact property bool validate: false property string validateValue @@ -42,14 +44,19 @@ QGCViewDialog { ParameterEditorController { id: controller; factPanel: parent } function accept() { - var errorString = fact.validate(valueField.text, forceSave.checked) - if (errorString == "") { - fact.value = valueField.text - fact.valueChanged(fact.value) + if (factCombo.visible) { + fact.enumIndex = factCombo.currentIndex hideDialog() } else { - validationError.text = errorString - forceSave.visible = true + var errorString = fact.validate(valueField.text, forceSave.checked) + if (errorString == "") { + fact.value = valueField.text + fact.valueChanged(fact.value) + hideDialog() + } else { + validationError.text = errorString + forceSave.visible = true + } } } @@ -80,14 +87,30 @@ QGCViewDialog { } QGCTextField { - id: valueField - text: validate ? validateValue : fact.valueString + id: valueField + text: validate ? validateValue : fact.valueString + visible: fact.enumStrings.length == 0 || validate //focus: true // At this point all Facts are numeric inputMethodHints: Qt.ImhFormattedNumbersOnly } + QGCComboBox { + id: factCombo + width: valueField.width + visible: fact.enumStrings.length != 0 && !validate + model: fact.enumStrings + + Component.onCompleted: { + // We can't bind directly to fact.enumIndex since that would add an unknown value + // if there are no enum strings. + if (visible) { + currentIndex = fact.enumIndex + } + } + } + QGCLabel { text: fact.name } Row {