[welcome] Switch to using LocaleModel for language combobox

- Use the model instead of inserting items
 - While here, tidy includes and documentation
main
Adriaan de Groot 6 years ago
parent 589168685e
commit 94765d40cd

@ -2,7 +2,7 @@
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2015, Anke Boersma <demm@kaosx.us>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,15 +21,17 @@
#include "WelcomePage.h"
#include "ui_WelcomePage.h"
#include "CalamaresVersion.h"
#include "LocaleModel.h"
#include "checker/CheckerContainer.h"
#include "utils/Logger.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/Retranslator.h"
#include "modulesystem/ModuleManager.h"
#include "Branding.h"
#include "CalamaresVersion.h"
#include "Settings.h"
#include "ViewManager.h"
#include "modulesystem/ModuleManager.h"
#include "utils/Logger.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/Retranslator.h"
#include <QApplication>
#include <QBoxLayout>
@ -39,13 +41,11 @@
#include <QComboBox>
#include <QMessageBox>
#include "Branding.h"
WelcomePage::WelcomePage( QWidget* parent )
: QWidget( parent )
, ui( new Ui::WelcomePage )
, m_checkingWidget( new CheckerContainer( this ) )
, m_languages( nullptr )
{
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsResult, m_checkingWidget, &CheckerContainer::requirementsChecked );
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsComplete, m_checkingWidget, &CheckerContainer::requirementsComplete );
@ -156,21 +156,8 @@ WelcomePage::initLanguages()
ui->languageWidget->clear();
ui->languageWidget->setInsertPolicy( QComboBox::InsertAtBottom );
{
std::list< CalamaresUtils::LocaleLabel > localeList;
const auto locales = QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';');
for ( const QString& locale : locales )
{
localeList.emplace_back( locale );
}
localeList.sort(); // According to the sortkey, which is english
for ( const auto& locale : localeList )
{
ui->languageWidget->addItem( locale.label(), locale.locale() );
}
}
m_languages = new LocaleModel( QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') );
ui->languageWidget->setModel( m_languages );
// Find the best initial translation
QLocale defaultLocale = QLocale( QLocale::system().name() );

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,6 +28,7 @@ class WelcomePage;
}
class CheckerContainer;
class LocaleModel;
class WelcomePage : public QWidget
{
@ -34,19 +36,24 @@ class WelcomePage : public QWidget
public:
explicit WelcomePage( QWidget* parent = nullptr );
/// @brief Configure the buttons for URLs from the branding configuration
void setUpLinks( bool showSupportUrl,
bool showKnownIssuesUrl,
bool showReleaseNotesUrl );
/// @brief Results of requirements checking
bool verdict() const;
protected:
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus
private:
/// @brief Fill the list of languages with the available translations
void initLanguages();
Ui::WelcomePage* ui;
CheckerContainer* m_checkingWidget;
LocaleModel *m_languages;
};
#endif // WELCOMEPAGE_H

Loading…
Cancel
Save