Allow tracking whether the locale has changed via the `QtSettings` class
This allows an application to reload translations if the default locale has changed to apply locale changes dynamically.
This commit is contained in:
parent
f30d020cda
commit
f69ffec06c
|
@ -50,6 +50,7 @@ struct QtSettingsData {
|
||||||
QString iconTheme;
|
QString iconTheme;
|
||||||
QString initialIconTheme;
|
QString initialIconTheme;
|
||||||
QLocale defaultLocale;
|
QLocale defaultLocale;
|
||||||
|
QLocale previousLocale;
|
||||||
QString localeName;
|
QString localeName;
|
||||||
QString previousPluginDirectory;
|
QString previousPluginDirectory;
|
||||||
QString additionalPluginDirectory;
|
QString additionalPluginDirectory;
|
||||||
|
@ -319,6 +320,7 @@ void QtSettings::apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply locale
|
// apply locale
|
||||||
|
m_d->previousLocale = QLocale();
|
||||||
QLocale::setDefault(m_d->customLocale ? QLocale(m_d->localeName) : m_d->defaultLocale);
|
QLocale::setDefault(m_d->customLocale ? QLocale(m_d->localeName) : m_d->defaultLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,6 +357,14 @@ bool QtSettings::isPaletteDark()
|
||||||
return m_d->isPaletteDark;
|
return m_d->isPaletteDark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns whether the last apply() call has changed the default locale.
|
||||||
|
*/
|
||||||
|
bool QtSettings::hasLocaleChanged() const
|
||||||
|
{
|
||||||
|
return m_d->previousLocale != QLocale();
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns a new OptionCatecory containing all Qt related option pages.
|
* \brief Returns a new OptionCatecory containing all Qt related option pages.
|
||||||
* \remarks
|
* \remarks
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
void reevaluatePaletteAndDefaultIconTheme();
|
void reevaluatePaletteAndDefaultIconTheme();
|
||||||
bool isPaletteDark();
|
bool isPaletteDark();
|
||||||
bool hasCustomFont() const;
|
bool hasCustomFont() const;
|
||||||
|
bool hasLocaleChanged() const;
|
||||||
operator QtSettingsData &() const;
|
operator QtSettingsData &() const;
|
||||||
|
|
||||||
OptionCategory *category();
|
OptionCategory *category();
|
||||||
|
|
Loading…
Reference in New Issue