diff --git a/companion/src/comparedialog.cpp b/companion/src/comparedialog.cpp index 48ed3f9f5..f12c182b2 100644 --- a/companion/src/comparedialog.cpp +++ b/companion/src/comparedialog.cpp @@ -305,7 +305,7 @@ void compareDialog::printPhases() str.append(""+tr("Switch")+""+tr("Flight mode name")); str.append(""+tr("IN")+""+tr("OUT")+""); for (i=0; i<4; i++) { - str.append(QString("%1").arg(getStickStr(i))); + str.append(QString("%1").arg(getInputStr(*g_model1, i))); } str.append(""); for (i=0; igetCapability(FlightPhases); i++) { @@ -406,7 +406,7 @@ void compareDialog::printPhases() str.append(""+tr("Switch")+""+tr("Flight mode name")); str.append(""+tr("IN")+""+tr("OUT")+""); for (i=0; i<4; i++) { - str.append(QString("%1").arg(getStickStr(i))); + str.append(QString("%1").arg(getInputStr(*g_model1, i))); } str.append(""); for (i=0; igetCapability(FlightPhases); i++) { @@ -694,7 +694,7 @@ void compareDialog::printExpos() } } str.append(""); - str.append(""+getStickStr(i)+""); + str.append(""+getInputStr(*g_model2, i)+""); str.append(""); str.append(""); for (int j=0; j= 216) { // TODO ScriptData scriptsData[MAX_SCRIPTS]; internalField.Append(new SpareBitsField<720>()); - // TODO char inputNames[MAX_INPUTS][4]; - internalField.Append(new SpareBitsField<1024>()); + for (int i=0; i<32; i++) + internalField.Append(new ZCharField<4>(modelData.inputNames[i])); } } diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 73738e0b4..a0917d9b6 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -598,8 +598,6 @@ int Open9xInterface::getCapability(const Capability capability) return 1; case ExtendedTrims: return 500; - case ExtraTrims: - return 1; case Simulation: return 1; case DSM2Indexes: @@ -696,6 +694,7 @@ int Open9xInterface::getCapability(const Capability capability) case GetThrSwitch: return (IS_TARANIS(board) ? DSW_SF1 : DSW_THR) ; case VirtualInputs: + return IS_TARANIS(board) ? 32 : 0; case LuaInputs: case LimitsPer1000: case EnhancedCurves: diff --git a/companion/src/firmwares/opentx/stamp-opentx.h.in b/companion/src/firmwares/opentx/stamp-opentx.h.in index ad88df035..246c69b5d 100644 --- a/companion/src/firmwares/opentx/stamp-opentx.h.in +++ b/companion/src/firmwares/opentx/stamp-opentx.h.in @@ -2,5 +2,5 @@ #define DATE_STR "@DATE@" #define TIME_STR "@TIME@" #define VERS_STR "c9x" -#define SVN_STR "@FIRMWARE@-r@G9X_WC_REVISION@" +#define VERS_STR "@FIRMWARE@-r@G9X_WC_REVISION@" #define MOD_STR "FH" diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 7c5046b31..d89deaa6f 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -18,9 +18,21 @@ QString getPhaseName(int val, char * phasename) } } -QString getStickStr(int index) +QString getInputStr(ModelData & model, int index) { - return RawSource(SOURCE_TYPE_STICK, index).toString(); + QString result; + + if (GetEepromInterface()->getCapability(VirtualInputs)) { + result = model.inputNames[index]; + if (result.isEmpty()) { + result = QObject::tr("Input%1").arg(index+1, 2, 10, QChar('0')); + } + } + else { + result = RawSource(SOURCE_TYPE_STICK, index).toString(); + } + + return result; } void populateGvSourceCB(QComboBox *b, int value) @@ -63,7 +75,7 @@ void populateTTraceCB(QComboBox *b, int value) } int channels=(IS_ARM(GetEepromInterface()->getBoard()) ? 32 : 16); for (int i=1; i<= channels; i++) { - b->addItem(QObject::tr("CH")+QString("%1").arg(i,2,10,QChar('0'))); + b->addItem(QObject::tr("CH%1").arg(i, 2, 10, QChar('0'))); } b->setCurrentIndex(value); } @@ -471,6 +483,78 @@ void populatePhasesCB(QComboBox *b, int value) b->setCurrentIndex(value + GetEepromInterface()->getCapability(FlightPhases)); } +bool gvarsEnabled() +{ + int gvars=0; + if (GetEepromInterface()->getCapability(HasVariants)) { + if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) { + gvars=1; + } + } + else { + gvars=1; + } + return gvars; +} + +GVarGroup::GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const unsigned int flags): + QObject(), + weightGV(weightGV), + weightSB(weightSB), + weightCB(weightCB), + weight(weight), + flags(flags), + lock(false) +{ + lock = true; + + if (gvarsEnabled()) { + populateGVCB(weightCB, weight); + connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int))); + connect(weightCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged())); + } + else { + weightGV->hide(); + if (weight > maxi || weight < -mini) { + weight = deflt; + } + } + + weightSB->setMinimum(mini); + weightSB->setMaximum(maxi); + + if (weight>maxi || weightsetChecked(true); + weightSB->hide(); + weightCB->show(); + } + else { + weightGV->setChecked(false); + weightSB->setValue(weight); + weightSB->show(); + weightCB->hide(); + } + + connect(weightSB, SIGNAL(editingFinished()), this, SLOT(valuesChanged())); + + lock = false; +} + +void GVarGroup::gvarCBChanged(int state) +{ + weightCB->setVisible(state); + weightSB->setVisible(!state); + valuesChanged(); +} + +void GVarGroup::valuesChanged() +{ + if (weightGV->isChecked()) + weight = weightCB->itemData(weightCB->currentIndex()).toInt(); + else + weight = weightSB->value(); +} + CurveGroup::CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags): QObject(), curveTypeCB(curveTypeCB), diff --git a/companion/src/helpers.h b/companion/src/helpers.h index bc61e2894..6f104480c 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -29,6 +29,26 @@ void populateTTraceCB(QComboBox *b, int value); void populateRotEncCB(QComboBox *b, int value, int renumber); void populateBacklightCB(QComboBox *b, const uint8_t value); +class GVarGroup : public QObject { + + Q_OBJECT + + public: + GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const unsigned int flags=0); + + protected slots: + void gvarCBChanged(int); + void valuesChanged(); + + protected: + QCheckBox *weightGV; + QSpinBox *weightSB; + QComboBox *weightCB; + int & weight; + const unsigned int flags; + bool lock; +}; + class CurveGroup : public QObject { Q_OBJECT @@ -88,7 +108,7 @@ void populateCSWCB(QComboBox *b, int value); QString getTimerMode(int tm); QString getTimerModeB(int tm); QString getPhaseName(int val, char * phasename=NULL); -QString getStickStr(int index); +QString getInputStr(ModelData & model, int index); QString getCSWFunc(int val); QString getFuncName(unsigned int val); QString getRepeatString(unsigned int val); diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp index b20cd1f68..8270689b6 100644 --- a/companion/src/modeledit/customswitches.cpp +++ b/companion/src/modeledit/customswitches.cpp @@ -254,7 +254,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) cswitchSource2[i]->setVisible(false); cswitchValue[i]->setVisible(false); cswitchOffset[i]->setVisible(true); - populateSourceCB(cswitchSource1[i], source, POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource1[i], source, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); cswitchOffset[i]->setDecimals(source.getDecimals(model)); cswitchOffset[i]->setSingleStep(source.getStep(model)); if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcsetVisible(true); cswitchValue[i]->setVisible(false); cswitchOffset[i]->setVisible(false); - populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); - populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), POPULATE_SOURCES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); break; case CS_FAMILY_TIMERS: cswitchSource1[i]->setVisible(false); diff --git a/companion/src/modeledit/expodialog.cpp b/companion/src/modeledit/expodialog.cpp index bb2df0c65..d632777df 100644 --- a/companion/src/modeledit/expodialog.cpp +++ b/companion/src/modeledit/expodialog.cpp @@ -3,126 +3,97 @@ #include "eeprominterface.h" #include "helpers.h" -ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) : +ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, int stickMode) : QDialog(parent), ui(new Ui::ExpoDialog), + model(model), ed(expoData) { - ui->setupUi(this); - QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 }; - QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; + ui->setupUi(this); + QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 }; + QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; - setWindowTitle(tr("DEST -> %1").arg(getStickStr(ed->chn))); - QRegExp rx(CHAR_FOR_NAMES_REGEX); - - int gvars=0; - if (GetEepromInterface()->getCapability(HasVariants)) { - if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) { - gvars=1; - } - } else { - gvars=1; - } + setWindowTitle(tr("Edit %1").arg(getInputStr(model, ed->chn))); + QRegExp rx(CHAR_FOR_NAMES_REGEX); - if (gvars==0) { - ui->weightGV->setDisabled(true); - ui->curveGVarCB->hide(); - if ((ed->curve.type == CurveReference::CURVE_REF_EXPO || ed->curve.type == CurveReference::CURVE_REF_DIFF) && ed->curve.value > 100) { - ed->curve.value = 0; - } - if (ed->weight>100 || ed->weight<-100) { - ed->weight = 100; - } - } + gvGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, 100, 0, 100); + curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve); - populateGVCB(ui->weightCB, ed->weight); + populateSwitchCB(ui->switchesCB,ed->swtch); - ui->weightSB->setMinimum(0); - ui->weightSB->setMaximum(100); - if (ed->weight>100 || ed->weight<0) { - ui->weightGV->setChecked(true); - ui->weightSB->hide(); - ui->weightCB->show(); - } else { - ui->weightGV->setChecked(false); - ui->weightSB->setValue(ed->weight); - ui->weightSB->show(); - ui->weightCB->hide(); - } + ui->sideCB->setCurrentIndex(ed->mode-1); - populateSwitchCB(ui->switchesCB,ed->swtch); - - // TODO keep this group, same in MixerDialog - CurveGroup * curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve); - - ui->sideCB->setCurrentIndex(ed->mode-1); - - if (!GetEepromInterface()->getCapability(FlightPhases)) { - ui->label_phases->hide(); - for (int i=0; i<9; i++) { - lb_fp[i]->hide(); - cb_fp[i]->hide(); - } - } else { - int mask=1; - for (int i=0; i<9 ; i++) { - if ((ed->phases & mask)==0) { - cb_fp[i]->setChecked(true); - } - mask <<= 1; - } - for (int i=GetEepromInterface()->getCapability(FlightPhases); i<9;i++) { - lb_fp[i]->hide(); - cb_fp[i]->hide(); - } - } - - if (GetEepromInterface()->getCapability(VirtualInputs)) { - ui->sideLabel->hide(); - ui->sideCB->hide(); - } - else { - ui->sourceLabel->hide(); - ui->sourceCB->hide(); - ui->scaleLabel->hide(); - ui->scaleSB->hide(); - ui->trimLabel->hide(); - ui->trimCB->hide(); - } - - int expolength=GetEepromInterface()->getCapability(HasExpoNames); - if (!expolength) { - ui->label_name->hide(); - ui->expoName->hide(); - } else { - ui->expoName->setMaxLength(expolength); - } - - ui->expoName->setValidator(new QRegExpValidator(rx, this)); - ui->expoName->setText(ed->name); - valuesChanged(); - - connect(ui->expoName,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); - - connect(ui->curveTypeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); - connect(ui->curveGVarCB,SIGNAL(stateChanged(int)),this,SLOT(valuesChanged())); - connect(ui->curveValueCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); - connect(ui->curveValueSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); - - connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); - connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); - connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); - connect(ui->sideCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); - connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); + if (!GetEepromInterface()->getCapability(FlightPhases)) { + ui->label_phases->hide(); for (int i=0; i<9; i++) { - connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged())); + lb_fp[i]->hide(); + cb_fp[i]->hide(); } - QTimer::singleShot(0, this, SLOT(shrink())); + } + else { + int mask=1; + for (int i=0; i<9 ; i++) { + if ((ed->phases & mask)==0) { + cb_fp[i]->setChecked(true); + } + mask <<= 1; + } + for (int i=GetEepromInterface()->getCapability(FlightPhases); i<9;i++) { + lb_fp[i]->hide(); + cb_fp[i]->hide(); + } + } + + if (GetEepromInterface()->getCapability(VirtualInputs)) { + ui->sideLabel->hide(); + ui->sideCB->hide(); + ui->inputName->setMaxLength(4); + populateSourceCB(ui->sourceCB, ed->srcRaw, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0)); + ui->sourceCB->removeItem(0); + } + else { + ui->inputNameLabel->hide(); + ui->inputName->hide(); + ui->sourceLabel->hide(); + ui->sourceCB->hide(); + ui->scaleLabel->hide(); + ui->scaleSB->hide(); + ui->trimLabel->hide(); + ui->trimCB->hide(); + } + + int expolength = GetEepromInterface()->getCapability(HasExpoNames); + if (!expolength) { + ui->lineNameLabel->hide(); + ui->lineName->hide(); + } + else { + ui->lineName->setMaxLength(expolength); + } + + ui->inputName->setValidator(new QRegExpValidator(rx, this)); + ui->inputName->setText(model.inputNames[ed->chn]); + + ui->lineName->setValidator(new QRegExpValidator(rx, this)); + ui->lineName->setText(ed->name); + + valuesChanged(); + + connect(ui->lineName,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); + connect(ui->sourceCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); + connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); + connect(ui->sideCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); + for (int i=0; i<9; i++) { + connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged())); + } + QTimer::singleShot(0, this, SLOT(shrink())); } ExpoDialog::~ExpoDialog() { - delete ui; + delete gvGroup; + delete curveGroup; + delete ui; } void ExpoDialog::changeEvent(QEvent *e) @@ -137,54 +108,17 @@ void ExpoDialog::changeEvent(QEvent *e) } } -void ExpoDialog::widgetChanged() -{ - // TODO so many times duplicated :( - int gvars=0; - if (GetEepromInterface()->getCapability(HasVariants)) { - if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) { - gvars=1; - } - } else { - gvars=1; - } - - /* TODO if (gvars==1) { - if (ui->expoCurveGV->isChecked()) { - ui->expoCurveCB->show(); - ui->expoCurveSB->hide(); - } else { - ui->expoCurveCB->hide(); - ui->expoCurveSB->show(); - } - if (ui->weightGV->isChecked()) { - ui->weightCB->show(); - ui->weightSB->hide(); - } else { - ui->weightCB->hide(); - ui->weightSB->show(); - } - } */ - valuesChanged(); - QTimer::singleShot(0, this, SLOT(shrink())); -} - void ExpoDialog::valuesChanged() { QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; - if (ui->weightGV->isChecked()) { - ed->weight = ui->weightCB->itemData(ui->weightCB->currentIndex()).toInt(); - } else { - ed->weight = ui->weightSB->value(); - } + ed->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()); ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt()); ed->mode = ui->sideCB->currentIndex() + 1; - int i=0; - for (i=0; iexpoName->text().toAscii().length(); i++) { - ed->name[i]=ui->expoName->text().toAscii().at(i); - } - ed->name[i]=0; + + strcpy(ed->name, ui->lineName->text().toAscii().data()); + strcpy(model.inputNames[ed->chn], ui->inputName->text().toAscii().data()); + ed->phases=0; for (int i=8; i>=0 ; i--) { if (!cb_fp[i]->checkState()) { @@ -231,5 +165,5 @@ void ExpoDialog::valuesChanged() void ExpoDialog::shrink() { - resize(0,0); + resize(0,0); } diff --git a/companion/src/modeledit/expodialog.h b/companion/src/modeledit/expodialog.h index a7630cc87..5281e4c29 100644 --- a/companion/src/modeledit/expodialog.h +++ b/companion/src/modeledit/expodialog.h @@ -4,27 +4,32 @@ #include #include "eeprominterface.h" +class GVarGroup; +class CurveGroup; + namespace Ui { - class ExpoDialog; + class ExpoDialog; } class ExpoDialog : public QDialog { Q_OBJECT -public: - ExpoDialog(QWidget *parent, ExpoData *mixdata, int stickMode); + public: + ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expodata, int stickMode); ~ExpoDialog(); -protected: + protected: void changeEvent(QEvent *e); -private slots: + private slots: void valuesChanged(); - void widgetChanged(); void shrink(); -private: - Ui::ExpoDialog *ui; - ExpoData *ed; + private: + Ui::ExpoDialog * ui; + ModelData & model; + ExpoData * ed; + GVarGroup * gvGroup; + CurveGroup * curveGroup; }; #endif // EXPODIALOG_H diff --git a/companion/src/modeledit/expodialog.ui b/companion/src/modeledit/expodialog.ui index baf7c6b14..bfe43b1ec 100644 --- a/companion/src/modeledit/expodialog.ui +++ b/companion/src/modeledit/expodialog.ui @@ -30,28 +30,35 @@ :/icon.png:/icon.png + + + + The source for the mixer + + + - + - Name + Input name - + 6 - + Weight - + @@ -85,14 +92,14 @@ - + Flight modes - + @@ -249,14 +256,14 @@ - + Switch - + Switch used by the expo. @@ -264,14 +271,14 @@ If blank then the expo is considered to be "ON" all the time. - + Stick Side - + @@ -290,7 +297,7 @@ If blank then the expo is considered to be "ON" all the time. - + @@ -309,7 +316,7 @@ If blank then the expo is considered to be "ON" all the time. - + Qt::Vertical @@ -322,14 +329,7 @@ If blank then the expo is considered to be "ON" all the time. - - - - The source for the mixer - - - - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -352,28 +352,21 @@ p, li { white-space: pre-wrap; } - + Scale - + Include Trim - - - - Source - - - - + @@ -387,14 +380,14 @@ p, li { white-space: pre-wrap; } - + Curve - + @@ -425,6 +418,27 @@ p, li { white-space: pre-wrap; } + + + + Source + + + + + + + Line name + + + + + + + 6 + + + diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index d8882f01b..015080f76 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -48,6 +48,10 @@ void InputsPanel::update() { lock = true; + int inputsCount = GetEepromInterface()->getCapability(VirtualInputs); + if (inputsCount == 0) + inputsCount = NUM_STICKS; + // curDest -> destination channel // i -> mixer number QByteArray qba; @@ -58,10 +62,12 @@ void InputsPanel::update() ExpoData *md = &model.expoData[i]; if (md->mode==0) break; - QString str = ""; - while(curDest<(int)md->chn-1) { + + QString str; + + while (curDest<(int)md->chn-1) { curDest++; - str = getStickStr(curDest); + str = getInputStr(model, curDest); qba.clear(); qba.append((quint8)-curDest-1); QListWidgetItem *itm = new QListWidgetItem(str); @@ -69,14 +75,21 @@ void InputsPanel::update() ExposlistWidget->addItem(itm); } - if(curDest!=(int)md->chn) { - str = getStickStr(md->chn); + if (curDest!=(int)md->chn) { + if (GetEepromInterface()->getCapability(VirtualInputs)) + str = QString("%1").arg(getInputStr(model, md->chn), -8, ' '); + else + str = getInputStr(model, md->chn); curDest = md->chn; - } else { + } + else { str = " "; } - if (!GetEepromInterface()->getCapability(VirtualInputs)) { + if (GetEepromInterface()->getCapability(VirtualInputs)) { + str += " " + tr("Source(%1)").arg(md->srcRaw.toString()); + } + else { switch (md->mode) { case (1): str += " <-"; break; case (2): str += " ->"; break; @@ -94,12 +107,10 @@ void InputsPanel::update() if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch(%1)").arg(md->swtch.toString()); if (GetEepromInterface()->getCapability(HasExpoNames)) { - QString ExpoName; - ExpoName.append(md->name); - if (!ExpoName.isEmpty()) { - str+=QString("(%1)").arg(ExpoName); - } + QString expoName = md->name; + if (!expoName.isEmpty()) str += QString(" [%1]").arg(expoName); } + qba.clear(); qba.append((quint8)i); qba.append((const char*)md, sizeof(ExpoData)); @@ -108,9 +119,9 @@ void InputsPanel::update() ExposlistWidget->addItem(itm); //(str); } - while(curDestexec()) { + ExpoDialog *g = new ExpoDialog(this, model, &mixd, generalSettings.stickMode); + if (g->exec()) { model.expoData[index] = mixd; emit modified(); update(); - } else { + } + else { if (expoInserted) { gm_deleteExpo(index); } diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index d0d4c3560..6d527b6d6 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -19,76 +19,32 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) : else this->setWindowTitle(tr("DEST -> CH%1%2").arg(md->destCh/10).arg(md->destCh%10)); - populateSourceCB(ui->sourceCB, md->srcRaw, POPULATE_SOURCES | POPULATE_SWITCHES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0)); - + populateSourceCB(ui->sourceCB, md->srcRaw, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0)); ui->sourceCB->removeItem(0); - int limit=GetEepromInterface()->getCapability(OffsetWeight); - int gvars=0; - if (GetEepromInterface()->getCapability(HasVariants)) { - if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) { - gvars=1; - } - } else { - gvars=1; - } - if (gvars==0) { - ui->offsetGV->setDisabled(true); - ui->weightGV->setDisabled(true); - if (md->weight>limit || md->weight<-limit) { - md->weight=100; - } - if (md->sOffset>limit || md->sOffset<-limit) { - md->sOffset=0; - } - } - populateGVCB(ui->offsetCB,md->sOffset); - populateGVCB(ui->weightCB,md->weight); - ui->weightSB->setMinimum(-limit); - ui->weightSB->setMaximum(limit); - if (md->weight>limit || md->weight<-limit) { - ui->weightGV->setChecked(true); - ui->weightSB->hide(); - ui->weightCB->show(); - } - else { - ui->weightGV->setChecked(false); - ui->weightSB->setValue(md->weight); - ui->weightSB->show(); - ui->weightCB->hide(); - } - ui->offsetSB->setMinimum(-limit); - ui->offsetSB->setMaximum(limit); - if (md->sOffset>limit || md->sOffset<-limit) { - ui->offsetGV->setChecked(true); - ui->offsetSB->hide(); - ui->offsetCB->show(); - } - else { - ui->offsetGV->setChecked(false); - ui->offsetSB->setValue(md->sOffset); - ui->offsetSB->show(); - ui->offsetCB->hide(); - } + int limit = GetEepromInterface()->getCapability(OffsetWeight); + + gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, md->weight, 100, -limit, limit); + gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, md->sOffset, 0, -limit, limit); if (GetEepromInterface()->getCapability(VirtualInputs)) { ui->trimLabel->hide(); ui->trimCB->hide(); } - CurveGroup * curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve); + curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve); ui->MixDR_CB->setChecked(md->noExpo==0); if (!GetEepromInterface()->getCapability(MixesWithoutExpo)) { ui->MixDR_CB->hide(); ui->label_MixDR->hide(); } - if (GetEepromInterface()->getCapability(ExtraTrims)) { - ui->trimCB->addItem(tr("Rud"),1); - ui->trimCB->addItem(tr("Ele"),2); - ui->trimCB->addItem(tr("Thr"),3); - ui->trimCB->addItem(tr("Ail"),4); - } + + ui->trimCB->addItem(tr("Rud"), 1); + ui->trimCB->addItem(tr("Ele"), 2); + ui->trimCB->addItem(tr("Thr"), 3); + ui->trimCB->addItem(tr("Ail"), 4); + ui->trimCB->setCurrentIndex((-md->carryTrim)+1); int namelength=GetEepromInterface()->getCapability(HasMixerNames); if (!namelength) { @@ -147,12 +103,6 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) : valuesChanged(); connect(ui->mixerName,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->sourceCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); - connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); - connect(ui->offsetCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); - connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); - connect(ui->offsetSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); - connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); // TODO why the same slot? - connect(ui->offsetGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); connect(ui->trimCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->MixDR_CB,SIGNAL(toggled(bool)),this,SLOT(valuesChanged())); connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); @@ -169,54 +119,23 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) : MixerDialog::~MixerDialog() { - delete ui; + delete gvWeightGroup; + delete gvOffsetGroup; + delete curveGroup; + delete ui; } void MixerDialog::changeEvent(QEvent *e) { - QDialog::changeEvent(e); - switch (e->type()) { + QDialog::changeEvent(e); + + switch (e->type()) { case QEvent::LanguageChange: - ui->retranslateUi(this); - break; + ui->retranslateUi(this); + break; default: - break; - } -} - -void MixerDialog::widgetChanged() -{ - int gvars = 0; - if (GetEepromInterface()->getCapability(HasVariants)) { - if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) { - gvars = 1; - } + break; } - else { - gvars = 1; - } - - if (gvars == 1) { - if (ui->weightGV->isChecked()) { - ui->weightCB->show(); - ui->weightSB->hide(); - } - else { - ui->weightCB->hide(); - ui->weightSB->show(); - } - if (ui->offsetGV->isChecked()) { - ui->offsetCB->show(); - ui->offsetSB->hide(); - } - else { - ui->offsetCB->hide(); - ui->offsetSB->show(); - } - } - - valuesChanged(); - QTimer::singleShot(0, this, SLOT(shrink())); } void MixerDialog::valuesChanged() @@ -237,16 +156,6 @@ void MixerDialog::valuesChanged() ui->MixDR_CB->setHidden(true); ui->label_MixDR->setHidden(true); } - if (ui->weightGV->isChecked()) { - md->weight = ui->weightCB->itemData(ui->weightCB->currentIndex()).toInt(); - } else { - md->weight = ui->weightSB->value(); - } - if (ui->offsetGV->isChecked()) { - md->sOffset = ui->offsetCB->itemData(ui->offsetCB->currentIndex()).toInt(); - } else { - md->sOffset = ui->offsetSB->value(); - } md->carryTrim = -(ui->trimCB->currentIndex()-1); md->noExpo = ui->MixDR_CB->checkState() ? 0 : 1; md->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt()); @@ -276,6 +185,7 @@ void MixerDialog::valuesChanged() } } -void MixerDialog::shrink() { - resize(0,0); +void MixerDialog::shrink() +{ + resize(0, 0); } diff --git a/companion/src/modeledit/mixerdialog.h b/companion/src/modeledit/mixerdialog.h index 9435e1892..df2046e0f 100644 --- a/companion/src/modeledit/mixerdialog.h +++ b/companion/src/modeledit/mixerdialog.h @@ -4,29 +4,33 @@ #include #include "eeprominterface.h" +class GVarGroup; +class CurveGroup; + namespace Ui { - class MixerDialog; + class MixerDialog; } class MixerDialog : public QDialog { Q_OBJECT -public: + public: MixerDialog(QWidget *parent, MixData *mixdata, int stickMode); ~MixerDialog(); -protected: + protected: void changeEvent(QEvent *e); -private slots: - void widgetChanged(); + private slots: void valuesChanged(); void shrink(); - -private: + private: Ui::MixerDialog *ui; MixData *md; bool lock; + GVarGroup * gvWeightGroup; + GVarGroup * gvOffsetGroup; + CurveGroup * curveGroup; }; #endif // MIXERDIALOG_H diff --git a/companion/src/printdialog.cpp b/companion/src/printdialog.cpp index ac1cc9feb..e952e3ee3 100644 --- a/companion/src/printdialog.cpp +++ b/companion/src/printdialog.cpp @@ -176,7 +176,7 @@ QString printDialog::printPhases() str.append(""); for (int i=0; i<4; i++) { - str.append(QString("").arg(getStickStr(i))); + str.append(QString("").arg(getInputStr(*g_model, i))); } if (gvars==1) { for (int i=0; i
"+tr("Switch")+"
"+tr("Flight mode name")); str.append(""+tr("IN")+""+tr("OUT")+"%1%1"); if(lastCHN!=ed->chn) { lastCHN=ed->chn; - str.append(""+getStickStr(ed->chn)+""); + str.append(""+getInputStr(*g_model, ed->chn)+""); } else str.append(" ");