Commit cea599b9 authored by Jacob Walser's avatar Jacob Walser

Add manual entry option for enumerated and bitmask parameters

parent 6b10539a
......@@ -34,18 +34,11 @@ QGCViewDialog {
QGCPalette { id: qgcPal; colorGroupEnabled: true }
function accept() {
if (bitmaskColumn.visible) {
var value = 0;
for (var i = 0; i < fact.bitmaskValues.length; ++i) {
var checkbox = bitmaskRepeater.itemAt(i)
if (checkbox.checked) {
value |= fact.bitmaskValues[i];
}
}
fact.value = value;
if (bitmaskColumn.visible && !manualEntry.checked) {
fact.value = bitmaskValue();
fact.valueChanged(fact.value)
hideDialog();
} else if (factCombo.visible) {
} else if (factCombo.visible && !manualEntry.checked) {
fact.enumIndex = factCombo.currentIndex
hideDialog()
} else {
......@@ -61,6 +54,17 @@ QGCViewDialog {
}
}
function bitmaskValue() {
var value = 0;
for (var i = 0; i < fact.bitmaskValues.length; ++i) {
var checkbox = bitmaskRepeater.itemAt(i)
if (checkbox.checked) {
value |= fact.bitmaskValues[i];
}
}
return value
}
Component.onCompleted: {
if (validate) {
validationError.text = fact.validate(validateValue, false /* convertOnly */)
......@@ -79,6 +83,17 @@ QGCViewDialog {
anchors.left: parent.left
anchors.right: parent.right
// Checkbox to allow manual entry of enumerated or bitmask parameters
QGCCheckBox {
id: manualEntry
visible: factCombo.visible || bitmaskColumn.visible
text: qsTr("Manual Entry (Advanced User)")
onClicked: {
valueField.text = fact.valueString
}
}
QGCLabel {
id: validationError
width: parent.width
......@@ -94,7 +109,7 @@ QGCViewDialog {
QGCTextField {
id: valueField
text: validate ? validateValue : fact.valueString
visible: fact.enumStrings.length == 0 || validate
visible: fact.enumStrings.length == 0 || validate || manualEntry.checked
unitsLabel: fact.units
showUnits: fact.units != ""
Layout.fillWidth: true
......@@ -132,6 +147,10 @@ QGCViewDialog {
currentIndex = fact.enumIndex
}
}
onCurrentIndexChanged: {
valueField.text = fact.enumValues[currentIndex]
}
}
Column {
......@@ -146,6 +165,10 @@ QGCViewDialog {
delegate : QGCCheckBox {
text : modelData
checked : fact.value & fact.bitmaskValues[index]
onClicked: {
valueField.text = bitmaskValue()
}
}
}
}
......
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