From 620940c75b90d422d73a98285c816cc4a1e8a52b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 16 Apr 2019 23:49:27 +0200 Subject: [PATCH] [libcalamaresui] Drop now-unused sortKey from LocaleLabel - sortKey is unused - add englishLabel for reverse-i18n --- src/libcalamaresui/utils/CalamaresUtilsGui.cpp | 12 +++--------- src/libcalamaresui/utils/CalamaresUtilsGui.h | 8 +++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp index 69924f1b8..123d9858c 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp @@ -269,26 +269,20 @@ LocaleLabel::LocaleLabel( const QString& locale, LabelFormat format ) //: language[name] (country[name]) QString longFormat = QObject::tr( "%1 (%2)" ); - QString sortKey = QLocale::languageToString( m_locale.language() ); QString languageName = m_locale.nativeLanguageName(); + QString englishName = m_locale.languageToString( m_locale.language() ); QString countryName; if ( languageName.isEmpty() ) - languageName = QString( QLatin1Literal( "* %1 (%2)" ) ).arg( locale, sortKey ); + languageName = QString( QLatin1Literal( "* %1 (%2)" ) ).arg( locale, englishName ); bool needsCountryName = ( format == LabelFormat::AlwaysWithCountry ) || (locale.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 1 ); if ( needsCountryName ) - { - sortKey.append( '+' ); - sortKey.append( QLocale::countryToString( m_locale.country() ) ); - countryName = m_locale.nativeCountryName(); - } - - m_sortKey = sortKey; m_label = needsCountryName ? longFormat.arg( languageName ).arg( countryName ) : languageName; + m_englishLabel = englishName; } QLocale LocaleLabel::getLocale( const QString& localeName ) diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.h b/src/libcalamaresui/utils/CalamaresUtilsGui.h index 49f94e6a4..124594800 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.h +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.h @@ -172,6 +172,12 @@ public: { return m_label; } + /** @brief Get the *English* human-readable name for this locale. */ + QString englishLabel() const + { + return m_englishLabel; + } + /** @brief Get the Qt locale. */ QLocale locale() const { @@ -188,8 +194,8 @@ public: protected: QLocale m_locale; QString m_localeId; // the locale identifier, e.g. "en_GB" - QString m_sortKey; // the English name of the locale QString m_label; // the native name of the locale + QString m_englishLabel; } ;