Gui: fixes #6663: [Bug] Decimal separator not chosen by locale system settings anymore

This commit is contained in:
wmayer
2022-03-28 15:38:51 +02:00
parent 8cf6bf6909
commit b50ec016bd
6 changed files with 92 additions and 30 deletions

View File

@@ -258,16 +258,28 @@ bool Translator::setLocale(const std::string& language) const
if (!bcp47.empty())
loc = QLocale(QString::fromStdString(bcp47));
QLocale::setDefault(loc);
// Need to manually send the event so locale change is fully took into account on widgets
auto ev = QEvent(QEvent::LocaleChange);
qApp->sendEvent(qApp, &ev);
updateLocaleChange();
#ifdef FC_DEBUG
Base::Console().Log("Locale changed to %s => %s\n", qPrintable(loc.bcp47Name()), qPrintable(loc.name()));
#endif
return (loc.language() != loc.C);
}
void Translator::setSystemLocale() const
{
QLocale::setDefault(QLocale::system());
updateLocaleChange();
}
void Translator::updateLocaleChange() const
{
// Need to manually send the event so locale change is fully took into account on widgets
auto ev = QEvent(QEvent::LocaleChange);
qApp->sendEvent(qApp, &ev);
}
QStringList Translator::directories() const
{
QStringList list;