[libcalamares] Move more into the locale service

- Use namespace CalamaresUtils::Locale consistently for this service.
 - Move locale-related non-GUI support code from the Welcome module
   to libcalamares; these are generally useful. Both Label (naming a locale)
   and LabelModel (managing a bunch of those Labels) have been moved.
This commit is contained in:
Adriaan de Groot 2019-05-10 11:46:20 -04:00
parent b490e30a5e
commit 18ed4c74ef
12 changed files with 93 additions and 75 deletions

View file

@ -21,16 +21,16 @@
#include "WelcomePage.h"
#include "ui_WelcomePage.h"
#include "LocaleModel.h"
#include "checker/CheckerContainer.h"
#include "Branding.h"
#include "CalamaresVersion.h"
#include "Settings.h"
#include "ViewManager.h"
#include "locale/LabelModel.h"
#include "modulesystem/ModuleManager.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/LocaleLabel.h"
#include "utils/Logger.h"
#include "utils/Retranslator.h"
@ -131,7 +131,7 @@ WelcomePage::initLanguages()
ui->languageWidget->clear();
ui->languageWidget->setInsertPolicy( QComboBox::InsertAtBottom );
m_languages = new LocaleModel( QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') );
m_languages = new CalamaresUtils::Locale::LabelModel( QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') );
ui->languageWidget->setModel( m_languages );
ui->languageWidget->setItemDelegate( new LocaleTwoColumnDelegate( ui->languageWidget ) );
@ -261,3 +261,11 @@ bool WelcomePage::verdict() const
{
return m_checkingWidget->verdict();
}
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( CalamaresUtils::Locale::LabelModel::EnglishLabelRole ).toString() );
}