feat: add a separate setting for selecting 'text language' when ALL_LANGS is set (#6960)

This commit is contained in:
philmoz
2026-01-08 12:34:22 +10:00
committed by GitHub
parent a3ccc87a88
commit 4f90a5e426
60 changed files with 352 additions and 95 deletions
+135 -31
View File
@@ -115,8 +115,9 @@ ui(new Ui::GeneralSetup)
ui->voiceLang_CB->hide();
}
else {
populateVoiceLangCB();
populateVoiceLangCB(ui->voiceLang_CB, generalSettings.ttsLanguage);
}
populateTextLangCB(ui->textLang_CB, generalSettings.uiLanguage, Boards::getCapability(board, Board::HasColorLcd));
if (!firmware->getCapability(MavlinkTelemetry)) {
ui->mavbaud_CB->hide();
@@ -124,7 +125,6 @@ ui(new Ui::GeneralSetup)
}
else {
ui->mavbaud_CB->setCurrentIndex(generalSettings.mavbaud);
// TODO why ??? populateVoiceLangCB(ui->voiceLang_CB, generalSettings.ttsLanguage);
}
if (!firmware->getCapability(HasSoundMixer)) {
@@ -396,38 +396,130 @@ void GeneralSetupPanel::on_timezoneLE_textEdited(const QString &text)
}
}
void GeneralSetupPanel::populateVoiceLangCB()
// Copied from tts.h
enum RadioLanguage {
LANG_CN,
LANG_CZ,
LANG_DA,
LANG_DE,
LANG_EN,
LANG_ES,
LANG_FI,
LANG_FR,
LANG_HE,
LANG_HU,
LANG_IT,
LANG_JP,
LANG_KO,
LANG_NL,
LANG_PL,
LANG_PT,
LANG_RU,
LANG_SE,
LANG_SK,
LANG_TW,
LANG_UA,
LANG_COUNT
};
// Order must match RadioLanguage
// Note: these align with the radio NOT computer locales - TODO harmonise with ISO and one list!!!
static const char* langStrings[][2] = {
{ "Chinese", "cn" },
{ "Czech", "cz" },
{ "Danish", "da" },
{ "German", "de" },
{ "English", "en" },
{ "Spanish", "es" },
{ "Finnish", "fi" },
{ "French", "fr" },
{ "Hebrew", "he" },
{ "Hungarian", "hu" },
{ "Italian", "it" },
{ "Japanese", "jp" },
{ "Korean", "ko" },
{ "Dutch", "nl" },
{ "Polish", "pl" },
{ "Portuguese", "pt" },
{ "Russian", "ru" },
{ "Swedish", "se" },
{ "Slovak", "sk" },
{ "Taiwanese", "tw" },
{ "Ukrainian", "ua" },
};
void GeneralSetupPanel::populateVoiceLangCB(QComboBox* b, const char* currLang)
{
QComboBox * b = ui->voiceLang_CB;
// Note: these align with the radio NOT computer locales - TODO harmonise with ISO and one list!!!
static QString strings[][2] = {
{ tr("Chinese"), "cn" },
{ tr("Czech"), "cz" },
{ tr("Danish"), "da" },
{ tr("Dutch"), "nl" },
{ tr("English"), "en" },
{ tr("Finnish"), "fi" },
{ tr("French"), "fr" },
{ tr("German"), "de" },
{ tr("Hebrew"), "he" },
{ tr("Hungarian"), "hu" },
{ tr("Italian"), "it" },
{ tr("Japanese"), "jp" },
{ tr("Korean"), "ko" },
{ tr("Polish"), "pl" },
{ tr("Portuguese"), "pt" },
{ tr("Russian"), "ru" },
{ tr("Slovak"), "sk" },
{ tr("Spanish"), "es" },
{ tr("Swedish"), "se" },
{ tr("Taiwanese"), "tw" },
{ tr("Ukrainian"), "ua" },
{ NULL, NULL }};
b->clear();
for (int i = 0; i < LANG_COUNT; i++) {
b->addItem(tr(langStrings[i][0]), langStrings[i][1]);
if (strncmp(currLang, langStrings[i][1], 2) == 0) {
b->setCurrentIndex(b->count() - 1);
}
}
}
void GeneralSetupPanel::populateTextLangCB(QComboBox* b, const char* currLang, bool isColor)
{
// Available text languages
// B&W
static RadioLanguage bwLangs[] = {
// LANG_CN, // no fonts
LANG_CZ,
LANG_DA,
LANG_DE,
LANG_EN,
LANG_ES,
LANG_FI,
LANG_FR,
// LANG_HE, // no fonts
// LANG_HU, // no translation file
LANG_IT,
// LANG_JP, // no fonts
// LANG_KO, // no fonts
LANG_NL,
LANG_PL,
LANG_PT,
LANG_RU,
LANG_SE,
// LANG_SK, // no translation file
// LANG_TW, // no fonts
LANG_UA,
LANG_COUNT
};
// Color
static RadioLanguage colorLangs[] = {
LANG_CN,
LANG_CZ,
LANG_DA,
LANG_DE,
LANG_EN,
LANG_ES,
LANG_FI,
LANG_FR,
LANG_HE,
// LANG_HU, // no translation file
LANG_IT,
LANG_JP,
LANG_KO,
LANG_NL,
LANG_PL,
LANG_PT,
LANG_RU,
LANG_SE,
// LANG_SK, // no translation file
LANG_TW,
LANG_UA,
LANG_COUNT
};
RadioLanguage* langs = isColor ? colorLangs : bwLangs;
b->clear();
for (int i = 0; !strings[i][0].isNull(); i++) {
b->addItem(strings[i][0],strings[i][1]);
if (generalSettings.ttsLanguage == strings[i][1]) {
for (int i = 0; langs[i] < LANG_COUNT; i++) {
int n = langs[i];
b->addItem(tr(langStrings[n][0]),langStrings[n][1]);
if (strncmp(currLang, langStrings[n][1], 2) == 0) {
b->setCurrentIndex(b->count() - 1);
}
}
@@ -485,6 +577,18 @@ void GeneralSetupPanel::on_voiceLang_CB_currentIndexChanged(int index)
}
}
void GeneralSetupPanel::on_textLang_CB_currentIndexChanged(int index)
{
if (!lock) {
QString code = ui->textLang_CB->itemData(index).toString();
for (int i = 0; i < 2; i++) {
generalSettings.uiLanguage[i] = code.at(i).toLatin1();
}
generalSettings.uiLanguage[2] = '\0';
emit modified();
}
}
void GeneralSetupPanel::updateVarioPitchRange()
{
ui->varioPMax_SB->setMaximum(700 + (generalSettings.varioPitch * 10) + 1000 + 800);
+3 -1
View File
@@ -68,6 +68,7 @@ class GeneralSetupPanel : public GeneralPanel
void on_backlightColor_SL_valueChanged();
void on_mavbaud_CB_currentIndexChanged(int index);
void on_voiceLang_CB_currentIndexChanged(int index);
void on_textLang_CB_currentIndexChanged(int index);
void stickReverseEdited();
void on_switchesDelay_valueChanged(int);
void on_blAlarm_ChkB_stateChanged();
@@ -113,6 +114,7 @@ class GeneralSetupPanel : public GeneralPanel
void showLabelSelectOptions();
void setValues();
void populateVoiceLangCB();
void populateVoiceLangCB(QComboBox* b, const char* currLang);
void populateTextLangCB(QComboBox* b, const char* currLang, bool isColor);
void updateVarioPitchRange();
};
+25 -15
View File
@@ -576,7 +576,7 @@
</property>
</widget>
</item>
<item row="29" column="1">
<item row="30" column="1">
<widget class="QComboBox" name="labelMultiMode_CB">
<item>
<property name="text">
@@ -590,7 +590,7 @@
</item>
</widget>
</item>
<item row="26" column="1">
<item row="27" column="1">
<widget class="QCheckBox" name="modelQuickSelect_CB">
<property name="toolTip">
<string>Enable this to quickly change model on the model select page (a long press can then be used to open the model edit menu).</string>
@@ -621,14 +621,14 @@
</property>
</widget>
</item>
<item row="24" column="0">
<item row="25" column="0">
<widget class="QLabel" name="label_registrationId">
<property name="text">
<string>Owner Registration ID</string>
</property>
</widget>
</item>
<item row="28" column="0">
<item row="29" column="0">
<widget class="QLabel" name="label_labelSingleSelect">
<property name="text">
<string>Label selection mode</string>
@@ -662,7 +662,7 @@
</property>
</widget>
</item>
<item row="29" column="0">
<item row="30" column="0">
<widget class="QLabel" name="label_labelMultiMode">
<property name="text">
<string>Label matching</string>
@@ -692,7 +692,7 @@
</property>
</widget>
</item>
<item row="28" column="1">
<item row="29" column="1">
<widget class="QComboBox" name="labelSingleSelect_CB">
<item>
<property name="text">
@@ -706,7 +706,7 @@
</item>
</widget>
</item>
<item row="31" column="0">
<item row="32" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
@@ -822,7 +822,7 @@
</property>
</widget>
</item>
<item row="27" column="1">
<item row="28" column="1">
<widget class="QComboBox" name="modelSelectLayout_CB">
<item>
<property name="text">
@@ -874,7 +874,7 @@
</item>
</layout>
</item>
<item row="25" column="1">
<item row="26" column="1">
<widget class="QComboBox" name="rotEncMode_CB"/>
</item>
<item row="0" column="1">
@@ -908,7 +908,7 @@
</property>
</widget>
</item>
<item row="24" column="1">
<item row="25" column="1">
<widget class="QLineEdit" name="registrationId">
<property name="maxLength">
<number>8</number>
@@ -929,6 +929,13 @@
</property>
</widget>
</item>
<item row="24" column="0">
<widget class="QLabel" name="TextLang_label">
<property name="text">
<string>Text Language</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_speakerPitch">
<property name="text">
@@ -999,7 +1006,10 @@
<item row="23" column="1">
<widget class="QComboBox" name="voiceLang_CB"/>
</item>
<item row="30" column="1">
<item row="24" column="1">
<widget class="QComboBox" name="textLang_CB"/>
</item>
<item row="31" column="1">
<widget class="QComboBox" name="favMultiMode_CB">
<item>
<property name="text">
@@ -1102,7 +1112,7 @@
</item>
</widget>
</item>
<item row="27" column="0">
<item row="28" column="0">
<widget class="QLabel" name="label_modelSelectLayout">
<property name="text">
<string>Manage Models layout</string>
@@ -1125,7 +1135,7 @@
</property>
</widget>
</item>
<item row="25" column="0">
<item row="26" column="0">
<widget class="QLabel" name="rotEncMode_label">
<property name="text">
<string>Rotary Encoder Mode</string>
@@ -1148,7 +1158,7 @@
</property>
</widget>
</item>
<item row="26" column="0">
<item row="27" column="0">
<widget class="QLabel" name="label_modelQuickSelect">
<property name="text">
<string>Model quick select</string>
@@ -1203,7 +1213,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="30" column="0">
<item row="31" column="0">
<widget class="QLabel" name="label_favMultiMode">
<property name="text">
<string>Favorites matching</string>