|
|
|
@ -163,21 +163,53 @@ ColumnLayout {
@@ -163,21 +163,53 @@ ColumnLayout {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FactComboBox { |
|
|
|
|
id: mainJSButtonActionCombo |
|
|
|
|
width: ScreenTools.defaultFontPixelWidth * 15 |
|
|
|
|
fact: hasFirmwareSupport ? controller.getParameterFact(-1, parameterName) : null; |
|
|
|
|
visible: hasFirmwareSupport |
|
|
|
|
indexModel: false |
|
|
|
|
QGCComboBox { |
|
|
|
|
id: buttonActionCombo |
|
|
|
|
width: ScreenTools.defaultFontPixelWidth * 26 |
|
|
|
|
property Fact fact: controller.parameterExists(-1, parameterName) ? controller.getParameterFact(-1, parameterName) : null |
|
|
|
|
property Fact fact_shift: controller.parameterExists(-1, parameterShiftName) ? controller.getParameterFact(-1, parameterShiftName) : null |
|
|
|
|
property var factOptions: fact ? fact.enumStrings : []; |
|
|
|
|
model: [..._activeJoystick.assignableActionTitles, ...factOptions] |
|
|
|
|
property var isFwAction: currentIndex >= _activeJoystick.assignableActionTitles.length |
|
|
|
|
sizeToContents: true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function _findCurrentButtonAction() { |
|
|
|
|
// Find the index in the dropdown of the current action, checks FW and QGC actions |
|
|
|
|
if(_activeJoystick) { |
|
|
|
|
if (fact && fact.value > 0) { |
|
|
|
|
// This is a firmware function |
|
|
|
|
currentIndex = _activeJoystick.assignableActionTitles.length + fact.value |
|
|
|
|
// For sanity reasons, make sure qgc is set to "no action" if the firmware is set to do something |
|
|
|
|
_activeJoystick.setButtonAction(modelData, "No Action") |
|
|
|
|
} else { |
|
|
|
|
// If there is not firmware function, check QGC ones |
|
|
|
|
currentIndex = find(_activeJoystick.buttonActions[modelData]) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Component.onCompleted: _findCurrentButtonAction() |
|
|
|
|
onModelChanged: _findCurrentButtonAction() |
|
|
|
|
onActivated: function (optionIndex) { |
|
|
|
|
var func = textAt(optionIndex) |
|
|
|
|
if (factOptions.indexOf(func) > -1) { |
|
|
|
|
// This is a FW action, set parameter to the action and set QGC's handler to No Action |
|
|
|
|
fact.value = factOptions.indexOf(func) |
|
|
|
|
_activeJoystick.setButtonAction(modelData, "No Action") |
|
|
|
|
} else { |
|
|
|
|
// This is a QGC action, set parameters to Disabled and QGC to the desired action |
|
|
|
|
_activeJoystick.setButtonAction(modelData, func) |
|
|
|
|
fact.value = 0 |
|
|
|
|
fact_shift.value = 0 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
FactComboBox { |
|
|
|
|
id: shiftJSButtonActionCombo |
|
|
|
|
width: ScreenTools.defaultFontPixelWidth * 15 |
|
|
|
|
fact: hasFirmwareSupport ? controller.getParameterFact(-1, parameterShiftName) : null; |
|
|
|
|
visible: hasFirmwareSupport |
|
|
|
|
indexModel: false |
|
|
|
|
id: shiftJSButtonActionCombo |
|
|
|
|
width: ScreenTools.defaultFontPixelWidth * 26 |
|
|
|
|
fact: controller.parameterExists(-1, parameterShiftName) ? controller.getParameterFact(-1, parameterShiftName) : null; |
|
|
|
|
indexModel: false |
|
|
|
|
visible: buttonActionCombo.isFwAction |
|
|
|
|
sizeToContents: true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|