Clarify what QSystemLocale::fallbackLocale() is used for

Change-Id: I8f073f996505ccb42020b32fd76520ecef54e628
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Tor Arne Vestbø 2021-02-05 16:59:04 +01:00
parent 13ae47d980
commit f218d89522
9 changed files with 24 additions and 20 deletions

View File

@ -707,7 +707,7 @@ static void updateSystemPrivate()
sys_locale->query(QSystemLocale::LocaleChanged);
// Populate global with fallback as basis:
globalLocaleData = locale_data[sys_locale->fallbackUiLocaleIndex()];
globalLocaleData = locale_data[sys_locale->fallbackLocaleIndex()];
QVariant res = sys_locale->query(QSystemLocale::LanguageId);
if (!res.isNull()) {
@ -4240,7 +4240,7 @@ QStringList QLocale::uiLanguages() const
for (const auto &entry : uiLanguages)
locales.append(QLocale(entry));
if (locales.isEmpty())
locales.append(systemLocale()->fallbackUiLocale());
locales.append(systemLocale()->fallbackLocale());
} else
#endif
{

View File

@ -1112,13 +1112,6 @@
\sa FormatType
*/
/*!
\fn QLocale QSystemLocale::fallbackUiLocale() const
\since 4.6
Returns the fallback locale obtained from the system.
*/
/*!
\fn QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
@ -1129,6 +1122,17 @@
\sa QSystemLocale::QueryType
*/
/*!
\fn QLocale QSystemLocale::fallbackLocale() const
\since 4.6
Returns the locale used if the system locale is not able to answer a query.
Must be a QLocale instance based on the built-in CLDR data, and should
match what the system locale is using as closely as that data supports.
*/
/*!
\class QSystemLocale::CurrencyToStringArgument
\inmodule QtCore

View File

@ -418,7 +418,7 @@ static QVariant macQuoteString(QSystemLocale::QueryType type, QStringView str)
#ifndef QT_NO_SYSTEMLOCALE
QLocale QSystemLocale::fallbackUiLocale() const
QLocale QSystemLocale::fallbackLocale() const
{
return QLocale(getMacLocaleName());
}

View File

@ -127,9 +127,9 @@ public:
StandaloneMonthNameShort // QString, in: int
};
virtual QVariant query(QueryType type, QVariant in = QVariant()) const;
virtual QLocale fallbackUiLocale() const;
inline uint fallbackUiLocaleIndex() const;
virtual QLocale fallbackLocale() const;
inline uint fallbackLocaleIndex() const;
private:
QSystemLocale(bool);
friend class QSystemLocaleSingleton;
@ -428,7 +428,7 @@ public:
};
#ifndef QT_NO_SYSTEMLOCALE
uint QSystemLocale::fallbackUiLocaleIndex() const { return fallbackUiLocale().d->m_index; }
uint QSystemLocale::fallbackLocaleIndex() const { return fallbackLocale().d->m_index; }
#endif
template <>

View File

@ -133,7 +133,7 @@ static bool contradicts(const QString &maybe, const QString &known)
return !(maybeId.acceptLanguage(knownId.language_id) && maybeId.acceptScriptCountry(knownId));
}
QLocale QSystemLocale::fallbackUiLocale() const
QLocale QSystemLocale::fallbackLocale() const
{
// See man 7 locale for precedence - LC_ALL beats LC_MESSAGES beats LANG:
QString lang = qEnvironmentVariable("LC_ALL");

View File

@ -702,7 +702,7 @@ QString QSystemLocalePrivate::winToQtFormat(QStringView sys_fmt)
return result;
}
QLocale QSystemLocale::fallbackUiLocale() const
QLocale QSystemLocale::fallbackLocale() const
{
return QLocale(QString::fromLatin1(getWinLocaleName()));
}
@ -762,8 +762,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
if (type == LanguageId)
return lid.language_id;
if (type == ScriptId)
return lid.script_id ? lid.script_id : ushort(fallbackUiLocale().script());
return lid.country_id ? lid.country_id : ushort(fallbackUiLocale().country());
return lid.script_id ? lid.script_id : ushort(fallbackLocale().script());
return lid.country_id ? lid.country_id : ushort(fallbackLocale().country());
}
case MeasurementSystem:
return d->measurementSystem();

View File

@ -187,7 +187,7 @@ QVariant QAndroidSystemLocale::query(QueryType type, QVariant in) const
return QVariant();
}
QLocale QAndroidSystemLocale::fallbackUiLocale() const
QLocale QAndroidSystemLocale::fallbackLocale() const
{
QReadLocker locker(&m_lock);
return m_locale;

View File

@ -51,7 +51,7 @@ public:
QAndroidSystemLocale();
QVariant query(QueryType type, QVariant in) const override;
QLocale fallbackUiLocale() const override;
QLocale fallbackLocale() const override;
private:
void getLocaleFromJava() const;

View File

@ -3056,7 +3056,7 @@ public:
return QVariant();
}
QLocale fallbackUiLocale() const override
QLocale fallbackLocale() const override
{
return m_locale;
}