FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseIdx, GeneralSettings & generalSettings, Firmware * firmware): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::FlightMode), phaseIdx(phaseIdx), phase(model.flightModeData[phaseIdx]), reCount(firmware->getCapability(RotaryEncoders)), gvCount(firmware->getCapability(Gvars)) { ui->setupUi(this); ui->labelName->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->labelName, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(name_customContextMenuRequested(const QPoint &))); int modesCount = firmware->getCapability(FlightModes); // Phase name QRegExp rx(CHAR_FOR_NAMES_REGEX); if (modesCount) { ui->name->setValidator(new QRegExpValidator(rx, this)); ui->name->setMaxLength(firmware->getCapability(FlightModesName)); connect(ui->name, SIGNAL(editingFinished()), this, SLOT(phaseName_editingFinished())); } else { ui->name->setDisabled(true); } // Phase switch if (phaseIdx > 0) { populateSwitchCB(ui->swtch, phase.swtch, generalSettings, MixesContext); connect(ui->swtch, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseSwitch_currentIndexChanged(int))); }
void CustomFunctionsPanel::fswDelete() { model.funcSw[selectedFunction].clear(); // TODO update switch and func lock = true; populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, generalSettings, CustomFunctionsContext); populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func); refreshCustomFunction(selectedFunction); lock = false; emit modified(); }
void CustomFunctionsPanel::update() { lock = true; for (int i=0; i<firmware->getCapability(CustomFunctions); i++) { if (!initialized) { populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, generalSettings, CustomFunctionsContext); populateFuncCB(fswtchFunc[i], model.funcSw[i].func); populateGVmodeCB(fswtchGVmode[i], model.funcSw[i].adjustMode); populateFuncParamCB(fswtchParamT[i], model, model.funcSw[i].func, model.funcSw[i].param, model.funcSw[i].adjustMode); } refreshCustomFunction(i); } initialized = true; lock = false; }
void CustomFunctionsPanel::update() { lock = true; int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions); for (int i=0; i<num_fsw; i++) { if (!initialized) { populateSwitchCB(fswtchSwtch[i], functions[i].swtch, generalSettings, model ? SpecialFunctionsContext : GlobalFunctionsContext); populateFuncCB(fswtchFunc[i], functions[i].func); populateGVmodeCB(fswtchGVmode[i], functions[i].adjustMode); populateFuncParamCB(fswtchParamT[i], functions[i].func, functions[i].param, functions[i].adjustMode); } refreshCustomFunction(i); } initialized = true; lock = false; }
void CustomFunctionsPanel::fswPaste() { const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); if (mimeData->hasFormat("application/x-companion-fsw")) { QByteArray fswData = mimeData->data("application/x-companion-fsw"); FuncSwData *fsw = &model.funcSw[selectedFunction]; memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData)); lock = true; populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, generalSettings, CustomFunctionsContext); populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func); populateGVmodeCB(fswtchGVmode[selectedFunction], model.funcSw[selectedFunction].adjustMode); populateFuncParamCB(fswtchParamT[selectedFunction], model, model.funcSw[selectedFunction].func, model.funcSw[selectedFunction].param, model.funcSw[selectedFunction].adjustMode); refreshCustomFunction(selectedFunction); lock = false; emit modified(); } }
MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, GeneralSettings & generalSettings, Firmware * firmware) : QDialog(parent), ui(new Ui::MixerDialog), model(model), generalSettings(generalSettings), firmware(firmware), md(mixdata), lock(false) { ui->setupUi(this); QRegExp rx(CHAR_FOR_NAMES_REGEX); 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 }; this->setWindowTitle(tr("DEST -> CH%1").arg(md->destCh)); populateSourceCB(ui->sourceCB, md->srcRaw, generalSettings, &model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); ui->sourceCB->removeItem(0); int limit = firmware->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); curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve, firmware->getCapability(HasMixerExpo) ? 0 : HIDE_EXPO); ui->MixDR_CB->setChecked(md->noExpo == 0); if (!firmware->getCapability(HasNoExpo)) { ui->MixDR_CB->hide(); ui->label_MixDR->hide(); } if (!firmware->getCapability(VirtualInputs)) { for(int i=0; i < NUM_STICKS; i++) { ui->trimCB->addItem(AnalogString(i)); } } ui->trimCB->setCurrentIndex(1 - md->carryTrim); int namelength = firmware->getCapability(HasMixerNames); if (!namelength) { ui->label_name->hide(); ui->mixerName->hide(); } else { ui->mixerName->setMaxLength(namelength); } ui->mixerName->setValidator(new QRegExpValidator(rx, this)); ui->mixerName->setText(md->name); if (!firmware->getCapability(FlightModes)) { 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 ((md->flightModes & mask) == 0) { cb_fp[i]->setChecked(true); } mask <<= 1; } for (int i=firmware->getCapability(FlightModes); i<9; i++) { lb_fp[i]->hide(); cb_fp[i]->hide(); } } populateSwitchCB(ui->switchesCB, md->swtch, generalSettings, MixesContext); ui->warningCB->setCurrentIndex(md->mixWarn); ui->mltpxCB->setCurrentIndex(md->mltpx); int scale=firmware->getCapability(SlowScale); float range=firmware->getCapability(SlowRange); ui->slowDownSB->setMaximum(range/scale); ui->slowDownSB->setSingleStep(1.0/scale); ui->slowDownSB->setDecimals((scale==1 ? 0 :1)); ui->slowDownSB->setValue((float)md->speedDown/scale); ui->slowUpSB->setMaximum(range/scale); ui->slowUpSB->setSingleStep(1.0/scale); ui->slowUpSB->setDecimals((scale==1 ? 0 :1)); ui->slowUpSB->setValue((float)md->speedUp/scale); ui->delayDownSB->setMaximum(range/scale); ui->delayDownSB->setSingleStep(1.0/scale); ui->delayDownSB->setDecimals((scale==1 ? 0 :1)); ui->delayDownSB->setValue((float)md->delayDown/scale); ui->delayUpSB->setMaximum(range/scale); ui->delayUpSB->setSingleStep(1.0/scale); ui->delayUpSB->setDecimals((scale==1 ? 0 :1)); ui->delayUpSB->setValue((float)md->delayUp/scale); QTimer::singleShot(0, this, SLOT(shrink())); valuesChanged(); connect(ui->mixerName,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->sourceCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); 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())); connect(ui->warningCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->mltpxCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->delayDownSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->delayUpSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->slowDownSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->slowUpSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); for (int i=0; i<9; i++) { connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged())); } }
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, Firmware * firmware): GenericPanel(parent, model, generalSettings, firmware), functions(model ? model->customFn : generalSettings.customFn) #if defined(PHONON) , phononCurrent(-1), clickObject(NULL), clickOutput(NULL) #endif { Stopwatch s1("CustomFunctionsPanel - populate"); lock = true; int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions); if (!firmware->getCapability(VoicesAsNumbers)) { tracksSet = getFilesSet(getSoundsPath(generalSettings), QStringList() << "*.wav" << "*.WAV", firmware->getCapability(VoicesMaxLength)); for (int i=0; i<num_fsw; i++) { if (functions[i].func==FuncPlayPrompt || functions[i].func==FuncBackgroundMusic) { QString temp = functions[i].paramarm; if (!temp.isEmpty()) { tracksSet.insert(temp); } } } } s1.report("get tracks"); if (IS_TARANIS(firmware->getBoard())) { scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/FUNCTIONS", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength)); for (int i=0; i<num_fsw; i++) { if (functions[i].func==FuncPlayScript) { QString temp = functions[i].paramarm; if (!temp.isEmpty()) { scriptsSet.insert(temp); } } } } s1.report("get scripts"); CompanionIcon playIcon("play.png"); QStringList headerLabels; headerLabels << "#" << tr("Switch") << tr("Action") << tr("Parameters") << tr("Enable"); TableLayout * tableLayout = new TableLayout(this, num_fsw, headerLabels); for (int i=0; i<num_fsw; i++) { // The label QLabel * label = new QLabel(this); label->setContextMenuPolicy(Qt::CustomContextMenu); label->setMouseTracking(true); label->setProperty("index", i); if (model) label->setText(tr("SF%1").arg(i+1)); else label->setText(tr("GF%1").arg(i+1)); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint))); tableLayout->addWidget(i, 0, label); // s1.report("label"); // The switch fswtchSwtch[i] = new QComboBox(this); fswtchSwtch[i]->setProperty("index", i); populateSwitchCB(fswtchSwtch[i], functions[i].swtch, generalSettings, model ? SpecialFunctionsContext : GlobalFunctionsContext); fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); fswtchSwtch[i]->setMaxVisibleItems(10); connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); tableLayout->addWidget(i, 1, fswtchSwtch[i]); // s1.report("switch"); // The function fswtchFunc[i] = new QComboBox(this); fswtchFunc[i]->setProperty("index", i); populateFuncCB(fswtchFunc[i], functions[i].func); connect(fswtchFunc[i], SIGNAL(currentIndexChanged(int)), this, SLOT(functionEdited())); tableLayout->addWidget(i, 2, fswtchFunc[i]); // s1.report("func"); // The parameters QHBoxLayout * paramLayout = new QHBoxLayout(); tableLayout->addLayout(i, 3, paramLayout); fswtchGVmode[i] = new QComboBox(this); fswtchGVmode[i]->setProperty("index", i); populateGVmodeCB(fswtchGVmode[i], functions[i].adjustMode); fswtchGVmode[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); connect(fswtchGVmode[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); paramLayout->addWidget(fswtchGVmode[i]); fswtchParamGV[i] = new QCheckBox(this); fswtchParamGV[i]->setProperty("index", i); fswtchParamGV[i]->setText("GV"); fswtchParamGV[i]->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); connect(fswtchParamGV[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); paramLayout->addWidget(fswtchParamGV[i]); fswtchParam[i] = new QDoubleSpinBox(this); fswtchParam[i]->setProperty("index", i); fswtchParam[i]->setAccelerated(true); fswtchParam[i]->setDecimals(0); connect(fswtchParam[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited())); paramLayout->addWidget(fswtchParam[i]); fswtchParamTime[i] = new QTimeEdit(this); fswtchParamTime[i]->setProperty("index", i); fswtchParamTime[i]->setAccelerated(true); fswtchParamTime[i]->setDisplayFormat("hh:mm:ss"); connect(fswtchParamTime[i], SIGNAL(editingFinished()), this, SLOT(customFunctionEdited())); paramLayout->addWidget(fswtchParamTime[i]); fswtchParamT[i] = new QComboBox(this); fswtchParamT[i]->setProperty("index", i); populateFuncParamCB(fswtchParamT[i], functions[i].func, functions[i].param, functions[i].adjustMode); paramLayout->addWidget(fswtchParamT[i]); fswtchParamT[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); fswtchParamArmT[i] = new QComboBox(this); fswtchParamArmT[i]->setProperty("index", i); fswtchParamArmT[i]->setEditable(true); fswtchParamArmT[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); paramLayout->addWidget(fswtchParamArmT[i]); connect(fswtchParamArmT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited())); fswtchBLcolor[i] = new QSlider(this); fswtchBLcolor[i]->setProperty("index", i); fswtchBLcolor[i]->setMinimum(0); fswtchBLcolor[i]->setMaximum(100); fswtchBLcolor[i]->setSingleStep(1); fswtchBLcolor[i]->setOrientation(Qt::Horizontal); paramLayout->addWidget(fswtchBLcolor[i]); connect(fswtchBLcolor[i], SIGNAL(sliderReleased()), this, SLOT(customFunctionEdited())); #ifdef PHONON playBT[i] = new QPushButton(this); playBT[i]->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); playBT[i]->setProperty("index", i); playBT[i]->setIcon(playIcon); paramLayout->addWidget(playBT[i]); connect(playBT[i], SIGNAL(pressed()), this, SLOT(playMusic())); #endif QHBoxLayout * repeatLayout = new QHBoxLayout(); tableLayout->addLayout(i, 4, repeatLayout); fswtchRepeat[i] = new RepeatComboBox(this, functions[i].repeatParam); repeatLayout->addWidget(fswtchRepeat[i], i+1); connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified())); fswtchEnable[i] = new QCheckBox(this); fswtchEnable[i]->setProperty("index", i); fswtchEnable[i]->setText(tr("ON")); fswtchEnable[i]->setFixedWidth(200); repeatLayout->addWidget(fswtchEnable[i], i+1); connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited())); } s1.report("add items"); disableMouseScrolling(); s1.report("disableMouseScrolling"); lock = false; update(); s1.report("update"); tableLayout->resizeColumnsToContents(); s1.report("resizeColumnsToContents"); tableLayout->setColumnWidth(3, 300); tableLayout->pushRowsUp(num_fsw+1); s1.report("end"); }
GeneralEdit::GeneralEdit(EEPFILE *eFile, QWidget *parent) : QDialog(parent), ui(new Ui::GeneralEdit) { ui->setupUi(this); this->setWindowIcon(QIcon(":/icon.png")); eeFile = eFile; switchDefPosEditLock = false; QSettings settings("er9x-eePe", "eePe"); ui->tabWidget->setCurrentIndex(settings.value("generalEditTab", 0).toInt()); eeFile->getGeneralSettings(&g_eeGeneral); createSwitchMapping( &g_eeGeneral, eeFile->mee_type ) ; QRegExp rx(CHAR_FOR_NAMES_REGEX); ui->ownerNameLE->setValidator(new QRegExpValidator(rx, this)); populateSwitchCB(ui->backlightswCB,g_eeGeneral.lightSw,eeFile->mee_type); ui->ownerNameLE->setText(g_eeGeneral.ownerName); for(quint8 i=0; i<16; i++) { if (g_eeGeneral.customStickNames[i] == 0 ) { g_eeGeneral.customStickNames[i] = ' ' ; } } QString Str = (char *)g_eeGeneral.customStickNames ; ui->rudNameLE->setText( Str.mid(0,4)) ; ui->eleNameLE->setText( Str.mid(4,4)) ; ui->thrNameLE->setText( Str.mid(8,4)) ; ui->ailNameLE->setText( Str.mid(12,4)) ; ui->contrastSB->setValue(g_eeGeneral.contrast); ui->battwarningDSB->setValue((double)g_eeGeneral.vBatWarn/10); ui->battcalibDSB->setValue((double)g_eeGeneral.vBatCalib/10); ui->battCalib->setValue((double)g_eeGeneral.vBatCalib/10); ui->backlightautoSB->setValue(g_eeGeneral.lightAutoOff*5); ui->backlightStickMove->setValue(g_eeGeneral.lightOnStickMove*5); ui->inactimerSB->setValue(g_eeGeneral.inactivityTimer+10); ui->soundModeCB->setCurrentIndex(g_eeGeneral.speakerMode > 3 ? 4 : g_eeGeneral.speakerMode ); ui->speakerPitchSB->setValue(g_eeGeneral.speakerPitch); ui->hapticStengthSB->setValue(g_eeGeneral.hapticStrength); ui->thrrevChkB->setChecked(g_eeGeneral.throttleReversed); // ui->inputfilterCB->setCurrentIndex(g_eeGeneral.filterInput); ui->thrwarnChkB->setChecked(!g_eeGeneral.disableThrottleWarning); //Default is zero=checked ui->switchwarnChkB->setChecked(!g_eeGeneral.disableSwitchWarning); //Default is zero=checked ui->memwarnChkB->setChecked(!g_eeGeneral.disableMemoryWarning); //Default is zero=checked ui->alarmwarnChkB->setChecked(!g_eeGeneral.disableAlarmWarning);//Default is zero=checked ui->PotScrollEnableChkB->setChecked(!g_eeGeneral.disablePotScroll);//Default is zero=checked ui->StickScrollEnableChkB->setChecked(g_eeGeneral.stickScroll);//Default is zero=not checked ui->CrossTrimChkB->setChecked(g_eeGeneral.crosstrim);//Default is zero=not checked ui->FrskyPinsChkB->setChecked(g_eeGeneral.FrskyPins);//Default is zero=not checked ui->TeZ_gt_90ChkB->setChecked(g_eeGeneral.TEZr90);//Default is zero=not checked ui->MsoundSerialChkB->setChecked(g_eeGeneral.MegasoundSerial);//Default is zero=not checked ui->RotateScreenChkB->setChecked(g_eeGeneral.rotateScreen);//Default is zero=not checked ui->SerialLCDChkB->setChecked(g_eeGeneral.serialLCD);//Default is zero=not checked ui->SSD1306ChkB->setChecked(g_eeGeneral.SSD1306);//Default is zero=not checked ui->BandGapEnableChkB->setChecked(!g_eeGeneral.disableBG);//Default is zero=checked ui->beeperCB->setCurrentIndex(g_eeGeneral.beeperVal); ui->channelorderCB->setCurrentIndex(g_eeGeneral.templateSetup); ui->stickmodeCB->setCurrentIndex(g_eeGeneral.stickMode); ui->volumeSB->setValue(g_eeGeneral.volume+7); ui->enablePpmsimChkB->setChecked(g_eeGeneral.enablePpmsim); ui->internalFrskyAlarmChkB->setChecked(g_eeGeneral.frskyinternalalarm); ui->backlightinvertChkB->setChecked(g_eeGeneral.blightinv); ui->beepMinuteChkB->setChecked(g_eeGeneral.minuteBeep); ui->beepCountDownChkB->setChecked(g_eeGeneral.preBeep); ui->beepFlashChkB->setChecked(g_eeGeneral.flashBeep); ui->splashScreenChkB->setChecked(!g_eeGeneral.disableSplashScreen); ui->splashScreenNameChkB->setChecked(!g_eeGeneral.hideNameOnSplash); ui->ana1Neg->setValue(g_eeGeneral.calibSpanNeg[0]); ui->ana2Neg->setValue(g_eeGeneral.calibSpanNeg[1]); ui->ana3Neg->setValue(g_eeGeneral.calibSpanNeg[2]); ui->ana4Neg->setValue(g_eeGeneral.calibSpanNeg[3]); ui->ana5Neg->setValue(g_eeGeneral.calibSpanNeg[4]); ui->ana6Neg->setValue(g_eeGeneral.calibSpanNeg[5]); ui->ana7Neg->setValue(g_eeGeneral.calibSpanNeg[6]); ui->ana1Mid->setValue(g_eeGeneral.calibMid[0]); ui->ana2Mid->setValue(g_eeGeneral.calibMid[1]); ui->ana3Mid->setValue(g_eeGeneral.calibMid[2]); ui->ana4Mid->setValue(g_eeGeneral.calibMid[3]); ui->ana5Mid->setValue(g_eeGeneral.calibMid[4]); ui->ana6Mid->setValue(g_eeGeneral.calibMid[5]); ui->ana7Mid->setValue(g_eeGeneral.calibMid[6]); ui->ana1Pos->setValue(g_eeGeneral.calibSpanPos[0]); ui->ana2Pos->setValue(g_eeGeneral.calibSpanPos[1]); ui->ana3Pos->setValue(g_eeGeneral.calibSpanPos[2]); ui->ana4Pos->setValue(g_eeGeneral.calibSpanPos[3]); ui->ana5Pos->setValue(g_eeGeneral.calibSpanPos[4]); ui->ana6Pos->setValue(g_eeGeneral.calibSpanPos[5]); ui->ana7Pos->setValue(g_eeGeneral.calibSpanPos[6]); setSwitchDefPos(); ui->StickRevLH->setChecked(g_eeGeneral.stickReverse & 0x01); ui->StickRevLV->setChecked(g_eeGeneral.stickReverse & 0x02); ui->StickRevRV->setChecked(g_eeGeneral.stickReverse & 0x04); ui->StickRevRH->setChecked(g_eeGeneral.stickReverse & 0x08); ui->weightSB_1->findChild<QLineEdit*>()->setReadOnly(true); ui->weightSB_2->findChild<QLineEdit*>()->setReadOnly(true); ui->weightSB_3->findChild<QLineEdit*>()->setReadOnly(true); ui->weightSB_4->findChild<QLineEdit*>()->setReadOnly(true); updateTrianerTab(); connect(ui->modeCB_1, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->modeCB_2, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->modeCB_3, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->modeCB_4, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->weightSB_1, SIGNAL(editingFinished()), this, SLOT(trainerTabValueChanged())); connect(ui->weightSB_2, SIGNAL(editingFinished()), this, SLOT(trainerTabValueChanged())); connect(ui->weightSB_3, SIGNAL(editingFinished()), this, SLOT(trainerTabValueChanged())); connect(ui->weightSB_4, SIGNAL(editingFinished()), this, SLOT(trainerTabValueChanged())); connect(ui->sourceCB_1, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->sourceCB_2, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->sourceCB_3, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->sourceCB_4, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->swtchCB_1, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->swtchCB_2, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->swtchCB_3, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->swtchCB_4, SIGNAL(currentIndexChanged(int)), this, SLOT(trainerTabValueChanged())); connect(ui->trainerCalib_1, SIGNAL(editingFinished()), this, SLOT(trainerTabValueChanged())); connect(ui->trainerCalib_2, SIGNAL(editingFinished()), this, SLOT(trainerTabValueChanged())); connect(ui->trainerCalib_3, SIGNAL(editingFinished()), this, SLOT(trainerTabValueChanged())); connect(ui->trainerCalib_4, SIGNAL(editingFinished()), this, SLOT(trainerTabValueChanged())); connect(ui->PPM_MultiplierDSB, SIGNAL(editingFinished()), this, SLOT(trainerTabValueChanged())); connect(ui->weightSB_1, SIGNAL(valueChanged(int)), this, SLOT(validateWeightSB())); connect(ui->weightSB_2, SIGNAL(valueChanged(int)), this, SLOT(validateWeightSB())); connect(ui->weightSB_3, SIGNAL(valueChanged(int)), this, SLOT(validateWeightSB())); connect(ui->weightSB_4, SIGNAL(valueChanged(int)), this, SLOT(validateWeightSB())); populateHardwareSwitch(ui->EleSwitchSource, g_eeGeneral.ele2source ) ; populateHardwareSwitch(ui->AilSwitchSource, g_eeGeneral.ail2source ) ; populateHardwareSwitch(ui->Pb1SwitchSource, g_eeGeneral.pb1source ) ; populateHardwareSwitch(ui->Pb2SwitchSource, g_eeGeneral.pb2source ) ; ui->L_wrInputCB->setChecked( g_eeGeneral.lcd_wrInput ) ; ui->Pb7InputCB->setChecked( g_eeGeneral.pb7Input ) ; ui->Pg2InputCB->setChecked( g_eeGeneral.pg2Input ) ; }
ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) : QDialog(parent), ui(new Ui::ExpoDialog), 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 }; setWindowTitle(tr("DEST -> %1").arg(getStickStr(ed->chn))); QRegExp rx(CHAR_FOR_NAMES_REGEX); if (GetEepromInterface()->getCapability(GvarsAsWeight)) { int gvars=0; if (GetEepromInterface()->getCapability(HasVariants)) { if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) { gvars=1; } } else { gvars=1; } if (gvars==0) { ui->expoGV->setDisabled(true); ui->weightGV->setDisabled(true); ui->expoCurveGV->setDisabled(true); if (ed->expo>100) { ed->expo=0; } if (ed->weight>100 || ed->weight<-100) { ed->weight=100; } if (ed->curveParam>100 || ed->curveParam<-100) { ed->curveParam=0; } } populateGVCB(ui->expoCB,ed->expo); populateGVCB(ui->weightCB,ed->weight); populateGVCB(ui->expoCurveCB,ed->curveParam); 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->expoSB->setMinimum(-100); ui->expoSB->setMaximum(100); if (ed->expo>100 || ed->expo<-100) { ui->expoGV->setChecked(true); ui->expoSB->hide(); ui->expoCB->show(); } else { ui->expoGV->setChecked(false); ui->expoSB->setValue(ed->expo); ui->expoSB->show(); ui->expoCB->hide(); } ui->expoCurveSB->setMinimum(-100); ui->expoCurveSB->setMaximum(100); if (ed->curveParam>100 || ed->curveParam<-100) { ui->expoCurveGV->setChecked(true); ui->expoCurveSB->hide(); ui->expoCurveCB->show(); } else { ui->expoCurveGV->setChecked(false); ui->expoCurveSB->setValue(ed->curveParam); ui->expoCurveSB->show(); ui->expoCurveCB->hide(); } } else { ui->expoGV->hide(); ui->weightGV->hide(); ui->expoCurveGV->hide(); ui->expoSB->setMinimum(-100); ui->expoSB->setMaximum(100); ui->expoSB->setValue(ed->expo); ui->expoCurveSB->setMinimum(-100); ui->expoCurveSB->setMaximum(100); ui->expoCurveSB->setValue(ed->curveParam); ui->weightSB->setMinimum(0); ui->weightSB->setMaximum(100); ui->weightSB->setValue(ed->weight); } populateSwitchCB(ui->switchesCB,ed->swtch); if (ed->curveMode==0) { populateExpoCurvesCB(ui->curvesCB,0); // TODO capacity for er9x } else { populateExpoCurvesCB(ui->curvesCB,ed->curveParam); // TODO capacity for er9x } ui->modeCB->setCurrentIndex(ed->mode-1); if (!GetEepromInterface()->getCapability(HasExpoCurves)) { ui->label_curves->hide(); ui->curvesCB->hide(); ed->curveMode=1; } if (!GetEepromInterface()->getCapability(ExpoIsCurve)) { ui->expoCurveCB->hide(); ui->expoCurveSB->hide(); ui->expoCurveGV->hide(); ui->label_curves->setText(tr("Curve")); } else { ui->label_expo->hide(); ui->expoCB->hide(); ui->expoGV->hide(); ui->expoSB->hide(); } 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(); } } 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->expoCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->expoSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->expoCurveCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->expoCurveSB,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->curvesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->modeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->expoGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); connect(ui->expoCurveGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); 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(QWidget *parent, ModelData & model, ExpoData *expoData, GeneralSettings & generalSettings, Firmware * firmware, QString & inputName) : QDialog(parent), ui(new Ui::ExpoDialog), model(model), generalSettings(generalSettings), firmware(firmware), ed(expoData), inputName(inputName), modelPrinter(firmware, generalSettings, model) { 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("Edit %1").arg(modelPrinter.printInputName(ed->chn))); QRegExp rx(CHAR_FOR_NAMES_REGEX); if (IS_TARANIS(GetEepromInterface()->getBoard())) { gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, 100, -100, 100); gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, ed->offset, 0, -100, 100); } else { gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, 100, 0, 100); gvOffsetGroup = NULL; ui->offsetLabel->hide(); ui->offsetGV->hide(); ui->offsetSB->hide(); ui->offsetCB->hide(); } curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, firmware->getCapability(HasInputDiff) ? 0 : (HIDE_DIFF | HIDE_NEGATIVE_CURVES)); populateSwitchCB(ui->switchesCB, ed->swtch, generalSettings, MixesContext); ui->sideCB->setCurrentIndex(ed->mode-1); if (!firmware->getCapability(FlightModes)) { 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->flightModes & mask) == 0) { cb_fp[i]->setChecked(true); } mask <<= 1; } for (int i=firmware->getCapability(FlightModes); i<9; i++) { lb_fp[i]->hide(); cb_fp[i]->hide(); } } if (firmware->getCapability(VirtualInputs)) { ui->inputName->setMaxLength(4); populateSourceCB(ui->sourceCB, ed->srcRaw, generalSettings, &model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY); ui->sourceCB->removeItem(0); ui->inputName->setValidator(new QRegExpValidator(rx, this)); ui->inputName->setText(inputName); } else { ui->inputNameLabel->hide(); ui->inputName->hide(); ui->sourceLabel->hide(); ui->sourceCB->hide(); ui->trimLabel->hide(); ui->trimCB->hide(); } for(int i=0; i < NUM_STICKS; i++) { ui->trimCB->addItem(AnalogString(i), i+1); } ui->trimCB->setCurrentIndex(1 - ed->carryTrim); int expolength = firmware->getCapability(HasExpoNames); if (!expolength) { ui->lineNameLabel->hide(); ui->lineName->hide(); } else { ui->lineName->setMaxLength(expolength); } ui->lineName->setValidator(new QRegExpValidator(rx, this)); ui->lineName->setText(ed->name); updateScale(); valuesChanged(); connect(ui->lineName, SIGNAL(editingFinished()), this, SLOT(valuesChanged())); connect(ui->sourceCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged())); connect(ui->scale, SIGNAL(editingFinished()), this, SLOT(valuesChanged())); connect(ui->trimCB, 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())); } if (firmware->getCapability(VirtualInputs)) connect(ui->inputName, SIGNAL(editingFinished()), this, SLOT(valuesChanged())); QTimer::singleShot(0, this, SLOT(shrink())); }
VoiceAlarmDialog::VoiceAlarmDialog(QWidget *parent, VoiceAlarmData *invad, int eeType, int stickmode, int modelVersion, SKYModelData *pModel ) : QDialog(parent), ui(new Ui::VoiceAlarmDialog) { ui->setupUi(this); leeType = eeType ; lpModel = pModel ; vad = invad ; populateSourceCB( ui->SourceCB, stickmode, 1, vad->source, modelVersion, eeType ) ; // uint32_t value ; // value = vad->source ; // if ( eeType ) // { // if ( value >= EXTRA_POTS_POSITION ) // { // if ( value >= EXTRA_POTS_START ) // { // value -= ( EXTRA_POTS_START - EXTRA_POTS_POSITION ) ; // } // else // { // value += eeType == 2 ? 2 : NUM_EXTRA_POTS ; // } // } // } // ui->SourceCB->setCurrentIndex(value) ; populateSwitchCB( ui->SwitchCB, vad->swtch, eeType ) ; ui->FunctionCB->setCurrentIndex( vad->func ) ; ui->RateCB->setCurrentIndex( vad->rate ) ; ui->HapticCB->setCurrentIndex( vad->haptic ) ; ui->ValueSB->setValue( vad->offset ) ; ui->MuteCB->setCurrentIndex( vad->mute ) ; ui->FileTypeCB->setCurrentIndex( vad->fnameType ) ; ui->PlaySourceCB->setCurrentIndex( vad->vsource ) ; switch ( vad->fnameType ) { case 1 : ui->FileName->setText( (char *)vad->file.name ) ; break ; case 2 : ui->FileNumberSB->setValue( vad->file.vfile ) ; break ; case 3 : ui->AudioCB->setCurrentIndex( vad->file.vfile ) ; break ; } updateDisplay() ; connect(ui->SourceCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->FunctionCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->SwitchCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->RateCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->HapticCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->MuteCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->ValueSB,SIGNAL(valueChanged(int)),this,SLOT(valuesChanged())); connect(ui->FileTypeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->PlaySourceCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->FileName, SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->FileNumberSB,SIGNAL(valueChanged(int)),this,SLOT(valuesChanged())); connect(ui->AudioCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); }