[welcome] Switch to using LocaleModel for language combobox
- Use the model instead of inserting items - While here, tidy includes and documentation
This commit is contained in:
parent
589168685e
commit
94765d40cd
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||||
* Copyright 2015, Anke Boersma <demm@kaosx.us>
|
* 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
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,16 +21,18 @@
|
|||||||
#include "WelcomePage.h"
|
#include "WelcomePage.h"
|
||||||
|
|
||||||
#include "ui_WelcomePage.h"
|
#include "ui_WelcomePage.h"
|
||||||
#include "CalamaresVersion.h"
|
#include "LocaleModel.h"
|
||||||
#include "checker/CheckerContainer.h"
|
#include "checker/CheckerContainer.h"
|
||||||
|
|
||||||
|
#include "Branding.h"
|
||||||
|
#include "CalamaresVersion.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
#include "ViewManager.h"
|
||||||
|
#include "modulesystem/ModuleManager.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
|
|
||||||
#include "modulesystem/ModuleManager.h"
|
|
||||||
#include "Settings.h"
|
|
||||||
#include "ViewManager.h"
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
@ -39,13 +41,11 @@
|
|||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "Branding.h"
|
|
||||||
|
|
||||||
|
|
||||||
WelcomePage::WelcomePage( QWidget* parent )
|
WelcomePage::WelcomePage( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, ui( new Ui::WelcomePage )
|
, ui( new Ui::WelcomePage )
|
||||||
, m_checkingWidget( new CheckerContainer( this ) )
|
, 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::requirementsResult, m_checkingWidget, &CheckerContainer::requirementsChecked );
|
||||||
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsComplete, m_checkingWidget, &CheckerContainer::requirementsComplete );
|
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsComplete, m_checkingWidget, &CheckerContainer::requirementsComplete );
|
||||||
@ -156,21 +156,8 @@ WelcomePage::initLanguages()
|
|||||||
ui->languageWidget->clear();
|
ui->languageWidget->clear();
|
||||||
ui->languageWidget->setInsertPolicy( QComboBox::InsertAtBottom );
|
ui->languageWidget->setInsertPolicy( QComboBox::InsertAtBottom );
|
||||||
|
|
||||||
{
|
m_languages = new LocaleModel( QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') );
|
||||||
std::list< CalamaresUtils::LocaleLabel > localeList;
|
ui->languageWidget->setModel( m_languages );
|
||||||
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() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the best initial translation
|
// Find the best initial translation
|
||||||
QLocale defaultLocale = QLocale( QLocale::system().name() );
|
QLocale defaultLocale = QLocale( QLocale::system().name() );
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
* 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
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -27,6 +28,7 @@ class WelcomePage;
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CheckerContainer;
|
class CheckerContainer;
|
||||||
|
class LocaleModel;
|
||||||
|
|
||||||
class WelcomePage : public QWidget
|
class WelcomePage : public QWidget
|
||||||
{
|
{
|
||||||
@ -34,19 +36,24 @@ class WelcomePage : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit WelcomePage( QWidget* parent = nullptr );
|
explicit WelcomePage( QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
/// @brief Configure the buttons for URLs from the branding configuration
|
||||||
void setUpLinks( bool showSupportUrl,
|
void setUpLinks( bool showSupportUrl,
|
||||||
bool showKnownIssuesUrl,
|
bool showKnownIssuesUrl,
|
||||||
bool showReleaseNotesUrl );
|
bool showReleaseNotesUrl );
|
||||||
|
|
||||||
|
/// @brief Results of requirements checking
|
||||||
bool verdict() const;
|
bool verdict() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus
|
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// @brief Fill the list of languages with the available translations
|
||||||
void initLanguages();
|
void initLanguages();
|
||||||
|
|
||||||
Ui::WelcomePage* ui;
|
Ui::WelcomePage* ui;
|
||||||
CheckerContainer* m_checkingWidget;
|
CheckerContainer* m_checkingWidget;
|
||||||
|
LocaleModel *m_languages;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WELCOMEPAGE_H
|
#endif // WELCOMEPAGE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user