[Companion] Show custom control names throughout the UI (& internal refactoring) (#4693)

* [Companion] Introduce new Boards class to further consolidate hardware metadata and remove some globals.

* [Companion] * RawSource::toString() and RawSwitch::toString() can now return custom hardware names (if given a GeneralSettings object) for the following types (respectively):
    SOURCE_TYPE_STICK, SOURCE_TYPE_SWITCH, SWITCH_TYPE_SWITCH, & SWITCH_TYPE_MULTIPOS_POT;
* RawSource::isPot() and isSlider() can now return their own index position in potConfig[]/sliderConfig[];
* Switch indicator strings can be localized if necessary.

* [Companion] Refactor model printers to use new RawSource/RawSwitch capabilities; Simplify model-to-printer mapping scheme in multimodelprinter; Use const ModelData pointer.

* [Companion] Refactor how RawSource and RawSwitch selection combo boxes are populated, using cache-able data models instead of direct manipulation; Refactor some other Helpers function into their own namespace.

* Cosmetics & forgotten qualifier.
This commit is contained in:
Max Paperno
2017-03-27 19:02:19 +02:00
committed by Bertrand Songis
parent 627347a48c
commit f5ab145d2f
40 changed files with 886 additions and 747 deletions
+37 -16
View File
@@ -73,6 +73,13 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
lock = true;
int num_fsw = model ? firmware->getCapability(CustomFunctions) : firmware->getCapability(GlobalFunctions);
rawSwitchItemModel = Helpers::getRawSwitchItemModel(&generalSettings, model ? Helpers::SpecialFunctionsContext : Helpers::GlobalFunctionsContext);
rawSwitchItemModel->setParent(this);
rawSrcInputsItemModel = Helpers::getRawSourceItemModel(&generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES);
rawSrcInputsItemModel->setParent(this);
rawSrcAllItemModel = Helpers::getRawSourceItemModel(&generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRY|POPULATE_TELEMETRYEXT|POPULATE_SCRIPT_OUTPUTS);
rawSrcAllItemModel->setParent(this);
if (!firmware->getCapability(VoicesAsNumbers)) {
tracksSet = getFilesSet(getSoundsPath(generalSettings), QStringList() << "*.wav" << "*.WAV", firmware->getCapability(VoicesMaxLength));
for (int i=0; i<num_fsw; i++) {
@@ -123,8 +130,9 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
// The switch
fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setModel(rawSwitchItemModel);
fswtchSwtch[i]->setCurrentIndex(fswtchSwtch[i]->findData(functions[i].swtch.toValue()));
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()));
@@ -133,8 +141,14 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
// The function
fswtchFunc[i] = new QComboBox(this);
if (!i) {
populateFuncCB(fswtchFunc[i], functions[i].func);
}
else {
fswtchFunc[i]->setModel(fswtchFunc[0]->model());
fswtchFunc[i]->setCurrentIndex(fswtchFunc[i]->findData(functions[i].func));
}
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");
@@ -216,6 +230,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
repeatLayout->addWidget(fswtchEnable[i], i+1);
connect(fswtchEnable[i], SIGNAL(stateChanged(int)), this, SLOT(customFunctionEdited()));
}
s1.report("add items");
disableMouseScrolling();
@@ -367,7 +382,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
cfn.adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex();
}
if (cfn.swtch.toValue()){
if (cfn.swtch.toValue()) {
if (func>=FuncOverrideCH1 && func<=FuncOverrideCH32) {
if (model) {
@@ -432,7 +447,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
fswtchParamTime[i]->setMinimumTime(QTime(0, 0, 0));
fswtchParamTime[i]->setMaximumTime(firmware->getMaxTimerStart());
fswtchParamTime[i]->setTime(QTimeS(cfn.param));
widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM + CUSTOM_FUNCTION_ENABLE;
widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM | CUSTOM_FUNCTION_ENABLE;
}
else if (func>=FuncSetFailsafeInternalModule && func<=FuncBindExternalModule) {
widgetsMask |= CUSTOM_FUNCTION_ENABLE;
@@ -491,9 +506,9 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
else {
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
}
populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
}
@@ -502,9 +517,9 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
else if (func==FuncBackgroundMusic) {
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength));
}
populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
Helpers::populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
}
@@ -525,9 +540,9 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
else if (func==FuncPlayScript) {
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8);
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8);
}
populateFileComboBox(fswtchParamArmT[i], scriptsSet, cfn.paramarm);
Helpers::populateFileComboBox(fswtchParamArmT[i], scriptsSet, cfn.paramarm);
}
else if (func==FuncBacklight && IS_TARANIS_PLUS(getCurrentBoard())) {
if (modified)
@@ -584,7 +599,8 @@ void CustomFunctionsPanel::fswPaste()
CustomFunctionData *fsw = &functions[selectedFunction];
memcpy(fsw, fswData.constData(), sizeof(CustomFunctionData));
lock = true;
populateSwitchCB(fswtchSwtch[selectedFunction], functions[selectedFunction].swtch, generalSettings, model ? SpecialFunctionsContext : GlobalFunctionsContext);
fswtchSwtch[selectedFunction]->setModel(rawSwitchItemModel);
fswtchSwtch[selectedFunction]->setCurrentIndex(fswtchSwtch[selectedFunction]->findData(functions[selectedFunction].swtch.toValue()));
populateFuncCB(fswtchFunc[selectedFunction], functions[selectedFunction].func);
populateGVmodeCB(fswtchGVmode[selectedFunction], functions[selectedFunction].adjustMode);
populateFuncParamCB(fswtchParamT[selectedFunction], functions[selectedFunction].func, functions[selectedFunction].param, functions[selectedFunction].adjustMode);
@@ -599,7 +615,8 @@ void CustomFunctionsPanel::fswDelete()
functions[selectedFunction].clear();
// TODO update switch and func
lock = true;
populateSwitchCB(fswtchSwtch[selectedFunction], functions[selectedFunction].swtch, generalSettings, model ? SpecialFunctionsContext : GlobalFunctionsContext);
fswtchSwtch[selectedFunction]->setModel(rawSwitchItemModel);
fswtchSwtch[selectedFunction]->setCurrentIndex(fswtchSwtch[selectedFunction]->findData(functions[selectedFunction].swtch.toValue()));
populateFuncCB(fswtchFunc[selectedFunction], functions[selectedFunction].func);
refreshCustomFunction(selectedFunction);
lock = false;
@@ -699,18 +716,22 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsi
CustomFunctionData::populateResetParams(model, b, value);
}
else if (function==FuncVolume) {
populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES);
b->setModel(rawSrcInputsItemModel);
b->setCurrentIndex(b->findData(value));
}
else if (function==FuncPlayValue) {
populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRY|POPULATE_TELEMETRYEXT|POPULATE_SCRIPT_OUTPUTS);
b->setModel(rawSrcAllItemModel);
b->setCurrentIndex(b->findData(value));
}
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
switch (adjustmode) {
case 1:
populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_NONE|POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES);
b->setModel(rawSrcInputsItemModel);
b->setCurrentIndex(b->findData(value));
break;
case 2:
populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_GVARS);
b->setModel(Helpers::getRawSourceItemModel(&generalSettings, model, POPULATE_GVARS));
b->setCurrentIndex(b->findData(value));
break;
}
}
@@ -74,6 +74,9 @@ class CustomFunctionsPanel : public GenericPanel
void populateFuncCB(QComboBox *b, unsigned int value);
void populateGVmodeCB(QComboBox *b, unsigned int value);
void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode=0);
QStandardItemModel * rawSwitchItemModel;
QStandardItemModel * rawSrcInputsItemModel;
QStandardItemModel * rawSrcAllItemModel;
QSet<QString> tracksSet;
QSet<QString> scriptsSet;
+4 -3
View File
@@ -60,7 +60,8 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, model,
firmware->getCapability(HasInputDiff) ? 0 : (HIDE_DIFF | HIDE_NEGATIVE_CURVES));
populateSwitchCB(ui->switchesCB, ed->swtch, generalSettings, MixesContext);
ui->switchesCB->setModel(Helpers::getRawSwitchItemModel(&generalSettings, Helpers::MixesContext));
ui->switchesCB->setCurrentIndex(ui->switchesCB->findData(ed->swtch.toValue()));
ui->sideCB->setCurrentIndex(ed->mode-1);
@@ -90,8 +91,8 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
if (firmware->getCapability(VirtualInputs)) {
ui->inputName->setMaxLength(firmware->getCapability(InputsLength));
populateSourceCB(ui->sourceCB, ed->srcRaw, generalSettings, &model, POPULATE_NONE | POPULATE_SOURCES |
POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
ui->sourceCB->setModel(Helpers::getRawSourceItemModel(&generalSettings, &model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY));
ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(ed->srcRaw.toValue()));
ui->sourceCB->removeItem(0);
ui->inputName->setValidator(new QRegExpValidator(rx, this));
ui->inputName->setText(inputName);
+9 -8
View File
@@ -50,7 +50,8 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
// Phase switch
if (phaseIdx > 0) {
populateSwitchCB(ui->swtch, phase.swtch, generalSettings, MixesContext);
ui->swtch->setModel(Helpers::getRawSwitchItemModel(&generalSettings, Helpers::MixesContext));
ui->swtch->setCurrentIndex(ui->swtch->findData(phase.swtch.toValue()));
connect(ui->swtch, SIGNAL(currentIndexChanged(int)), this, SLOT(phaseSwitch_currentIndexChanged(int)));
}
else {
@@ -74,7 +75,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
ui->fadeIn->setDisabled(true);
ui->fadeOut->setDisabled(true);
}
// The trims
QString labels[CPN_MAX_STICKS];
for(int i=0; i < CPN_MAX_STICKS; i++) {
@@ -129,7 +130,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
// RE link to another RE
reUse[i] = new QComboBox(ui->reGB);
reUse[i]->setProperty("index", i);
populateGvarUseCB(reUse[i], phaseIdx);
Helpers::populateGvarUseCB(reUse[i], phaseIdx);
if (phase.rotaryEncoders[i] > 1024) {
reUse[i]->setCurrentIndex(phase.rotaryEncoders[i] - 1024);
}
@@ -171,7 +172,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
// GVar link to another GVar
gvUse[i] = new QComboBox(ui->gvGB);
gvUse[i]->setProperty("index", i);
populateGvarUseCB(gvUse[i], phaseIdx);
Helpers::populateGvarUseCB(gvUse[i], phaseIdx);
if (phase.gvars[i] > 1024) {
gvUse[i]->setCurrentIndex(phase.gvars[i] - 1024);
}
@@ -185,7 +186,7 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
gvValues[i]->setMinimum(-1024);
gvValues[i]->setMaximum(1024);
gvLayout->addWidget(gvValues[i], i, col++, 1, 1);
// Popups
if (IS_TARANIS(board) && phaseIdx == 0) {
gvPopups[i] = new QCheckBox(ui->gvGB);
@@ -219,9 +220,9 @@ void FlightModePanel::update()
ui->fadeOut->setValue(float(phase.fadeOut)/scale);
for (int i=0; i<4; i++) {
int trimsMax = firmware->getCapability(ExtendedTrims);
int trimsMax = firmware->getCapability(ExtendedTrimsRange);
if (trimsMax == 0 || !model->extendedTrims) {
trimsMax = 125;
trimsMax = firmware->getCapability(TrimsRange);
}
trimsSlider[i]->setRange(-trimsMax, +trimsMax);
trimsValue[i]->setRange(-trimsMax, +trimsMax);
@@ -244,7 +245,7 @@ void FlightModePanel::update()
}
}
for (int i=0; i<reCount; i++) {
for (int i=0; i<reCount; i++) {
reValues[i]->setDisabled(false);
int idx = phase.rotaryEncoders[i];
FlightModeData *phasere = &phase;
+9 -3
View File
@@ -28,6 +28,9 @@ HeliPanel::HeliPanel(QWidget *parent, ModelData & model, GeneralSettings & gener
{
ui->setupUi(this);
rawSourceItemModel = Helpers::getRawSourceItemModel(&generalSettings, &model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
rawSourceItemModel->setParent(this);
connect(ui->swashType, SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(ui->swashRingVal, SIGNAL(editingFinished()), this, SLOT(edited()));
connect(ui->swashCollectiveSource, SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
@@ -68,11 +71,14 @@ void HeliPanel::update()
lock = true;
ui->swashType->setCurrentIndex(model->swashRingData.type);
populateSourceCB(ui->swashCollectiveSource, model->swashRingData.collectiveSource, generalSettings, model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
ui->swashCollectiveSource->setModel(rawSourceItemModel);
ui->swashCollectiveSource->setCurrentIndex(ui->swashCollectiveSource->findData(model->swashRingData.collectiveSource.toValue()));
ui->swashRingVal->setValue(model->swashRingData.value);
if (firmware->getCapability(VirtualInputs)) {
populateSourceCB(ui->swashElevatorSource, model->swashRingData.elevatorSource, generalSettings, model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
populateSourceCB(ui->swashAileronSource, model->swashRingData.aileronSource, generalSettings, model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
ui->swashElevatorSource->setModel(rawSourceItemModel);
ui->swashElevatorSource->setCurrentIndex(ui->swashElevatorSource->findData(model->swashRingData.elevatorSource.toValue()));
ui->swashAileronSource->setModel(rawSourceItemModel);
ui->swashAileronSource->setCurrentIndex(ui->swashAileronSource->findData(model->swashRingData.aileronSource.toValue()));
ui->swashElevatorWeight->setValue(model->swashRingData.elevatorWeight);
ui->swashAileronWeight->setValue(model->swashRingData.aileronWeight);
ui->swashCollectiveWeight->setValue(model->swashRingData.collectiveWeight);
+1
View File
@@ -41,6 +41,7 @@ class HeliPanel : public ModelPanel
private:
Ui::Heli *ui;
QStandardItemModel * rawSourceItemModel;
};
#endif // _HELI_H_
+22 -10
View File
@@ -28,6 +28,11 @@ LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model,
Stopwatch s1("LogicalSwitchesPanel");
int channelsMax = model.getChannelsMax(true);
rawSwitchItemModel = Helpers::getRawSwitchItemModel(&generalSettings, Helpers::LogicalSwitchesContext);
rawSwitchItemModel->setParent(this);
int srcFlags = POPULATE_NONE | POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0);
rawSourceItemModel = Helpers::getRawSourceItemModel(&generalSettings, &model, srcFlags);
rawSourceItemModel->setParent(this);
QStringList headerLabels;
headerLabels << "#" << tr("Function") << tr("V1") << tr("V2") << tr("AND Switch");
@@ -309,7 +314,6 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
}
else {
mask = DELAY_ENABLED | DURATION_ENABLED;
switch (model->logicalSw[i].getFunctionFamily())
{
case LS_FAMILY_VOFS:
@@ -317,7 +321,8 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
mask |= SOURCE1_VISIBLE;
RawSource source = RawSource(model->logicalSw[i].val1);
RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags());
populateSourceCB(cswitchSource1[i], source, generalSettings, model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
cswitchSource1[i]->setModel(rawSourceItemModel);
cswitchSource1[i]->setCurrentIndex(cswitchSource1[i]->findData(source.toValue()));
cswitchOffset[i]->setDecimals(range.decimals);
cswitchOffset[i]->setSingleStep(range.step);
if (source.isTimeBased()) {
@@ -341,19 +346,22 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
cswitchOffset[i]->setMaximum(range.max);
cswitchOffset[i]->setValue(range.step*(model->logicalSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
}
break;
}
case LS_FAMILY_STICKY:
// no break
case LS_FAMILY_STICKY: // no break
case LS_FAMILY_VBOOL:
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
populateSwitchCB(cswitchSource1[i], RawSwitch(model->logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
populateSwitchCB(cswitchSource2[i], RawSwitch(model->logicalSw[i].val2), generalSettings, LogicalSwitchesContext);
cswitchSource1[i]->setModel(rawSwitchItemModel);
cswitchSource1[i]->setCurrentIndex(cswitchSource1[i]->findData(model->logicalSw[i].val1));
cswitchSource2[i]->setModel(rawSwitchItemModel);
cswitchSource2[i]->setCurrentIndex(cswitchSource2[i]->findData(model->logicalSw[i].val2));
break;
case LS_FAMILY_EDGE:
mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE | VALUE3_VISIBLE;
mask &= ~DELAY_ENABLED;
populateSwitchCB(cswitchSource1[i], RawSwitch(model->logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
cswitchSource1[i]->setModel(rawSwitchItemModel);
cswitchSource1[i]->setCurrentIndex(cswitchSource1[i]->findData(model->logicalSw[i].val1));
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.0);
updateTimerParam(cswitchOffset2[i], model->logicalSw[i].val2+model->logicalSw[i].val3, ValToTim(TimToVal(cswitchOffset[i]->value())-1));
cswitchOffset2[i]->setSpecialValueText(tr("(instant)"));
@@ -366,13 +374,16 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
break;
case LS_FAMILY_VCOMP:
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
populateSourceCB(cswitchSource1[i], RawSource(model->logicalSw[i].val1), generalSettings, model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource2[i], RawSource(model->logicalSw[i].val2), generalSettings, model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
cswitchSource1[i]->setModel(rawSourceItemModel);
cswitchSource1[i]->setCurrentIndex(cswitchSource1[i]->findData(model->logicalSw[i].val1));
cswitchSource2[i]->setModel(rawSourceItemModel);
cswitchSource2[i]->setCurrentIndex(cswitchSource2[i]->findData(model->logicalSw[i].val2));
break;
case LS_FAMILY_TIMER:
mask |= VALUE1_VISIBLE | VALUE2_VISIBLE;
updateTimerParam(cswitchValue[i], model->logicalSw[i].val1, 0.1);
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.1);
break;
}
}
@@ -445,7 +456,8 @@ void LogicalSwitchesPanel::populateAndSwitchCB(QComboBox *b, const RawSwitch & v
}
if (IS_ARM(firmware->getBoard())) {
populateSwitchCB(b, value, generalSettings, LogicalSwitchesContext);
b->setModel(rawSwitchItemModel);
b->setCurrentIndex(b->findData(value.toValue()));
}
else {
RawSwitch item;
@@ -58,6 +58,8 @@ class LogicalSwitchesPanel : public ModelPanel
QDoubleSpinBox * cswitchDelay[CPN_MAX_CSW];
QComboBox * cswitchSource1[CPN_MAX_CSW];
QComboBox * cswitchSource2[CPN_MAX_CSW];
QStandardItemModel * rawSwitchItemModel;
QStandardItemModel * rawSourceItemModel;
void setSwitchWidgetVisibility(int i);
int selectedSwitch;
+4 -3
View File
@@ -42,8 +42,8 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
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->setModel(Helpers::getRawSourceItemModel(&generalSettings, &model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS));
ui->sourceCB->setCurrentIndex(ui->sourceCB->findData(md->srcRaw.toValue()));
ui->sourceCB->removeItem(0);
int limit = firmware->getCapability(OffsetWeight);
@@ -103,7 +103,8 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
}
}
populateSwitchCB(ui->switchesCB, md->swtch, generalSettings, MixesContext);
ui->switchesCB->setModel(Helpers::getRawSwitchItemModel(&generalSettings, Helpers::MixesContext));
ui->switchesCB->setCurrentIndex(ui->switchesCB->findData(md->swtch.toValue()));
ui->warningCB->setCurrentIndex(md->mixWarn);
ui->mltpxCB->setCurrentIndex(md->mltpx);
int scale=firmware->getCapability(SlowScale);
+20 -20
View File
@@ -49,7 +49,9 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
}
// Mode
populateSwitchCB(ui->mode, timer.mode, generalSettings, TimersContext);
ui->mode->setModel(Helpers::getRawSwitchItemModel(&generalSettings, Helpers::TimersContext));
ui->mode->setCurrentIndex(ui->mode->findData(timer.mode.toValue()));
//Helpers::populateSwitchCB(ui->mode, timer.mode, generalSettings, Helpers::TimersContext);
if (!firmware->getCapability(PermTimers)) {
ui->persistent->hide();
@@ -887,19 +889,20 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
// Beep Center checkboxes
prevFocus = ui->trimsDisplay;
int analogs = CPN_MAX_STICKS + getBoardCapability(board, Board::Pots) + getBoardCapability(board, Board::Sliders);
for (int i=0; i<analogs+firmware->getCapability(RotaryEncoders); i++) {
int genAryIdx = 0;
for (int i=0; i < analogs + firmware->getCapability(RotaryEncoders); i++) {
RawSource src((i < analogs) ? SOURCE_TYPE_STICK : SOURCE_TYPE_ROTARY_ENCODER, (i < analogs) ? i : analogs - i);
QCheckBox * checkbox = new QCheckBox(this);
checkbox->setProperty("index", i);
checkbox->setText(i<analogs ? firmware->getAnalogInputName(i) : RotaryEncoderString(i-analogs));
checkbox->setText(src.toString(&model, &generalSettings));
ui->centerBeepLayout->addWidget(checkbox, 0, i+1);
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
centerBeepCheckboxes << checkbox;
if (IS_HORUS_OR_TARANIS(board)) {
RawSource src(SOURCE_TYPE_STICK, i);
if (src.isPot() && !generalSettings.isPotAvailable(i-CPN_MAX_STICKS)) {
if (src.isPot(&genAryIdx) && !generalSettings.isPotAvailable(genAryIdx)) {
checkbox->hide();
}
else if (src.isSlider() && !generalSettings.isSliderAvailable(i-CPN_MAX_STICKS-getBoardCapability(board, Board::Pots))) {
else if (src.isSlider(&genAryIdx) && !generalSettings.isSliderAvailable(genAryIdx)) {
checkbox->hide();
}
}
@@ -909,13 +912,12 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
// Startup switches warnings
for (int i=0; i<getBoardCapability(board, Board::Switches); i++) {
Board::SwitchInfo switchInfo = getSwitchInfo(board, i);
if (IS_HORUS_OR_TARANIS(board)) {
switchInfo.config = Board::SwitchType(generalSettings.switchConfig[i]);
}
Board::SwitchInfo switchInfo = Boards::getSwitchInfo(board, i);
switchInfo.config = Board::SwitchType(generalSettings.switchConfig[i]);
if (switchInfo.config == Board::SWITCH_NOT_AVAILABLE || switchInfo.config == Board::SWITCH_TOGGLE) {
continue;
}
RawSource src(RawSourceType::SOURCE_TYPE_SWITCH, i);
QLabel * label = new QLabel(this);
QSlider * slider = new QSlider(this);
QCheckBox * cb = new QCheckBox(this);
@@ -923,13 +925,14 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
slider->setOrientation(Qt::Vertical);
slider->setMinimum(0);
slider->setInvertedAppearance(true);
slider->setInvertedControls(true);
slider->setTickPosition(QSlider::TicksBothSides);
slider->setMinimumSize(QSize(30, 50));
slider->setMaximumSize(QSize(50, 50));
slider->setSingleStep(1);
slider->setPageStep(1);
slider->setTickInterval(1);
label->setText(switchInfo.name);
label->setText(src.toString(&model, &generalSettings));
slider->setMaximum(switchInfo.config == Board::SWITCH_3POS ? 2 : 1);
cb->setProperty("index", i);
ui->switchesStartupLayout->addWidget(label, 0, i+1);
@@ -951,21 +954,18 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
prevFocus = ui->potWarningMode;
if (IS_HORUS_OR_TARANIS(board)) {
for (int i=0; i<getBoardCapability(board, Board::Pots)+getBoardCapability(board, Board::Sliders); i++) {
RawSource src(SOURCE_TYPE_STICK, CPN_MAX_STICKS + i);
QCheckBox * cb = new QCheckBox(this);
cb->setProperty("index", i);
cb->setText(firmware->getAnalogInputName(i+4));
cb->setText(src.toString(&model, &generalSettings));
ui->potWarningLayout->addWidget(cb, 0, i+1);
connect(cb, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool)));
potWarningCheckboxes << cb;
if (RawSource(SOURCE_TYPE_STICK, CPN_MAX_STICKS+i).isPot()) {
if (!generalSettings.isPotAvailable(i)) {
cb->hide();
}
if (src.isPot(&genAryIdx) && !generalSettings.isPotAvailable(genAryIdx)) {
cb->hide();
}
else {
if (!generalSettings.isSliderAvailable(i-getBoardCapability(board, Board::Pots))) {
cb->hide();
}
else if (src.isSlider(&genAryIdx) && !generalSettings.isSliderAvailable(genAryIdx)) {
cb->hide();
}
QWidget::setTabOrder(prevFocus, cb);
prevFocus = cb;
+8 -5
View File
@@ -352,7 +352,7 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model,
if (IS_TARANIS(firmware->getBoard())) {
QSet<QString> scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/TELEMETRY", QStringList() << "*.lua", 8);
populateFileComboBox(ui->scriptName, scriptsSet, screen.body.script.filename);
Helpers::populateFileComboBox(ui->scriptName, scriptsSet, screen.body.script.filename);
connect(ui->scriptName, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptNameEdited()));
connect(ui->scriptName, SIGNAL(editTextChanged ( const QString)), this, SLOT(scriptNameEdited()));
}
@@ -362,12 +362,15 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model,
void TelemetryCustomScreen::populateTelemetrySourceCB(QComboBox * b, RawSource & source, bool last)
{
int flags = POPULATE_NONE | POPULATE_TELEMETRY;
if (IS_ARM(firmware->getBoard())) {
populateSourceCB(b, source, generalSettings, model, POPULATE_NONE | POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
flags |= POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0);
}
else {
populateSourceCB(b, source, generalSettings, model, POPULATE_NONE | POPULATE_TELEMETRY | (last ? POPULATE_TELEMETRYEXT : 0));
else if (last) {
flags |= POPULATE_TELEMETRYEXT;
}
b->setModel(Helpers::getRawSourceItemModel(&generalSettings, model, flags));
b->setCurrentIndex(b->findData(source.toValue()));
}
TelemetryCustomScreen::~TelemetryCustomScreen()
@@ -454,7 +457,7 @@ void TelemetryCustomScreen::scriptNameEdited()
{
if (!lock) {
lock = true;
getFileComboBoxValue(ui->scriptName, screen.body.script.filename, 8);
Helpers::getFileComboBoxValue(ui->scriptName, screen.body.script.filename, 8);
emit modified();
lock = false;
}