[locale] Replace weird static-constructor
- Replace createDefault() with a constructor that takes a locale name; use it with en_US.UTF-8 in those places where createDefault was previously used.
This commit is contained in:
parent
093240c131
commit
50e6f0fcbf
@ -27,14 +27,12 @@ LocaleConfiguration::LocaleConfiguration()
|
||||
}
|
||||
|
||||
|
||||
LocaleConfiguration
|
||||
LocaleConfiguration::createDefault()
|
||||
LocaleConfiguration::LocaleConfiguration( const QString& localeName )
|
||||
: LocaleConfiguration()
|
||||
{
|
||||
LocaleConfiguration lc = LocaleConfiguration();
|
||||
lc.lang = lc.lc_numeric = lc.lc_time = lc.lc_monetary = lc.lc_paper = lc.lc_name
|
||||
= lc.lc_address = lc.lc_telephone = lc.lc_measurement
|
||||
= lc.lc_identification = "en_US.UTF-8";
|
||||
return lc;
|
||||
lang = lc_numeric = lc_time = lc_monetary = lc_paper = lc_name
|
||||
= lc_address = lc_telephone = lc_measurement
|
||||
= lc_identification = localeName;
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,9 +26,11 @@
|
||||
class LocaleConfiguration
|
||||
{
|
||||
public:
|
||||
/// @brief Create an empty locale, with nothing set
|
||||
explicit LocaleConfiguration();
|
||||
/// @brief Create a locale with everything set to the given @p localeName
|
||||
explicit LocaleConfiguration( const QString& localeName /* "en_US.UTF-8" */ );
|
||||
|
||||
static LocaleConfiguration createDefault();
|
||||
static LocaleConfiguration fromLanguageAndLocation( const QString& language,
|
||||
const QStringList& availableLocales,
|
||||
const QString& countryCode );
|
||||
|
@ -452,18 +452,20 @@ LocalePage::onActivate()
|
||||
LocaleConfiguration
|
||||
LocalePage::guessLocaleConfiguration() const
|
||||
{
|
||||
static QString defaultLocale = QStringLiteral( "en_US.UTF-8" );
|
||||
|
||||
QLocale myLocale; // User-selected language
|
||||
|
||||
// If we cannot say anything about available locales
|
||||
if ( m_localeGenLines.isEmpty() )
|
||||
{
|
||||
cWarning() << "guessLocaleConfiguration can't guess from an empty list.";
|
||||
return LocaleConfiguration::createDefault();
|
||||
return LocaleConfiguration( defaultLocale );
|
||||
}
|
||||
|
||||
QString myLanguageLocale = myLocale.name();
|
||||
if ( myLanguageLocale.isEmpty() )
|
||||
return LocaleConfiguration::createDefault();
|
||||
return LocaleConfiguration( defaultLocale );
|
||||
|
||||
return LocaleConfiguration::fromLanguageAndLocation( myLanguageLocale,
|
||||
m_localeGenLines,
|
||||
|
Loading…
Reference in New Issue
Block a user