diff --git a/src/modules/netinstall/Config.cpp b/src/modules/netinstall/Config.cpp index af4ae8e50..ebcda3b8b 100644 --- a/src/modules/netinstall/Config.cpp +++ b/src/modules/netinstall/Config.cpp @@ -66,6 +66,7 @@ void Config::loadGroupList( const QVariantList& groupData ) { m_model->setupModelData( groupData ); + emit statusReady(); } void diff --git a/src/modules/netinstall/Config.h b/src/modules/netinstall/Config.h index 372c82bee..781c9be5d 100644 --- a/src/modules/netinstall/Config.h +++ b/src/modules/netinstall/Config.h @@ -71,7 +71,8 @@ public: PackageModel* model() const { return m_model; } signals: - void statusChanged( QString status ); + void statusChanged( QString status ); ///< Something changed + void statusReady(); ///< Loading groups is complete private slots: void receivedGroupData(); ///< From async-loading group data diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index ab3e1a933..688e99b09 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -34,11 +34,16 @@ #include #include -NetInstallPage::NetInstallPage( QWidget* parent ) +NetInstallPage::NetInstallPage( Config* c, QWidget* parent ) : QWidget( parent ) + , m_config( c ) , ui( new Ui::Page_NetInst ) { ui->setupUi( this ); + ui->groupswidget->setModel( c->model() ); + connect( c, &Config::statusChanged, this, &NetInstallPage::setStatus ); + connect( c, &Config::statusReady, this, &NetInstallPage::expandGroups ); + setPageTitle( nullptr ); CALAMARES_RETRANSLATE_SLOT( &NetInstallPage::retranslate ); } @@ -63,16 +68,17 @@ NetInstallPage::setPageTitle( CalamaresUtils::Locale::TranslatedString* t ) void NetInstallPage::retranslate() { - if ( ui && m_title ) + if ( m_title ) { ui->label->setText( m_title->get() ); // That's get() on the TranslatedString } + ui->netinst_status->setText( m_config->status() ); } void -NetInstallPage::setModel( QAbstractItemModel* model ) +NetInstallPage::expandGroups() { - ui->groupswidget->setModel( model ); + auto* model = m_config->model(); // Go backwards because expanding a group may cause rows to appear below it for ( int i = model->rowCount() - 1; i >= 0; --i ) { @@ -84,6 +90,11 @@ NetInstallPage::setModel( QAbstractItemModel* model ) } } +void +NetInstallPage::setStatus( QString s ) +{ + ui->netinst_status->setText( s ); +} void NetInstallPage::onActivate() diff --git a/src/modules/netinstall/NetInstallPage.h b/src/modules/netinstall/NetInstallPage.h index 4db0b2f5d..13a106eaf 100644 --- a/src/modules/netinstall/NetInstallPage.h +++ b/src/modules/netinstall/NetInstallPage.h @@ -21,6 +21,7 @@ #ifndef NETINSTALLPAGE_H #define NETINSTALLPAGE_H +#include "Config.h" #include "PackageModel.h" #include "PackageTreeItem.h" @@ -42,7 +43,7 @@ class NetInstallPage : public QWidget { Q_OBJECT public: - NetInstallPage( QWidget* parent = nullptr ); + NetInstallPage( Config* config, QWidget* parent = nullptr ); virtual ~NetInstallPage(); /** @brief Sets the page title @@ -56,24 +57,21 @@ public: */ void setPageTitle( CalamaresUtils::Locale::TranslatedString* ); - /** @brief Sets the model of packages to display - * - * While setting up the UI, expand entries that should be pre-expanded. - * - * Follows the *expanded* key / the startExpanded field in the - * group entries of the model. Call this after filling up the model. - */ - void setModel( QAbstractItemModel* ); - void onActivate(); public slots: void retranslate(); + void setStatus( QString s ); -signals: - void checkReady( bool ); + /** @brief Expand entries that should be pre-expanded. + * + * Follows the *expanded* key / the startExpanded field in the + * group entries of the model. Call this after filling up the model. + */ + void expandGroups(); private: + Config* m_config; Ui::Page_NetInst* ui; std::unique_ptr< CalamaresUtils::Locale::TranslatedString > m_title; // Above the treeview diff --git a/src/modules/netinstall/NetInstallViewStep.cpp b/src/modules/netinstall/NetInstallViewStep.cpp index 0b5fb8b15..3eba788db 100644 --- a/src/modules/netinstall/NetInstallViewStep.cpp +++ b/src/modules/netinstall/NetInstallViewStep.cpp @@ -32,12 +32,11 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin< NetInstallViewStep::NetInstallViewStep( QObject* parent ) : Calamares::ViewStep( parent ) - , m_widget( new NetInstallPage() ) + , m_widget( new NetInstallPage( &m_config ) ) , m_sidebarLabel( nullptr ) , m_nextEnabled( false ) { - emit nextStatusChanged( true ); - connect( m_widget, &NetInstallPage::checkReady, this, &NetInstallViewStep::nextIsReady ); + connect( &m_config, &Config::statusReady, this, &NetInstallViewStep::nextIsReady ); } @@ -86,7 +85,7 @@ NetInstallViewStep::widget() bool NetInstallViewStep::isNextEnabled() const { - return m_nextEnabled; + return !m_config.required() || m_nextEnabled; } @@ -192,17 +191,16 @@ NetInstallViewStep::onLeave() } void -NetInstallViewStep::nextIsReady( bool b ) +NetInstallViewStep::nextIsReady() { - m_nextEnabled = b; - emit nextStatusChanged( b ); + m_nextEnabled = true; + emit nextStatusChanged( true ); } void NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { m_config.setRequired( CalamaresUtils::getBool( configurationMap, "required", false ) ); - m_widget->setModel( m_config.model() ); QString groupsUrl = CalamaresUtils::getString( configurationMap, "groupsUrl" ); if ( !groupsUrl.isEmpty() ) diff --git a/src/modules/netinstall/NetInstallViewStep.h b/src/modules/netinstall/NetInstallViewStep.h index 2dcf464c3..d2114a346 100644 --- a/src/modules/netinstall/NetInstallViewStep.h +++ b/src/modules/netinstall/NetInstallViewStep.h @@ -59,14 +59,14 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; public slots: - void nextIsReady( bool ); + void nextIsReady(); private: Config m_config; NetInstallPage* m_widget; CalamaresUtils::Locale::TranslatedString* m_sidebarLabel; // As it appears in the sidebar - bool m_nextEnabled; + bool m_nextEnabled = false; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( NetInstallViewStepFactory )