1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 01:35:21 +03:00

[Companion] Input names formatting (#4888)

* [Companion] Re-format Inputs list to format input name consistently with rest of UI; Add leading zeros to RawSource numbers in names; Show custom channel name in MixerDialog.

* [Companion] Remove colon separator between input number and custom name.

* Fix segfault when no model pointer is passed to RawSource::toString() (problem was only on this branch).
This commit is contained in:
Max Paperno 2017-05-11 01:37:14 -04:00 committed by Bertrand Songis
parent 6e0bec9db4
commit f7b6d95910
5 changed files with 21 additions and 32 deletions

View file

@ -508,9 +508,9 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
int genAryIdx = 0;
switch (type) {
case SOURCE_TYPE_VIRTUAL_INPUT:
result = QObject::tr("[I%1]").arg(index+1);
result = QObject::tr("[I%1]").arg(index+1, 2, 10, QChar('0'));
if (model && model->inputNames[index][0])
result.append(":" + QString(model->inputNames[index]).trimmed());
result.append(/*":" + */QString(model->inputNames[index]).trimmed());
return result;
case SOURCE_TYPE_LUA_OUTPUT:
@ -550,7 +550,7 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
return QObject::tr("CYC%1").arg(index+1);
case SOURCE_TYPE_PPM:
return QObject::tr("TR%1").arg(index+1);
return QObject::tr("TR%1").arg(index+1, 2, 10, QChar('0'));
case SOURCE_TYPE_CH:
result = QObject::tr("CH%1").arg(index+1, 2, 10, QChar('0'));
@ -564,7 +564,7 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
case SOURCE_TYPE_TELEMETRY:
if (IS_ARM(getCurrentBoard())) {
div_t qr = div(index, 3);
result = model ? QString(model->sensorData[qr.quot].label) : QString("[T%1]").arg(qr.quot+1);
result = model ? QString(model->sensorData[qr.quot].label) : QString("[T%1]").arg(qr.quot+1, 2, 10, QChar('0'));
if (qr.rem)
result += (qr.rem == 1 ? "-" : "+");
return result;
@ -574,7 +574,7 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
}
case SOURCE_TYPE_GVAR:
result = QObject::tr("GV%1").arg(index+1);
result = QObject::tr("GV%1").arg(index+1, 2, 10, QChar('0'));
if (getCurrentFirmware()->getCapability(GvarsName) && model && model->gvars_names[index][0])
result.append(":" + QString(model->gvars_names[index]).trimmed());
return result;

View file

@ -41,7 +41,8 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
cb_fp[i] = tmp[i];
}
setWindowTitle(tr("Edit %1").arg(modelPrinter.printInputName(ed->chn)));
RawSourceType srcType = (firmware->getCapability(VirtualInputs) ? SOURCE_TYPE_VIRTUAL_INPUT : SOURCE_TYPE_STICK);
setWindowTitle(tr("Edit %1").arg(RawSource(srcType, ed->chn).toString(&model, &generalSettings)));
QRegExp rx(CHAR_FOR_NAMES_REGEX);
if (IS_HORUS_OR_TARANIS(getCurrentBoard())) {

View file

@ -153,26 +153,26 @@ bool InputsPanel::AddInputLine(int dest)
QString InputsPanel::getInputText(int dest, bool * new_ch)
{
QString str;
if (new_ch) *new_ch = 0;
if (new_ch)
*new_ch = false;
if (dest < 0) {
str = modelPrinter.printInputName(-dest-1);
if (new_ch) *new_ch = 1;
if (new_ch)
*new_ch = true;
}
else {
ExpoData & input = model->expoData[dest];
int nameChars = (firmware->getCapability(VirtualInputs) ? 10 : 4);
if ((dest == 0) || (model->expoData[dest-1].chn != input.chn)) {
if (new_ch) *new_ch = 1;
if (firmware->getCapability(VirtualInputs))
str += QString("%1").arg(modelPrinter.printInputName(input.chn), -10, ' ');
else
str = modelPrinter.printInputName(input.chn);
if (new_ch)
*new_ch = true;
str = QString("%1").arg(modelPrinter.printInputName(input.chn), -nameChars, QChar(' '));
}
else {
if (firmware->getCapability(VirtualInputs))
str = " ";
else
str = " ";
str = QString(nameChars, QChar(' '));
}
str.replace(" ", "&nbsp;");
str += modelPrinter.printInputLine(input);

View file

@ -40,7 +40,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
cb_fp[i] = tmp[i];
}
this->setWindowTitle(tr("DEST -> CH%1").arg(md->destCh));
this->setWindowTitle(tr("DEST -> %1").arg(RawSource(SOURCE_TYPE_CH, md->destCh-1).toString(&model, &generalSettings)));
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()));

View file

@ -328,20 +328,8 @@ QString ModelPrinter::printRotaryEncoder(int flightModeIndex, int reIndex)
QString ModelPrinter::printInputName(int idx)
{
QString result;
if (firmware->getCapability(VirtualInputs)) {
if (strlen(model.inputNames[idx]) > 0) {
result = tr("[I%1]").arg(idx+1);
result += QString(model.inputNames[idx]);
}
else {
result = tr("Input%1").arg(idx+1, 2, 10, QChar('0'));
}
}
else {
result = RawSource(SOURCE_TYPE_STICK, idx).toString(&model, &generalSettings);
}
return result.toHtmlEscaped();
RawSourceType srcType = (firmware->getCapability(VirtualInputs) ? SOURCE_TYPE_VIRTUAL_INPUT : SOURCE_TYPE_STICK);
return RawSource(srcType, idx).toString(&model, &generalSettings).toHtmlEscaped();
}
QString ModelPrinter::printInputLine(int idx)