[libcalamaresui] Allow always-show-country setting in locale label
This commit is contained in:
parent
8790985fca
commit
210965aca4
@ -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 )
|
||||
{
|
||||
|
@ -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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user