Allow configuring notice on localization option page individually

Whether an application can retranslate the UI dynamically likely differs
from whether the other appearance related settings can be applied
dynamically so this needs to be configurable individually.

Additionally, the environment settings can never be applied dynamically so
the notice on that page should always be shown.
This commit is contained in:
Martchus 2023-07-03 00:21:29 +02:00
parent b340ff819c
commit c7426403e5
2 changed files with 21 additions and 6 deletions

View File

@ -64,6 +64,7 @@ struct QtSettingsData {
bool customLocale;
bool isPaletteDark;
bool showNotices;
bool retranslatable;
};
inline QtSettingsData::QtSettingsData()
@ -78,6 +79,7 @@ inline QtSettingsData::QtSettingsData()
, customLocale(false)
, isPaletteDark(false)
, showNotices(true)
, retranslatable(false)
{
}
@ -109,12 +111,28 @@ QtSettings::~QtSettings()
* - Only call this function if the application actually re-applies these settings when the
* settings dialog is applied and when it is generally able to handle widget style and
* palette changes well.
* - The localization option page's notice is handled via setRetranslatable() and the notice
* for the environment page is still always shown (as those settings can never be applied
* at runtime). So this affects only the appearance page at this point.
*/
void QtSettings::disableNotices()
{
m_d->showNotices = false;
}
/*!
* \brief Sets whether the application supports changing the locale settings at runtime.
* \remarks
* Set this to true if the application will retranslate its UI after the locale has changed.
* This requires the application to re-install translators and to re-invoke all ts() and
* translate() function calls. If set to true, the notice that the locale setting takes only
* effect after restarting is not shown anymore.
*/
void QtSettings::setRetranslatable(bool retranslatable)
{
m_d->retranslatable = retranslatable;
}
/*!
* \brief Returns whether a custom font is set.
*/
@ -501,7 +519,7 @@ QWidget *QtLanguageOptionPage::setupWidget()
{
// call base implementation first, so ui() is available
auto *widget = QtLanguageOptionPageBase::setupWidget();
if (!m_settings.showNotices) {
if (m_settings.retranslatable) {
ui()->label->hide();
}
@ -551,11 +569,7 @@ void QtEnvOptionPage::reset()
QWidget *QtEnvOptionPage::setupWidget()
{
// call base implementation first, so ui() is available
auto *widget = QtEnvOptionPageBase::setupWidget();
if (!m_settings.showNotices) {
ui()->label->hide();
}
return widget;
return QtEnvOptionPageBase::setupWidget();
}
/*!

View File

@ -47,6 +47,7 @@ public:
~QtSettings();
void disableNotices();
void setRetranslatable(bool retranslatable);
void restore(QSettings &settings);
void save(QSettings &settings) const;
void apply();