diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 409f0df5e0..3fd6e5ee23 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -995,14 +995,7 @@ void LimitData::clear() GeneralSettings::SwitchInfo GeneralSettings::switchInfoFromSwitchPositionTaranis(unsigned int index) { - if (index <= 3*5) - return SwitchInfo((index-1)/3, (index-1)%3); - else if (index <= 17) - return SwitchInfo(5, index==17 ? 2 : 0); - else if (index <= 20) - return SwitchInfo(6, index-18); - else - return SwitchInfo(7+(index-21)/2, 2*((index-21)%2)); + return SwitchInfo((index-1)/3, (index-1)%3); } bool GeneralSettings::switchPositionAllowedTaranis(int index) const @@ -1015,7 +1008,12 @@ bool GeneralSettings::switchPositionAllowedTaranis(int index) const else if (info.position == 1) return switchConfig[info.index] == SWITCH_3POS; else - return true; + return switchConfig[info.index] != SWITCH_NONE; +} + +bool GeneralSettings::switchSourceAllowedTaranis(int index) const +{ + return switchConfig[index] != SWITCH_NONE; } GeneralSettings::GeneralSettings() diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index b982da9d0d..e26d88581f 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -1174,6 +1174,7 @@ class GeneralSettings { static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index); bool switchPositionAllowedTaranis(int index) const; + bool switchSourceAllowedTaranis(int index) const; }; class RadioData { diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index eaaeaca175..f52aa506d0 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -412,10 +412,13 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin } for (int i=-GetCurrentFirmware()->getCapability(SwitchesPositions); i<0; i++) { - if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i)) - continue; item = RawSwitch(SWITCH_TYPE_SWITCH, i); b->addItem(item.toString(), item.toValue()); + if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i)){ + QModelIndex index = b->model()->index(b->count()-1, 0); + QVariant v(0); + b->model()->setData(index, v, Qt::UserRole - 1); + } if (item == value) b->setCurrentIndex(b->count()-1); } @@ -433,10 +436,13 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin } for (int i=1; i<=GetCurrentFirmware()->getCapability(SwitchesPositions); i++) { - if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i)) - continue; item = RawSwitch(SWITCH_TYPE_SWITCH, i); b->addItem(item.toString(), item.toValue()); + if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i)){ + QModelIndex index = b->model()->index(b->count()-1, 0); + QVariant v(0); + b->model()->setData(index, v, Qt::UserRole - 1); + } if (item == value) b->setCurrentIndex(b->count()-1); } @@ -525,7 +531,7 @@ void populateGVCB(QComboBox *b, int value) } } -void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData * model, unsigned int flags) +void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags) { BoardEnum board = GetCurrentFirmware()->getBoard(); RawSource item; @@ -590,6 +596,11 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData * for (int i=0; igetCapability(Switches); i++) { item = RawSource(SOURCE_TYPE_SWITCH, i); b->addItem(item.toString(model), item.toValue()); + if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchSourceAllowedTaranis(i)) { + QModelIndex index = b->model()->index(b->count()-1, 0); + QVariant v(0); + b->model()->setData(index, v, Qt::UserRole - 1); + } if (item == source) b->setCurrentIndex(b->count()-1); } diff --git a/companion/src/helpers.h b/companion/src/helpers.h index c57cdbda6a..035176e58a 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -115,7 +115,7 @@ QString getPhasesStr(unsigned int phases, ModelData * model); // void populateGVarCB(QComboBox *b, int value, int min, int max,int pgvars=5); //TODO: Clean Up void populateGVCB(QComboBox *b, int value); -void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData * model, unsigned int flags); +void populateSourceCB(QComboBox *b, const RawSource &source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags); QString getPhaseName(int val, const char * phasename=NULL); QString getInputStr(ModelData * model, int index); QString image2qstring(QImage image); diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index f7c8d0eaba..600278d736 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -714,18 +714,18 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsi b->setCurrentIndex(value); } else if (function==FuncVolume) { - populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS); + populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS); } else if (function==FuncPlayValue) { - populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT); + populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT); } else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) { switch (adjustmode) { case 1: - populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES); + populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES); break; case 2: - populateSourceCB(b, RawSource(value), model, POPULATE_GVARS); + populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_GVARS); break; case 3: b->clear(); diff --git a/companion/src/modeledit/expodialog.cpp b/companion/src/modeledit/expodialog.cpp index 51c51200b6..54f7fb61f8 100644 --- a/companion/src/modeledit/expodialog.cpp +++ b/companion/src/modeledit/expodialog.cpp @@ -60,7 +60,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G if (firmware->getCapability(VirtualInputs)) { ui->inputName->setMaxLength(4); - populateSourceCB(ui->sourceCB, ed->srcRaw, &model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY); + populateSourceCB(ui->sourceCB, ed->srcRaw, generalSettings, &model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY); ui->sourceCB->removeItem(0); } else { diff --git a/companion/src/modeledit/heli.cpp b/companion/src/modeledit/heli.cpp index 53d6541f92..391c1c3287 100644 --- a/companion/src/modeledit/heli.cpp +++ b/companion/src/modeledit/heli.cpp @@ -48,11 +48,11 @@ void HeliPanel::update() lock = true; ui->swashType->setCurrentIndex(model->swashRingData.type); - populateSourceCB(ui->swashCollectiveSource, model->swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); + populateSourceCB(ui->swashCollectiveSource, model->swashRingData.collectiveSource, generalSettings, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); ui->swashRingVal->setValue(model->swashRingData.value); if (firmware->getCapability(VirtualInputs)) { - populateSourceCB(ui->swashElevatorSource, model->swashRingData.elevatorSource, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); - populateSourceCB(ui->swashAileronSource, model->swashRingData.aileronSource, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); + populateSourceCB(ui->swashElevatorSource, model->swashRingData.elevatorSource, generalSettings, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); + populateSourceCB(ui->swashAileronSource, model->swashRingData.aileronSource, generalSettings, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); ui->swashElevatorWeight->setValue(model->swashRingData.elevatorWeight); ui->swashAileronWeight->setValue(model->swashRingData.aileronWeight); ui->swashCollectiveWeight->setValue(model->swashRingData.collectiveWeight); diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index 5a156b49c2..4228b7141c 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -301,7 +301,7 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i) { case LS_FAMILY_VOFS: mask |= SOURCE1_VISIBLE; - populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource1[i], source, generalSettings, model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); cswitchOffset[i]->setDecimals(range.decimals); cswitchOffset[i]->setSingleStep(range.step); if (source.isTimeBased()) { @@ -346,8 +346,8 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i) break; case LS_FAMILY_VCOMP: mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE; - populateSourceCB(cswitchSource1[i], RawSource(model->logicalSw[i].val1), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); - populateSourceCB(cswitchSource2[i], RawSource(model->logicalSw[i].val2), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource1[i], RawSource(model->logicalSw[i].val1), generalSettings, model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource2[i], RawSource(model->logicalSw[i].val2), generalSettings, model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); break; case LS_FAMILY_TIMER: mask |= VALUE1_VISIBLE | VALUE2_VISIBLE; diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index 89596f6107..12a7546732 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -19,7 +19,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G this->setWindowTitle(tr("DEST -> CH%1").arg(md->destCh)); - populateSourceCB(ui->sourceCB, md->srcRaw, &model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); + populateSourceCB(ui->sourceCB, md->srcRaw, generalSettings, &model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); ui->sourceCB->removeItem(0); int limit = firmware->getCapability(OffsetWeight);