Commit 6742bd85 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4740 from bluerobotics/param-manual-entry

Add manual entry option for enumerated and bitmask parameters
parents 8d6b18df 55f26894
......@@ -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 */)
......@@ -94,7 +98,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 +136,10 @@ QGCViewDialog {
currentIndex = fact.enumIndex
}
}
onCurrentIndexChanged: {
valueField.text = fact.enumValues[currentIndex]
}
}
Column {
......@@ -146,6 +154,10 @@ QGCViewDialog {
delegate : QGCCheckBox {
text : modelData
checked : fact.value & fact.bitmaskValues[index]
onClicked: {
valueField.text = bitmaskValue()
}
}
}
}
......@@ -212,7 +224,7 @@ QGCViewDialog {
Row {
width: parent.width
spacing: ScreenTools.defaultFontPixelWidth / 2
visible: showRCToParam
visible: showRCToParam || factCombo.visible || bitmaskColumn.visible
Rectangle {
height: 1
......@@ -234,6 +246,17 @@ QGCViewDialog {
}
}
// Checkbox to allow manual entry of enumerated or bitmask parameters
QGCCheckBox {
id: manualEntry
visible: _advanced.checked && (factCombo.visible || bitmaskColumn.visible)
text: qsTr("Manual Entry")
onClicked: {
valueField.text = fact.valueString
}
}
QGCButton {
text: qsTr("Set RC to Param...")
width: _editFieldWidth
......
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