Skip to content

Commit

Permalink
fix language default prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
DSCaskey committed Jun 30, 2023
1 parent ba18d9f commit b00831d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,15 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
SetLabelComboBox(VApplication::LabelLanguages());

index = ui->labelCombo->findData(qApp->Seamly2DSettings()->GetLabelLanguage());
if (index == -1)
{
index = ui->labelCombo->findData("en");
}
if (index != -1)
{
ui->labelCombo->setCurrentIndex(index);
}

connect(ui->labelCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this]()
{
m_labelLangChanged = true;
Expand Down
19 changes: 14 additions & 5 deletions src/libs/vmisc/def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int h

QPixmap pixmap;

if (not QPixmapCache::find(pixmapPath, &pixmap))
if (!QPixmapCache::find(pixmapPath, &pixmap))
{
pixmap = QPixmap(pixmapPath);
QPixmapCache::insert(pixmapPath, pixmap);
Expand Down Expand Up @@ -746,19 +746,24 @@ void InitLanguages(QComboBox *combobox)
locale.truncate(locale.lastIndexOf('.')); // "seamly2d_de_De"
locale.remove(0, locale.indexOf('_') + 1); // "de_De"

if (not englishUS)
if (!englishUS)
{
englishUS = (en_US == locale);
englishUS = (locale == en_US);
}

QLocale loc = QLocale(locale);
QString lang = loc.nativeLanguageName();
QIcon ico(QString("%1/%2.png").arg(":/flags").arg(QLocale::countryToString(loc.country())));
QString country = QLocale::countryToString(loc.country());
if (country == QLatin1String("Czechia"))
{
country = QLatin1String("CzechRepublic");
}
QIcon ico(QString("://flags/%1.png").arg(country));

combobox->addItem(ico, lang, locale);
}

if (combobox->count() == 0 || not englishUS)
if (combobox->count() == 0 || !englishUS)
{
// English language is internal and doens't have own *.qm file.
QIcon ico(QString(":/flags/United States.png"));
Expand All @@ -772,4 +777,8 @@ void InitLanguages(QComboBox *combobox)
{
combobox->setCurrentIndex(index);
}
else
{
combobox->setCurrentIndex(combobox->findData(en_US));
}
}

0 comments on commit b00831d

Please sign in to comment.