Merge branch 'master' into requirements-checking

This commit is contained in:
Adriaan de Groot 2019-02-15 00:32:45 +01:00
commit 43eae0bc47
437 changed files with 41760 additions and 9847 deletions

View file

@ -137,74 +137,6 @@ bool matchLocale( QComboBox& list, QLocale& matchFound, std::function<bool(const
return false;
}
struct LocaleLabel
{
LocaleLabel( const QString& locale )
: m_locale( LocaleLabel::getLocale( locale ) )
, m_localeId( locale )
{
QString sortKey = QLocale::languageToString( m_locale.language() );
QString label = m_locale.nativeLanguageName();
if ( label.isEmpty() )
label = QString( QLatin1Literal( "* %1 (%2)" ) ).arg( locale, sortKey );
if ( locale.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 2 )
{
QLatin1Literal countrySuffix( " (%1)" );
sortKey.append( QString( countrySuffix ).arg( QLocale::countryToString( m_locale.country() ) ) );
// If the language name is RTL, make this parenthetical addition RTL as well.
QString countryFormat = label.isRightToLeft() ? QString( QChar( 0x202B ) ) : QString();
countryFormat.append( countrySuffix );
label.append( countryFormat.arg( m_locale.nativeCountryName() ) );
}
m_sortKey = sortKey;
m_label = label;
}
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
/** @brief Define a sorting order.
*
* English (@see isEnglish() -- it means en_US) is sorted at the top.
*/
bool operator <(const LocaleLabel& other) const
{
if ( isEnglish() )
return !other.isEnglish();
if ( other.isEnglish() )
return false;
return m_sortKey < other.m_sortKey;
}
/** @brief Is this locale English?
*
* en_US and en (American English) is defined as English. The Queen's
* English -- proper English -- is relegated to non-English status.
*/
bool isEnglish() const
{
return m_localeId == QLatin1Literal( "en_US" ) || m_localeId == QLatin1Literal( "en" );
}
static QLocale getLocale( const QString& localeName )
{
if ( localeName.contains( "@latin" ) )
{
QLocale loc( localeName );
return QLocale( loc.language(), QLocale::Script::LatinScript, loc.country() );
}
else
return QLocale( localeName );
}
} ;
void
WelcomePage::initLanguages()
{
@ -213,7 +145,7 @@ WelcomePage::initLanguages()
ui->languageWidget->setInsertPolicy( QComboBox::InsertAtBottom );
{
std::list< LocaleLabel > localeList;
std::list< CalamaresUtils::LocaleLabel > localeList;
const auto locales = QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';');
for ( const QString& locale : locales )
{
@ -224,7 +156,7 @@ WelcomePage::initLanguages()
for ( const auto& locale : localeList )
{
ui->languageWidget->addItem( locale.m_label, locale.m_locale );
ui->languageWidget->addItem( locale.label(), locale.locale() );
}
}