mirror of
https://github.com/opentx/opentx.git
synced 2025-07-21 23:35:17 +03:00
Fixes in ExpoDialog. Some more code refactoring
This commit is contained in:
parent
888895b60b
commit
691b52572f
9 changed files with 134 additions and 211 deletions
|
@ -1351,6 +1351,34 @@ QString getProtocol(ModelData * g_model)
|
|||
return str;
|
||||
}
|
||||
|
||||
QString getPhasesStr(unsigned int phases, ModelData & model)
|
||||
{
|
||||
int numphases = GetEepromInterface()->getCapability(FlightPhases);
|
||||
|
||||
if (numphases && phases) {
|
||||
QString str;
|
||||
int count = 0;
|
||||
if (phases == (unsigned int)(1<<numphases) - 1) {
|
||||
str = QObject::tr("None");
|
||||
}
|
||||
if (phases) {
|
||||
for (int i=0; i<numphases;i++) {
|
||||
if (!(phases & (1<<i))) {
|
||||
if (count++ > 0) str += QString(", ");
|
||||
str += getPhaseName(i+1, model.phaseData[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > 1)
|
||||
return QObject::tr("Flight modes(%1)").arg(str);
|
||||
else
|
||||
return QObject::tr("Flight mode(%1)").arg(str);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
float c9xexpou(float point, float coeff)
|
||||
{
|
||||
float x=point*1024.0/100.0;
|
||||
|
|
|
@ -69,6 +69,7 @@ void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, in
|
|||
void populateTimerSwitchCB(QComboBox *b, int value);
|
||||
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model);
|
||||
QString getProtocolStr(const int proto);
|
||||
QString getPhasesStr(unsigned int phases, ModelData & model);
|
||||
|
||||
#define POPULATE_SOURCES 1
|
||||
#define POPULATE_TRIMS 2
|
||||
|
|
|
@ -57,8 +57,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
|
|||
|
||||
ui->sideCB->setCurrentIndex(ed->mode-1);
|
||||
|
||||
ui->label_expo->hide();
|
||||
|
||||
if (!GetEepromInterface()->getCapability(FlightPhases)) {
|
||||
ui->label_phases->hide();
|
||||
for (int i=0; i<9; i++) {
|
||||
|
@ -105,8 +103,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
|
|||
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->curveTypeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
||||
connect(ui->curveGVarCB,SIGNAL(stateChanged(int)),this,SLOT(valuesChanged()));
|
||||
|
@ -117,7 +113,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
|
|||
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->expoGV,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()));
|
||||
|
@ -174,7 +169,6 @@ void ExpoDialog::widgetChanged()
|
|||
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 };
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>370</width>
|
||||
<height>291</height>
|
||||
<height>331</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -44,14 +44,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Weight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1,0">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="weightGV">
|
||||
|
@ -85,47 +85,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_expo">
|
||||
<property name="text">
|
||||
<string>Expo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,1,0">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="expoGV">
|
||||
<property name="text">
|
||||
<string>GV</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="expoSB"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="expoCB">
|
||||
<property name="whatsThis">
|
||||
<string>Phase used by the expo.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_phases">
|
||||
<property name="text">
|
||||
|
@ -305,44 +264,6 @@ If blank then the expo is considered to be "ON" all the time.</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_curves">
|
||||
<property name="text">
|
||||
<string>Curve</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,1,0">
|
||||
<item>
|
||||
<widget class="QComboBox" name="curveTypeCB">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>The curve used by the expo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="curveGVarCB">
|
||||
<property name="text">
|
||||
<string>GV</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="curveValueCB">
|
||||
<property name="whatsThis">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="curveValueSB"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="sideLabel">
|
||||
<property name="text">
|
||||
|
@ -396,7 +317,7 @@ If blank then the expo is considered to be "ON" all the time.</string>
|
|||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
@ -408,41 +329,6 @@ If blank then the expo is considered to be "ON" all the time.</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="trimCB">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>No</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Yes</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="sourceLabel">
|
||||
<property name="text">
|
||||
<string>Source</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="trimLabel">
|
||||
<property name="text">
|
||||
<string>Include Trim</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="scaleLabel">
|
||||
<property name="text">
|
||||
<string>Scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="scaleSB">
|
||||
<property name="whatsThis">
|
||||
|
@ -466,6 +352,79 @@ p, li { white-space: pre-wrap; }
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="scaleLabel">
|
||||
<property name="text">
|
||||
<string>Scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="trimLabel">
|
||||
<property name="text">
|
||||
<string>Include Trim</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="sourceLabel">
|
||||
<property name="text">
|
||||
<string>Source</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="trimCB">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>No</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Yes</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_curves">
|
||||
<property name="text">
|
||||
<string>Curve</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,1,0">
|
||||
<item>
|
||||
<widget class="QComboBox" name="curveTypeCB">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>The curve used by the expo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="curveGVarCB">
|
||||
<property name="text">
|
||||
<string>GV</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="curveValueCB">
|
||||
<property name="whatsThis">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="curveValueSB"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
|
|
|
@ -88,43 +88,10 @@ void InputsPanel::update()
|
|||
|
||||
if (md->curve.value) str += " " + md->curve.toString();
|
||||
|
||||
if (GetEepromInterface()->getCapability(FlightPhases)) {
|
||||
if(md->phases) {
|
||||
if (md->phases!=(unsigned int)(1<<GetEepromInterface()->getCapability(FlightPhases))-1) {
|
||||
int mask=1;
|
||||
int first=0;
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases);i++) {
|
||||
if (!(md->phases & mask)) {
|
||||
first++;
|
||||
}
|
||||
mask <<=1;
|
||||
}
|
||||
if (first>1) {
|
||||
str += " " + tr("Flight modes") + QString("(");
|
||||
} else {
|
||||
str += " " + tr("Flight mode") + QString("(");
|
||||
}
|
||||
mask=1;
|
||||
first=1;
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases);i++) {
|
||||
if (!(md->phases & mask)) {
|
||||
if (!first) {
|
||||
str += QString(", ")+ QString("%1").arg(getPhaseName(i+1, model.phaseData[i].name));
|
||||
} else {
|
||||
str += QString("%1").arg(getPhaseName(i+1,model.phaseData[i].name));
|
||||
first=0;
|
||||
}
|
||||
}
|
||||
mask <<=1;
|
||||
}
|
||||
str += QString(")");
|
||||
}
|
||||
else {
|
||||
str += tr("DISABLED")+QString(" !!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
|
||||
QString phasesStr = getPhasesStr(md->phases, model);
|
||||
if (!phasesStr.isEmpty()) str += " " + phasesStr;
|
||||
|
||||
if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch(%1)").arg(md->swtch.toString());
|
||||
|
||||
if (GetEepromInterface()->getCapability(HasExpoNames)) {
|
||||
QString ExpoName;
|
||||
|
@ -231,7 +198,6 @@ void InputsPanel::setSelectedByExpoList(QList<int> list)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void InputsPanel::exposDelete(bool ask)
|
||||
{
|
||||
QMessageBox::StandardButton ret = QMessageBox::No;
|
||||
|
|
|
@ -22,6 +22,13 @@ class InputsPanel : public ModelPanel
|
|||
void expolistWidget_customContextMenuRequested(QPoint pos);
|
||||
void expolistWidget_doubleClicked(QModelIndex index);
|
||||
void expolistWidget_KeyPress(QKeyEvent *event);
|
||||
void exposDelete(bool ask=true);
|
||||
void exposCut();
|
||||
void exposCopy();
|
||||
void exposPaste();
|
||||
void exposDuplicate();
|
||||
void expoOpen(QListWidgetItem *item = NULL);
|
||||
void expoAdd();
|
||||
|
||||
private:
|
||||
GeneralSettings & generalSettings;
|
||||
|
@ -36,13 +43,6 @@ class InputsPanel : public ModelPanel
|
|||
void exposDeleteList(QList<int> list);
|
||||
QList<int> createExpoListFromSelected();
|
||||
void setSelectedByExpoList(QList<int> list);
|
||||
void exposDelete(bool ask=true);
|
||||
void exposCut();
|
||||
void exposCopy();
|
||||
void exposPaste();
|
||||
void exposDuplicate();
|
||||
void expoOpen(QListWidgetItem *item = NULL);
|
||||
void expoAdd();
|
||||
void pasteExpoMimeData(const QMimeData * mimeData, int destIdx);
|
||||
|
||||
};
|
||||
|
|
|
@ -49,7 +49,8 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
|
|||
ui->weightGV->setChecked(true);
|
||||
ui->weightSB->hide();
|
||||
ui->weightCB->show();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ui->weightGV->setChecked(false);
|
||||
ui->weightSB->setValue(md->weight);
|
||||
ui->weightSB->show();
|
||||
|
@ -70,6 +71,11 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
|
|||
ui->offsetCB->hide();
|
||||
}
|
||||
|
||||
if (GetEepromInterface()->getCapability(VirtualInputs)) {
|
||||
ui->trimLabel->hide();
|
||||
ui->trimCB->hide();
|
||||
}
|
||||
|
||||
CurveGroup * curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve);
|
||||
|
||||
ui->MixDR_CB->setChecked(md->noExpo==0);
|
||||
|
|
|
@ -179,7 +179,7 @@ p, li { white-space: pre-wrap; }
|
|||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<widget class="QLabel" name="trimLabel">
|
||||
<property name="text">
|
||||
<string>Include Trim</string>
|
||||
</property>
|
||||
|
|
|
@ -105,49 +105,18 @@ void MixesPanel::update()
|
|||
};
|
||||
|
||||
str += md->srcRaw.toString();
|
||||
|
||||
str += " " + tr("Weight(%1)").arg(getGVarString(md->weight, true));
|
||||
|
||||
unsigned int fpCount = GetEepromInterface()->getCapability(FlightPhases);
|
||||
if (GetEepromInterface()->getCapability(FlightPhases)) {
|
||||
if(md->phases) {
|
||||
if (md->phases!=(unsigned int)(1<<fpCount)-1) {
|
||||
int mask=1;
|
||||
int first=0;
|
||||
for (unsigned int i=0; i<fpCount; i++) {
|
||||
if (!(md->phases & mask)) {
|
||||
first++;
|
||||
QString phasesStr = getPhasesStr(md->phases, model);
|
||||
if (!phasesStr.isEmpty()) str += " " + phasesStr;
|
||||
|
||||
if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch(%1)").arg(md->swtch.toString());
|
||||
|
||||
if (md->carryTrim>0) {
|
||||
str += " " + tr("No Trim");
|
||||
}
|
||||
mask <<=1;
|
||||
}
|
||||
if (first>1) {
|
||||
str += " " + tr("Flight modes") + QString("(");
|
||||
} else {
|
||||
str += " " + tr("Flight mode") + QString("(");
|
||||
}
|
||||
mask=1;
|
||||
first=1;
|
||||
for (unsigned int i=0; i<fpCount; i++) {
|
||||
if (!(md->phases & mask)) {
|
||||
if (!first) {
|
||||
str += QString(", ")+ QString("%1").arg(getPhaseName(i+1, model.phaseData[i].name));
|
||||
}
|
||||
else {
|
||||
str += QString("%1").arg(getPhaseName(i+1,model.phaseData[i].name));
|
||||
first=0;
|
||||
}
|
||||
}
|
||||
mask <<=1;
|
||||
}
|
||||
str += QString(")");
|
||||
} else {
|
||||
str += tr("DISABLED")+QString(" !!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
|
||||
if(md->carryTrim>0) {
|
||||
str += " " +tr("No Trim");
|
||||
} else if (md->carryTrim<0) {
|
||||
else if (md->carryTrim<0) {
|
||||
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue