diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp index 123d9858c..9f68cf742 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp @@ -262,9 +262,23 @@ clearLayout( QLayout* layout ) } } +LocaleLabel::LocaleLabel() + : m_locale( QLocale() ) +{ + m_localeId = m_locale.name(); + + setLabels( QString(), LabelFormat::IfNeededWithCountry ); +} + LocaleLabel::LocaleLabel( const QString& locale, LabelFormat format ) : m_locale( LocaleLabel::getLocale( locale ) ) , m_localeId( locale ) +{ + setLabels( locale, format ); +} + +void +LocaleLabel::setLabels( const QString& locale, LabelFormat format ) { //: language[name] (country[name]) QString longFormat = QObject::tr( "%1 (%2)" ); @@ -274,7 +288,7 @@ LocaleLabel::LocaleLabel( const QString& locale, LabelFormat format ) QString countryName; if ( languageName.isEmpty() ) - languageName = QString( QLatin1Literal( "* %1 (%2)" ) ).arg( locale, englishName ); + languageName = QString( "* %1 (%2)" ).arg( locale, englishName ); bool needsCountryName = ( format == LabelFormat::AlwaysWithCountry ) || (locale.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 1 ); diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.h b/src/libcalamaresui/utils/CalamaresUtilsGui.h index 124594800..9df4f48c6 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.h +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.h @@ -140,6 +140,9 @@ public: /** @brief Formatting option for label -- add (country) to label. */ enum class LabelFormat { AlwaysWithCountry, IfNeededWithCountry } ; + /** @brief Empty locale. This uses the system-default locale. */ + LocaleLabel(); + /** @brief Construct from a locale name. * * The @p localeName should be one that Qt recognizes, e.g. en_US or ar_EY. @@ -192,6 +195,8 @@ public: static QLocale getLocale( const QString& localeName ); protected: + void setLabels( const QString& name, LabelFormat format ); + QLocale m_locale; QString m_localeId; // the locale identifier, e.g. "en_GB" QString m_label; // the native name of the locale