mirror of
https://github.com/opentx/opentx.git
synced 2025-07-21 15:25:17 +03:00
Fixes #3353
This commit is contained in:
parent
a84357ad0b
commit
c5a44250fc
6 changed files with 38 additions and 31 deletions
|
@ -103,7 +103,7 @@ void populatePhasesCB(QComboBox *b, int value)
|
||||||
b->setCurrentIndex(value + GetCurrentFirmware()->getCapability(FlightModes));
|
b->setCurrentIndex(value + GetCurrentFirmware()->getCapability(FlightModes));
|
||||||
}
|
}
|
||||||
|
|
||||||
GVarGroup::GVarGroup(QCheckBox *weightGV, QAbstractSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const double step, bool allowGvars):
|
GVarGroup::GVarGroup(QCheckBox * weightGV, QAbstractSpinBox * weightSB, QComboBox * weightCB, int & weight, const ModelData & model, const int deflt, const int mini, const int maxi, const double step, bool allowGvars):
|
||||||
QObject(),
|
QObject(),
|
||||||
weightGV(weightGV),
|
weightGV(weightGV),
|
||||||
weightSB(weightSB),
|
weightSB(weightSB),
|
||||||
|
@ -115,7 +115,7 @@ GVarGroup::GVarGroup(QCheckBox *weightGV, QAbstractSpinBox *weightSB, QComboBox
|
||||||
lock(true)
|
lock(true)
|
||||||
{
|
{
|
||||||
if (allowGvars && GetCurrentFirmware()->getCapability(Gvars)) {
|
if (allowGvars && GetCurrentFirmware()->getCapability(Gvars)) {
|
||||||
populateGVCB(weightCB, weight);
|
populateGVCB(*weightCB, weight, model);
|
||||||
connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int)));
|
connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int)));
|
||||||
connect(weightCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
connect(weightCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
||||||
}
|
}
|
||||||
|
@ -179,13 +179,14 @@ void GVarGroup::valuesChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CurveGroup::CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags):
|
CurveGroup::CurveGroup(QComboBox * curveTypeCB, QCheckBox * curveGVarCB, QComboBox * curveValueCB, QSpinBox * curveValueSB, CurveReference & curve, const ModelData & model, unsigned int flags):
|
||||||
QObject(),
|
QObject(),
|
||||||
curveTypeCB(curveTypeCB),
|
curveTypeCB(curveTypeCB),
|
||||||
curveGVarCB(curveGVarCB),
|
curveGVarCB(curveGVarCB),
|
||||||
curveValueCB(curveValueCB),
|
curveValueCB(curveValueCB),
|
||||||
curveValueSB(curveValueSB),
|
curveValueSB(curveValueSB),
|
||||||
curve(curve),
|
curve(curve),
|
||||||
|
model(model),
|
||||||
flags(flags),
|
flags(flags),
|
||||||
lock(false),
|
lock(false),
|
||||||
lastType(-1)
|
lastType(-1)
|
||||||
|
@ -219,7 +220,7 @@ void CurveGroup::update()
|
||||||
curveGVarCB->setChecked(true);
|
curveGVarCB->setChecked(true);
|
||||||
if (lastType != CurveReference::CURVE_REF_DIFF && lastType != CurveReference::CURVE_REF_EXPO) {
|
if (lastType != CurveReference::CURVE_REF_DIFF && lastType != CurveReference::CURVE_REF_EXPO) {
|
||||||
lastType = curve.type;
|
lastType = curve.type;
|
||||||
populateGVCB(curveValueCB, curve.value);
|
populateGVCB(*curveValueCB, curve.value, model);
|
||||||
}
|
}
|
||||||
curveValueCB->show();
|
curveValueCB->show();
|
||||||
curveValueSB->hide();
|
curveValueSB->hide();
|
||||||
|
@ -478,33 +479,39 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
|
||||||
b->setMaxVisibleItems(10);
|
b->setMaxVisibleItems(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void populateGVCB(QComboBox *b, int value)
|
void populateGVCB(QComboBox & b, int value, const ModelData & model)
|
||||||
{
|
{
|
||||||
bool selected = false;
|
bool selected = false;
|
||||||
|
|
||||||
b->clear();
|
b.clear();
|
||||||
|
|
||||||
int pgvars = GetCurrentFirmware()->getCapability(Gvars);
|
int count = GetCurrentFirmware()->getCapability(Gvars);
|
||||||
for (int i=-pgvars; i<=-1; i++) {
|
for (int i=-count; i<=-1; i++) {
|
||||||
int16_t gval = (int16_t)(-10000+i);
|
int16_t gval = (int16_t)(-10000+i);
|
||||||
b->addItem(QObject::tr("-GV%1").arg(-i), gval);
|
if (strlen(model.gvars_names[-i-1]) > 0)
|
||||||
|
b.addItem(QObject::tr("-GV%1 (%2)").arg(-i).arg(model.gvars_names[-i-1]), gval);
|
||||||
|
else
|
||||||
|
b.addItem(QObject::tr("-GV%1").arg(-i), gval);
|
||||||
if (value == gval) {
|
if (value == gval) {
|
||||||
b->setCurrentIndex(b->count()-1);
|
b.setCurrentIndex(b.count()-1);
|
||||||
selected = true;
|
selected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=1; i<=pgvars; i++) {
|
for (int i=1; i<=count; i++) {
|
||||||
int16_t gval = (int16_t)(10000+i);
|
int16_t gval = (int16_t)(10000+i);
|
||||||
b->addItem(QObject::tr("GV%1").arg(i), gval);
|
if (strlen(model.gvars_names[i-1]) > 0)
|
||||||
|
b.addItem(QObject::tr("GV%1 (%2)").arg(i).arg(model.gvars_names[i-1]), gval);
|
||||||
|
else
|
||||||
|
b.addItem(QObject::tr("GV%1").arg(i), gval);
|
||||||
if (value == gval) {
|
if (value == gval) {
|
||||||
b->setCurrentIndex(b->count()-1);
|
b.setCurrentIndex(b.count()-1);
|
||||||
selected = true;
|
selected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selected) {
|
if (!selected) {
|
||||||
b->setCurrentIndex(pgvars);
|
b.setCurrentIndex(count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class GVarGroup: public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GVarGroup(QCheckBox *weightGV, QAbstractSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const double step=1.0, bool allowGVars=true);
|
GVarGroup(QCheckBox * weightGV, QAbstractSpinBox * weightSB, QComboBox * weightCB, int & weight, const ModelData & model, const int deflt, const int mini, const int maxi, const double step=1.0, bool allowGVars=true);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void gvarCBChanged(int);
|
void gvarCBChanged(int);
|
||||||
|
@ -72,7 +72,7 @@ class CurveGroup : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags=0);
|
CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, const ModelData & model, unsigned int flags=0);
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
@ -86,6 +86,7 @@ class CurveGroup : public QObject {
|
||||||
QComboBox *curveValueCB;
|
QComboBox *curveValueCB;
|
||||||
QSpinBox *curveValueSB;
|
QSpinBox *curveValueSB;
|
||||||
CurveReference & curve;
|
CurveReference & curve;
|
||||||
|
const ModelData & model;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
bool lock;
|
bool lock;
|
||||||
int lastType;
|
int lastType;
|
||||||
|
@ -118,8 +119,7 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||||
#define GVARS_VARIANT 0x0001
|
#define GVARS_VARIANT 0x0001
|
||||||
#define FRSKY_VARIANT 0x0002
|
#define FRSKY_VARIANT 0x0002
|
||||||
|
|
||||||
// void populateGVarCB(QComboBox *b, int value, int min, int max,int pgvars=5); //TODO: Clean Up
|
void populateGVCB(QComboBox & b, int value, const ModelData & model);
|
||||||
void populateGVCB(QComboBox *b, int value);
|
|
||||||
void populateSourceCB(QComboBox *b, const RawSource &source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags);
|
void populateSourceCB(QComboBox *b, const RawSource &source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags);
|
||||||
QString image2qstring(QImage image);
|
QString image2qstring(QImage image);
|
||||||
int findmult(float value, float base);
|
int findmult(float value, float base);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, int min, int max, int deflt):
|
LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row, int col, int & value, const ModelData & model, int min, int max, int deflt):
|
||||||
firmware(firmware),
|
firmware(firmware),
|
||||||
spinbox(new QDoubleSpinBox()),
|
spinbox(new QDoubleSpinBox()),
|
||||||
value(value),
|
value(value),
|
||||||
|
@ -44,7 +44,7 @@ LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row,
|
||||||
horizontalLayout->addWidget(cb);
|
horizontalLayout->addWidget(cb);
|
||||||
horizontalLayout->addWidget(spinbox);
|
horizontalLayout->addWidget(spinbox);
|
||||||
tableLayout->addLayout(row, col, horizontalLayout);
|
tableLayout->addLayout(row, col, horizontalLayout);
|
||||||
gvarGroup = new GVarGroup(gv, spinbox, cb, value, deflt, min, max, displayStep, allowGVars);
|
gvarGroup = new GVarGroup(gv, spinbox, cb, value, model, deflt, min, max, displayStep, allowGVars);
|
||||||
}
|
}
|
||||||
|
|
||||||
LimitsGroup::~LimitsGroup()
|
LimitsGroup::~LimitsGroup()
|
||||||
|
@ -113,13 +113,13 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
|
||||||
}
|
}
|
||||||
|
|
||||||
// Channel offset
|
// Channel offset
|
||||||
limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].offset, -1000, 1000, 0);
|
limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].offset, model, -1000, 1000, 0);
|
||||||
|
|
||||||
// Channel min
|
// Channel min
|
||||||
limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].min, -model.getChannelsMax()*10, 0, -1000);
|
limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].min, model, -model.getChannelsMax()*10, 0, -1000);
|
||||||
|
|
||||||
// Channel max
|
// Channel max
|
||||||
limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].max, 0, model.getChannelsMax()*10, 1000);
|
limitsGroups << new LimitsGroup(firmware, tableLayout, i, col++, model.limitData[i].max, model, 0, model.getChannelsMax()*10, 1000);
|
||||||
|
|
||||||
// Channel inversion
|
// Channel inversion
|
||||||
QComboBox * invCB = new QComboBox(this);
|
QComboBox * invCB = new QComboBox(this);
|
||||||
|
|
|
@ -9,7 +9,7 @@ class GVarGroup;
|
||||||
class LimitsGroup
|
class LimitsGroup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, int min, int max, int deflt);
|
LimitsGroup(Firmware * firmware, TableLayout *tableLayout, int row, int col, int & value, const ModelData & model, int min, int max, int deflt);
|
||||||
~LimitsGroup();
|
~LimitsGroup();
|
||||||
|
|
||||||
void updateMinMax(int max);
|
void updateMinMax(int max);
|
||||||
|
|
|
@ -21,11 +21,11 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||||
|
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||||
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, 100, -100, 100);
|
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, model, 100, -100, 100);
|
||||||
gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, ed->offset, 0, -100, 100);
|
gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, ed->offset, model, 0, -100, 100);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, 100, 0, 100);
|
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, model, 100, 0, 100);
|
||||||
gvOffsetGroup = NULL;
|
gvOffsetGroup = NULL;
|
||||||
ui->offsetLabel->hide();
|
ui->offsetLabel->hide();
|
||||||
ui->offsetGV->hide();
|
ui->offsetGV->hide();
|
||||||
|
@ -33,7 +33,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||||
ui->offsetCB->hide();
|
ui->offsetCB->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve,
|
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, model,
|
||||||
firmware->getCapability(HasInputDiff) ? 0 : (HIDE_DIFF | HIDE_NEGATIVE_CURVES));
|
firmware->getCapability(HasInputDiff) ? 0 : (HIDE_DIFF | HIDE_NEGATIVE_CURVES));
|
||||||
|
|
||||||
populateSwitchCB(ui->switchesCB, ed->swtch, generalSettings, MixesContext);
|
populateSwitchCB(ui->switchesCB, ed->swtch, generalSettings, MixesContext);
|
||||||
|
|
|
@ -25,10 +25,10 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
|
||||||
|
|
||||||
int limit = firmware->getCapability(OffsetWeight);
|
int limit = firmware->getCapability(OffsetWeight);
|
||||||
|
|
||||||
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, md->weight, 100, -limit, limit);
|
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, md->weight, model, 100, -limit, limit);
|
||||||
gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, md->sOffset, 0, -limit, limit);
|
gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, md->sOffset, model, 0, -limit, limit);
|
||||||
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB,
|
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB,
|
||||||
md->curve, firmware->getCapability(HasMixerExpo) ? 0 : HIDE_EXPO);
|
md->curve, model, firmware->getCapability(HasMixerExpo) ? 0 : HIDE_EXPO);
|
||||||
|
|
||||||
ui->MixDR_CB->setChecked(md->noExpo == 0);
|
ui->MixDR_CB->setChecked(md->noExpo == 0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue