Beispiel #1
0
GVarGroup::GVarGroup(QCheckBox *weightGV, QAbstractSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const double step, bool allowGvars):
  QObject(),
  weightGV(weightGV),
  weightSB(weightSB),
  sb(dynamic_cast<QSpinBox *>(weightSB)),
  dsb(dynamic_cast<QDoubleSpinBox *>(weightSB)),
  weightCB(weightCB),
  weight(weight),
  step(step),
  lock(true)
{
  if (allowGvars && GetCurrentFirmware()->getCapability(Gvars)) {
    populateGVCB(weightCB, weight);
    connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int)));
    connect(weightCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
  }
Beispiel #2
0
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 (GetCurrentFirmware()->getCapability(Gvars)) {
    populateGVCB(weightCB, weight);
    connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int)));
    connect(weightCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
  }
Beispiel #3
0
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()));
}