diff --git a/src/modules/welcome/CMakeLists.txt b/src/modules/welcome/CMakeLists.txt index e217be22d..5fe5236b2 100644 --- a/src/modules/welcome/CMakeLists.txt +++ b/src/modules/welcome/CMakeLists.txt @@ -1,12 +1,12 @@ include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) -calamares_add_plugin( greeting +calamares_add_plugin( welcome TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES - GreetingViewStep.cpp - GreetingPage.cpp + WelcomeViewStep.cpp + WelcomePage.cpp UI - GreetingPage.ui + WelcomePage.ui LINK_LIBRARIES calamaresui SHARED_LIB diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 81271c29e..6a8695db0 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -17,9 +17,9 @@ * along with Calamares. If not, see . */ -#include "GreetingPage.h" +#include "WelcomePage.h" -#include "ui_GreetingPage.h" +#include "ui_WelcomePage.h" #include "CalamaresVersion.h" #include "utils/Logger.h" #include "utils/CalamaresUtilsGui.h" @@ -31,17 +31,18 @@ #include #include #include -#include +#include #include #include "Branding.h" -GreetingPage::GreetingPage( QWidget* parent ) +WelcomePage::WelcomePage( QWidget* parent ) : QWidget( parent ) - , ui( new Ui::GreetingPage ) + , ui( new Ui::WelcomePage ) { ui->setupUi( this ); + ui->languageWidget->setInsertPolicy( QComboBox::InsertAlphabetically ); QLocale defaultLocale = QLocale( QLocale::system().name() ); { @@ -55,33 +56,30 @@ GreetingPage::GreetingPage( QWidget* parent ) lang.append( QString( " (%1)" ) .arg( QLocale::countryToString( thisLocale.country() ) ) ); - ui->languageWidget->addItem( lang ); - ui->languageWidget->item( ui->languageWidget->count() - 1 ) - ->setData( Qt::UserRole, thisLocale ); + ui->languageWidget->addItem( lang, thisLocale ); if ( thisLocale.language() == defaultLocale.language() && thisLocale.country() == defaultLocale.country() ) { isTranslationAvailable = true; - ui->languageWidget->setCurrentRow( ui->languageWidget->count() - 1 ); + ui->languageWidget->setCurrentIndex( ui->languageWidget->count() - 1 ); cDebug() << "Initial locale " << thisLocale.name(); - CalamaresUtils::installTranslator( thisLocale, + CalamaresUtils::installTranslator( thisLocale.name(), Calamares::Branding::instance()->translationsPathPrefix(), qApp ); } } - ui->languageWidget->sortItems(); if ( !isTranslationAvailable ) { for (int i = 0; i < ui->languageWidget->count(); i++) { - QLocale thisLocale = ui->languageWidget->item(i)->data( Qt::UserRole ).toLocale(); + QLocale thisLocale = ui->languageWidget->itemData( i, Qt::UserRole ).toLocale(); if ( thisLocale.language() == defaultLocale.language() ) { isTranslationAvailable = true; - ui->languageWidget->setCurrentRow( i ); + ui->languageWidget->setCurrentIndex( i ); cDebug() << "Initial locale " << thisLocale.name(); - CalamaresUtils::installTranslator( thisLocale, + CalamaresUtils::installTranslator( thisLocale.name(), Calamares::Branding::instance()->translationsPathPrefix(), qApp ); break; @@ -93,13 +91,13 @@ GreetingPage::GreetingPage( QWidget* parent ) { for (int i = 0; i < ui->languageWidget->count(); i++) { - QLocale thisLocale = ui->languageWidget->item(i)->data( Qt::UserRole ).toLocale(); + QLocale thisLocale = ui->languageWidget->itemData( i, Qt::UserRole ).toLocale(); if ( thisLocale == QLocale( QLocale::English, QLocale::UnitedStates ) ) { - ui->languageWidget->setCurrentRow( i ); + ui->languageWidget->setCurrentIndex( i ); cDebug() << "Translation unavailable, so initial locale set to " << thisLocale.name(); QLocale::setDefault( thisLocale ); - CalamaresUtils::installTranslator( thisLocale, + CalamaresUtils::installTranslator( thisLocale.name(), Calamares::Branding::instance()->translationsPathPrefix(), qApp ); break; @@ -107,10 +105,11 @@ GreetingPage::GreetingPage( QWidget* parent ) } } - connect( ui->languageWidget, &QListWidget::currentItemChanged, - this, [ & ]( QListWidgetItem *current, QListWidgetItem *previous ) + connect( ui->languageWidget, + static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ), + this, [ & ]( int newIndex ) { - QLocale selectedLocale = current->data( Qt::UserRole ).toLocale(); + QLocale selectedLocale = ui->languageWidget->itemData( newIndex, Qt::UserRole ).toLocale(); cDebug() << "Selected locale" << selectedLocale.name(); QLocale::setDefault( selectedLocale ); @@ -118,12 +117,6 @@ GreetingPage::GreetingPage( QWidget* parent ) Calamares::Branding::instance()->translationsPathPrefix(), qApp ); } ); - - connect( ui->languageWidget, &QListWidget::itemDoubleClicked, - this, [] - { - Calamares::ViewManager::instance()->next(); - } ); } ui->mainText->setAlignment( Qt::AlignCenter ); @@ -172,7 +165,7 @@ GreetingPage::GreetingPage( QWidget* parent ) void -GreetingPage::setUpLinks( bool showSupportUrl, +WelcomePage::setUpLinks( bool showSupportUrl, bool showKnownIssuesUrl, bool showReleaseNotesUrl ) { @@ -233,7 +226,7 @@ GreetingPage::setUpLinks( bool showSupportUrl, void -GreetingPage::focusInEvent( QFocusEvent* e ) +WelcomePage::focusInEvent( QFocusEvent* e ) { if ( ui->languageWidget ) ui->languageWidget->setFocus(); diff --git a/src/modules/welcome/WelcomePage.h b/src/modules/welcome/WelcomePage.h index 209598bd8..1992c5cdc 100644 --- a/src/modules/welcome/WelcomePage.h +++ b/src/modules/welcome/WelcomePage.h @@ -16,21 +16,21 @@ * along with Calamares. If not, see . */ -#ifndef GREETINGPAGE_H -#define GREETINGPAGE_H +#ifndef WELCOMEPAGE_H +#define WELCOMEPAGE_H #include namespace Ui { -class GreetingPage; +class WelcomePage; } -class GreetingPage : public QWidget +class WelcomePage : public QWidget { Q_OBJECT public: - explicit GreetingPage( QWidget* parent = nullptr ); + explicit WelcomePage( QWidget* parent = nullptr ); void setUpLinks( bool showSupportUrl, bool showKnownIssuesUrl, @@ -40,7 +40,7 @@ protected: void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus private: - Ui::GreetingPage* ui; + Ui::WelcomePage* ui; }; -#endif // GREETINGPAGE_H +#endif // WELCOMEPAGE_H diff --git a/src/modules/welcome/WelcomePage.ui b/src/modules/welcome/WelcomePage.ui index 713c7cefe..3a39ab0d6 100644 --- a/src/modules/welcome/WelcomePage.ui +++ b/src/modules/welcome/WelcomePage.ui @@ -1,7 +1,7 @@ - GreetingPage - + WelcomePage + 0 @@ -15,17 +15,7 @@ - - - - 0 - 0 - - - - - - + @@ -81,6 +71,71 @@ + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 40 + 20 + + + + + + + + + 1 + 0 + + + + &Language: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + languageWidget + + + + + + + + 2 + 0 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Maximum + + + + 40 + 20 + + + + + + diff --git a/src/modules/welcome/WelcomeViewStep.cpp b/src/modules/welcome/WelcomeViewStep.cpp index e1e74d883..11c0397a8 100644 --- a/src/modules/welcome/WelcomeViewStep.cpp +++ b/src/modules/welcome/WelcomeViewStep.cpp @@ -16,21 +16,21 @@ * along with Calamares. If not, see . */ -#include "GreetingViewStep.h" +#include "WelcomeViewStep.h" -#include "GreetingPage.h" +#include "WelcomePage.h" #include -GreetingViewStep::GreetingViewStep( QObject* parent ) +WelcomeViewStep::WelcomeViewStep( QObject* parent ) : Calamares::ViewStep( parent ) - , m_widget( new GreetingPage() ) + , m_widget( new WelcomePage() ) { emit nextStatusChanged( true ); } -GreetingViewStep::~GreetingViewStep() +WelcomeViewStep::~WelcomeViewStep() { if ( m_widget && m_widget->parent() == nullptr ) m_widget->deleteLater(); @@ -38,68 +38,68 @@ GreetingViewStep::~GreetingViewStep() QString -GreetingViewStep::prettyName() const +WelcomeViewStep::prettyName() const { return tr( "Welcome" ); } QWidget* -GreetingViewStep::widget() +WelcomeViewStep::widget() { return m_widget; } void -GreetingViewStep::next() +WelcomeViewStep::next() { emit done(); } void -GreetingViewStep::back() +WelcomeViewStep::back() {} bool -GreetingViewStep::isNextEnabled() const +WelcomeViewStep::isNextEnabled() const { return true; } bool -GreetingViewStep::isBackEnabled() const +WelcomeViewStep::isBackEnabled() const { return false; } bool -GreetingViewStep::isAtBeginning() const +WelcomeViewStep::isAtBeginning() const { return true; } bool -GreetingViewStep::isAtEnd() const +WelcomeViewStep::isAtEnd() const { return true; } QList< Calamares::job_ptr > -GreetingViewStep::jobs() const +WelcomeViewStep::jobs() const { return QList< Calamares::job_ptr >(); } void -GreetingViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { bool showSupportUrl = configurationMap.contains( "showSupportUrl" ) && diff --git a/src/modules/welcome/WelcomeViewStep.h b/src/modules/welcome/WelcomeViewStep.h index 4ed4da6d4..57b8ede3e 100644 --- a/src/modules/welcome/WelcomeViewStep.h +++ b/src/modules/welcome/WelcomeViewStep.h @@ -16,8 +16,8 @@ * along with Calamares. If not, see . */ -#ifndef GREETINGPAGEPLUGIN_H -#define GREETINGPAGEPLUGIN_H +#ifndef WELCOMEPAGEPLUGIN_H +#define WELCOMEPAGEPLUGIN_H #include @@ -26,9 +26,9 @@ #include -class GreetingPage; +class WelcomePage; -class PLUGINDLLEXPORT GreetingViewStep : public Calamares::ViewStep +class PLUGINDLLEXPORT WelcomeViewStep : public Calamares::ViewStep { Q_OBJECT Q_PLUGIN_METADATA( IID "calamares.ViewModule/1.0" ) @@ -36,8 +36,8 @@ class PLUGINDLLEXPORT GreetingViewStep : public Calamares::ViewStep Q_INTERFACES( Calamares::ViewStep ) public: - explicit GreetingViewStep( QObject* parent = nullptr ); - virtual ~GreetingViewStep(); + explicit WelcomeViewStep( QObject* parent = nullptr ); + virtual ~WelcomeViewStep(); QString prettyName() const override; @@ -57,7 +57,7 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; private: - GreetingPage* m_widget; + WelcomePage* m_widget; }; -#endif // GREETINGPAGEPLUGIN_H +#endif // WELCOMEPAGEPLUGIN_H diff --git a/src/modules/welcome/module.desc b/src/modules/welcome/module.desc index dfa43ddbb..70383a55f 100644 --- a/src/modules/welcome/module.desc +++ b/src/modules/welcome/module.desc @@ -1,7 +1,7 @@ -# Module metadata file for greeting viewmodule +# Module metadata file for welcome viewmodule # Syntax is YAML 1.2 --- type: "view" #core or view -name: "greeting" #the module name. must be unique and same as the parent directory +name: "welcome" #the module name. must be unique and same as the parent directory interface: "qtplugin" #can be: qtplugin, python, process, ... -load: "libcalamares_viewmodule_greeting.so" +load: "libcalamares_viewmodule_welcome.so"