feat: add inverted sources (#4722)
Co-authored-by: elecpower <neilh713@tpg.com.au>
This commit is contained in:
@@ -383,7 +383,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||
if (!cfn.isEmpty()) {
|
||||
widgetsMask |= CUSTOM_FUNCTION_SHOW_FUNC | CUSTOM_FUNCTION_ENABLE;
|
||||
|
||||
if (func >= FuncOverrideCH1 && func <= FuncOverrideCH32) {
|
||||
if (func >= FuncOverrideCH1 && func <= FuncOverrideCHLast) {
|
||||
if (model) {
|
||||
int channelsMax = model->getChannelsMax(true);
|
||||
fswtchParam[i]->setDecimals(0);
|
||||
@@ -445,10 +445,10 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
||||
}
|
||||
else if (func >= FuncSetTimer1 && func <= FuncSetTimer3) {
|
||||
else if (func >= FuncSetTimer1 && func <= FuncSetTimerLast) {
|
||||
if (modified)
|
||||
cfn.param = fswtchParamTime[i]->timeInSeconds();
|
||||
RawSourceRange range = RawSource(SOURCE_TYPE_SPECIAL, func - FuncSetTimer1 + 2).getRange(model, generalSettings);
|
||||
RawSourceRange range = RawSource(SOURCE_TYPE_TIMER, func - FuncSetTimer1 + 1).getRange(model, generalSettings);
|
||||
fswtchParamTime[i]->setTimeRange((int)range.min, (int)range.max);
|
||||
fswtchParamTime[i]->setTime(cfn.param);
|
||||
widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM;
|
||||
@@ -663,39 +663,50 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsi
|
||||
{
|
||||
QStringList qs;
|
||||
b->setModel(new QStandardItemModel(b)); // clear combo box but not any shared item model
|
||||
|
||||
if (function == FuncPlaySound) {
|
||||
b->setModel(tabModelFactory->getItemModel(playSoundId));
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
if (b->currentIndex() < 0)
|
||||
b->setCurrentIndex(0);
|
||||
}
|
||||
else if (function == FuncPlayHaptic) {
|
||||
b->setModel(tabModelFactory->getItemModel(harpicId));
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
if (b->currentIndex() < 0)
|
||||
b->setCurrentIndex(0);
|
||||
}
|
||||
else if (function == FuncReset) {
|
||||
b->setModel(tabFilterFactory->getItemModel(funcResetParamId));
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
if (b->currentIndex() < 0)
|
||||
b->setCurrentIndex(0);
|
||||
}
|
||||
else if (function == FuncVolume || function == FuncBacklight) {
|
||||
b->setModel(tabFilterFactory->getItemModel(rawSourceInputsId));
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
if (b->currentIndex() < 0 && value == 0)
|
||||
b->setCurrentIndex(b->count() / 2); // '----' not in list so set to first positive value
|
||||
}
|
||||
else if (function == FuncPlayValue) {
|
||||
b->setModel(tabFilterFactory->getItemModel(rawSourceAllId));
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
if (b->currentIndex() < 0 && value == 0)
|
||||
b->setCurrentIndex(b->count() / 2); // '----' not in list so set to first positive value
|
||||
}
|
||||
else if (function >= FuncAdjustGV1 && function <= FuncAdjustGVLast) {
|
||||
switch (adjustmode) {
|
||||
case 1:
|
||||
b->setModel(tabFilterFactory->getItemModel(rawSourceInputsId));
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
if (b->currentIndex() < 0)
|
||||
b->setCurrentIndex(0);
|
||||
if (b->currentIndex() < 0 && value == 0)
|
||||
b->setCurrentIndex(b->count() / 2); // '----' not in list so set to first positive value
|
||||
break;
|
||||
case 2:
|
||||
b->setModel(tabFilterFactory->getItemModel(rawSourceGVarsId));
|
||||
b->setCurrentIndex(b->findData(value));
|
||||
if (b->currentIndex() < 0)
|
||||
b->setCurrentIndex(0);
|
||||
if (b->currentIndex() < 0 && value == 0)
|
||||
b->setCurrentIndex(b->count() / 2); // '----' not in list so set to first positive value
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
cb_fp[i] = tmp[i];
|
||||
}
|
||||
|
||||
RawSourceType srcType = (firmware->getCapability(VirtualInputs) ? SOURCE_TYPE_VIRTUAL_INPUT : SOURCE_TYPE_STICK);
|
||||
RawSourceType srcType = (firmware->getCapability(VirtualInputs) ? SOURCE_TYPE_VIRTUAL_INPUT : SOURCE_TYPE_INPUT);
|
||||
setWindowTitle(tr("Edit %1").arg(RawSource(srcType, ed->chn).toString(&model, &generalSettings)));
|
||||
|
||||
id = dialogFilteredItemModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_GVarRef)), "GVarRef");
|
||||
@@ -109,6 +109,8 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
flags), "RawSource");
|
||||
ui->sourceCB->setModel(dialogFilteredItemModels->getItemModel(id));
|
||||
ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(ed->srcRaw.toValue()));
|
||||
if (ui->sourceCB->currentIndex() < 0 && ed->srcRaw.toValue() == 0)
|
||||
ui->sourceCB->setCurrentIndex(ui->sourceCB->count() / 2); // '----' not in list so set to first positive entry
|
||||
ui->inputName->setValidator(new NameValidator(board, this));
|
||||
ui->inputName->setText(inputName);
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ bool LogicalSwitchesPanel::offsetChangedAt(int index)
|
||||
{
|
||||
RawSource source = RawSource(model->logicalSw[index].val1);
|
||||
RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[index].getRangeFlags());
|
||||
double currVal = source.isTimeBased() ? teOffset[index]->timeInSeconds() : dsbOffset[index]->value();
|
||||
double currVal = source.type == SOURCE_TYPE_TIMER ? teOffset[index]->timeInSeconds() : dsbOffset[index]->value();
|
||||
value = round((currVal - range.offset) / range.step);
|
||||
mod = (mod || value != model->logicalSw[index].val2);
|
||||
model->logicalSw[index].val2 = value;
|
||||
@@ -366,7 +366,7 @@ void LogicalSwitchesPanel::updateLine(int i)
|
||||
double value = range.step * model->logicalSw[i].val2 + range.offset; /* TODO+source.getRawOffset(model)*/
|
||||
cbSource1[i]->setModel(rawSourceFilteredModel);
|
||||
cbSource1[i]->setCurrentIndex(cbSource1[i]->findData(source.toValue()));
|
||||
if (source.isTimeBased()) {
|
||||
if (source.type == SOURCE_TYPE_TIMER) {
|
||||
mask |= VALUE_TO_VISIBLE;
|
||||
teOffset[i]->setTimeRange(range.min, range.max);
|
||||
teOffset[i]->setSingleStep(range.step);
|
||||
|
||||
@@ -55,6 +55,8 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata,
|
||||
"RawSource");
|
||||
ui->sourceCB->setModel(dialogFilteredItemModels->getItemModel(id));
|
||||
ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(md->srcRaw.toValue()));
|
||||
if (ui->sourceCB->currentIndex() < 0 && md->srcRaw.toValue() == 0)
|
||||
ui->sourceCB->setCurrentIndex(ui->sourceCB->count() / 2); // '----' not in list so set to first positive entry
|
||||
|
||||
int limit = firmware->getCapability(OffsetWeight);
|
||||
|
||||
@@ -206,7 +208,7 @@ void MixerDialog::valuesChanged()
|
||||
lock = true;
|
||||
md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt());
|
||||
if (firmware->getCapability(HasNoExpo)) {
|
||||
bool drVisible = (md->srcRaw.type == SOURCE_TYPE_STICK && md->srcRaw.index < CPN_MAX_STICKS);
|
||||
bool drVisible = (md->srcRaw.type == SOURCE_TYPE_INPUT && md->srcRaw.index < CPN_MAX_STICKS);
|
||||
ui->MixDR_CB->setEnabled(drVisible);
|
||||
ui->label_MixDR->setEnabled(drVisible);
|
||||
}
|
||||
|
||||
@@ -1610,7 +1610,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
const int ttlInputs = ttlSticks + ttlFlexInputs;
|
||||
|
||||
for (int i = 0; i < ttlInputs + firmware->getCapability(RotaryEncoders); i++) {
|
||||
RawSource src((i < ttlInputs) ? SOURCE_TYPE_STICK : SOURCE_TYPE_ROTARY_ENCODER, (i < ttlInputs) ? i : ttlInputs - i);
|
||||
RawSource src((i < ttlInputs) ? SOURCE_TYPE_INPUT : SOURCE_TYPE_ROTARY_ENCODER, (i < ttlInputs) ? i : ttlInputs - i);
|
||||
QCheckBox * checkbox = new QCheckBox(this);
|
||||
checkbox->setProperty("index", i);
|
||||
checkbox->setText(src.toString(&model, &generalSettings));
|
||||
@@ -1674,7 +1674,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
|
||||
if (IS_HORUS_OR_TARANIS(board) && ttlInputs > 0) {
|
||||
for (int i = ttlSticks; i < ttlInputs; i++) {
|
||||
RawSource src(SOURCE_TYPE_STICK, i);
|
||||
RawSource src(SOURCE_TYPE_INPUT, i);
|
||||
QCheckBox * cb = new QCheckBox(this);
|
||||
cb->setProperty("index", i - ttlSticks);
|
||||
cb->setText(src.toString(&model, &generalSettings));
|
||||
|
||||
@@ -158,7 +158,7 @@ void CustomScreen::updateBar(int line)
|
||||
float maxVal = screen.body.bars[line].barMax;
|
||||
maxVal = range.getValue(maxVal);
|
||||
|
||||
if (source.isTimeBased()) {
|
||||
if (source.type == SOURCE_TYPE_TIMER) {
|
||||
minTime[line]->setVisible(true);
|
||||
minTime[line]->setTimeRange(range.min, range.max);
|
||||
minTime[line]->setSingleStep(range.step);
|
||||
|
||||
Reference in New Issue
Block a user