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 { ...@@ -34,18 +34,11 @@ QGCViewDialog {
QGCPalette { id: qgcPal; colorGroupEnabled: true } QGCPalette { id: qgcPal; colorGroupEnabled: true }
function accept() { function accept() {
if (bitmaskColumn.visible) { if (bitmaskColumn.visible && !manualEntry.checked) {
var value = 0; fact.value = bitmaskValue();
for (var i = 0; i < fact.bitmaskValues.length; ++i) {
var checkbox = bitmaskRepeater.itemAt(i)
if (checkbox.checked) {
value |= fact.bitmaskValues[i];
}
}
fact.value = value;
fact.valueChanged(fact.value) fact.valueChanged(fact.value)
hideDialog(); hideDialog();
} else if (factCombo.visible) { } else if (factCombo.visible && !manualEntry.checked) {
fact.enumIndex = factCombo.currentIndex fact.enumIndex = factCombo.currentIndex
hideDialog() hideDialog()
} else { } else {
...@@ -61,6 +54,17 @@ QGCViewDialog { ...@@ -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: { Component.onCompleted: {
if (validate) { if (validate) {
validationError.text = fact.validate(validateValue, false /* convertOnly */) validationError.text = fact.validate(validateValue, false /* convertOnly */)
...@@ -94,7 +98,7 @@ QGCViewDialog { ...@@ -94,7 +98,7 @@ QGCViewDialog {
QGCTextField { QGCTextField {
id: valueField id: valueField
text: validate ? validateValue : fact.valueString text: validate ? validateValue : fact.valueString
visible: fact.enumStrings.length == 0 || validate visible: fact.enumStrings.length == 0 || validate || manualEntry.checked
unitsLabel: fact.units unitsLabel: fact.units
showUnits: fact.units != "" showUnits: fact.units != ""
Layout.fillWidth: true Layout.fillWidth: true
...@@ -132,6 +136,10 @@ QGCViewDialog { ...@@ -132,6 +136,10 @@ QGCViewDialog {
currentIndex = fact.enumIndex currentIndex = fact.enumIndex
} }
} }
onCurrentIndexChanged: {
valueField.text = fact.enumValues[currentIndex]
}
} }
Column { Column {
...@@ -146,6 +154,10 @@ QGCViewDialog { ...@@ -146,6 +154,10 @@ QGCViewDialog {
delegate : QGCCheckBox { delegate : QGCCheckBox {
text : modelData text : modelData
checked : fact.value & fact.bitmaskValues[index] checked : fact.value & fact.bitmaskValues[index]
onClicked: {
valueField.text = bitmaskValue()
}
} }
} }
} }
...@@ -212,7 +224,7 @@ QGCViewDialog { ...@@ -212,7 +224,7 @@ QGCViewDialog {
Row { Row {
width: parent.width width: parent.width
spacing: ScreenTools.defaultFontPixelWidth / 2 spacing: ScreenTools.defaultFontPixelWidth / 2
visible: showRCToParam visible: showRCToParam || factCombo.visible || bitmaskColumn.visible
Rectangle { Rectangle {
height: 1 height: 1
...@@ -234,6 +246,17 @@ QGCViewDialog { ...@@ -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 { QGCButton {
text: qsTr("Set RC to Param...") text: qsTr("Set RC to Param...")
width: _editFieldWidth 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