diff --git a/src/modules/welcome/CMakeLists.txt b/src/modules/welcome/CMakeLists.txt index d702321f7..e6ddd2bd7 100644 --- a/src/modules/welcome/CMakeLists.txt +++ b/src/modules/welcome/CMakeLists.txt @@ -16,9 +16,9 @@ include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) set( CHECKER_SOURCES checker/CheckerContainer.cpp + checker/GeneralRequirements.cpp checker/ResultWidget.cpp checker/ResultsListWidget.cpp - checker/GeneralRequirements.cpp ${PARTMAN_SRC} ) diff --git a/src/modules/welcome/LocaleModel.cpp b/src/modules/welcome/LocaleModel.cpp index b735983c1..0ecf0fd1c 100644 --- a/src/modules/welcome/LocaleModel.cpp +++ b/src/modules/welcome/LocaleModel.cpp @@ -41,18 +41,18 @@ LocaleModel::rowCount( const QModelIndex& ) const QVariant LocaleModel::data( const QModelIndex& index, int role ) const { - if ( role != Qt::DisplayRole ) + if ( ( role != LabelRole ) && ( role != EnglishLabelRole ) ) return QVariant(); if ( !index.isValid() ) return QVariant(); const auto& locale = m_locales.at( index.row() ); - switch ( index.column() ) + switch ( role ) { - case 0: + case LabelRole: return locale.label(); - case 1: + case EnglishLabelRole: return locale.englishLabel(); default: return QVariant(); @@ -100,3 +100,10 @@ LocaleModel::find( const QLocale& locale ) const return locale == l.locale(); } ); } + +void +LocaleTwoColumnDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const +{ + QStyledItemDelegate::paint( painter, option, index ); + option.widget->style()->drawItemText( painter, option.rect, Qt::AlignRight | Qt::AlignVCenter, option.palette, false, index.data( LocaleModel::EnglishLabelRole ).toString() ); +} diff --git a/src/modules/welcome/LocaleModel.h b/src/modules/welcome/LocaleModel.h index c8125c0d8..b1566d336 100644 --- a/src/modules/welcome/LocaleModel.h +++ b/src/modules/welcome/LocaleModel.h @@ -20,9 +20,9 @@ #define WELCOME_LOCALEMODEL_H #include +#include #include - #include "utils/LocaleLabel.h" class LocaleModel : public QAbstractListModel @@ -30,6 +30,12 @@ class LocaleModel : public QAbstractListModel public: using LocaleLabel = CalamaresUtils::LocaleLabel; + enum + { + LabelRole = Qt::DisplayRole, + EnglishLabelRole = Qt::UserRole + 1 + }; + LocaleModel( const QStringList& locales, QObject* parent = nullptr ); virtual ~LocaleModel() override; @@ -56,4 +62,12 @@ private: QVector< LocaleLabel > m_locales; } ; +class LocaleTwoColumnDelegate : public QStyledItemDelegate +{ +public: + using QStyledItemDelegate::QStyledItemDelegate; + + void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const override; +} ; + #endif diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 2f859cd91..afb63971d 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -36,10 +36,10 @@ #include #include +#include #include #include #include -#include #include WelcomePage::WelcomePage( QWidget* parent ) @@ -133,6 +133,7 @@ WelcomePage::initLanguages() m_languages = new LocaleModel( QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') ); ui->languageWidget->setModel( m_languages ); + ui->languageWidget->setItemDelegate( new LocaleTwoColumnDelegate( ui->languageWidget ) ); // Find the best initial translation QLocale defaultLocale = QLocale( QLocale::system().name() ); @@ -165,7 +166,7 @@ WelcomePage::initLanguages() { QString name = m_languages->locale( matchedLocaleIndex ).name(); cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name; - + CalamaresUtils::installTranslator( name, Calamares::Branding::instance()->translationsPathPrefix(), qApp ); ui->languageWidget->setCurrentIndex( matchedLocaleIndex ); }