Commit 62e45635 authored by Don Gagne's avatar Don Gagne

Show enumStringValue if available

parent 140c572f
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment