diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp index 789b41c4f..a7783af3e 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp @@ -262,7 +262,7 @@ clearLayout( QLayout* layout ) } } -LocaleLabel::LocaleLabel( const QString& locale ) +LocaleLabel::LocaleLabel( const QString& locale, LabelFormat format ) : m_locale( LocaleLabel::getLocale( locale ) ) , m_localeId( locale ) { @@ -275,7 +275,8 @@ LocaleLabel::LocaleLabel( const QString& locale ) if ( languageName.isEmpty() ) languageName = QString( QLatin1Literal( "* %1 (%2)" ) ).arg( locale, sortKey ); - bool needsCountryName = locale.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 2; + bool needsCountryName = ( format == LabelFormat::AlwaysWithCountry ) || + (locale.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 1 ); if ( needsCountryName ) { diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.h b/src/libcalamaresui/utils/CalamaresUtilsGui.h index e75eee210..6a036b218 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.h +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.h @@ -137,11 +137,16 @@ constexpr int windowPreferredHeight = 520; class LocaleLabel { public: + /** @brief Formatting option for label -- add (country) to label. */ + enum class LabelFormat { AlwaysWithCountry, IfNeededWithCountry } ; + /** @brief Construct from a locale name. * - * The locale name should be one that Qt recognizes, e.g. en_US or ar_EY. + * The @p localeName should be one that Qt recognizes, e.g. en_US or ar_EY. + * The @p format determines whether the country name is always present + * in the label (human-readable form) or only if needed for disambiguation. */ - LocaleLabel( const QString& localeName ); + LocaleLabel( const QString& localeName, LabelFormat format = LabelFormat::IfNeededWithCountry ); /** @brief Define a sorting order. *