diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index a13a6ceb7..28775f326 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -63,11 +63,11 @@ Config::retranslate() message = setup ? tr( "This computer does not satisfy some of the " "recommended requirements for setting up %1.
" "Setup can continue, but some features " - "might be disabled." ) + "might be reduced." ) : tr( "This computer does not satisfy some of the " "recommended requirements for installing %1.
" "Installation can continue, but some features " - "might be disabled." ); + "might be reduced." ); } m_warningMessage = message.arg( Calamares::Branding::instance()->shortVersionedName() ); diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 616c91bff..376fe1ea6 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -36,12 +36,12 @@ #include #include -WelcomePage::WelcomePage( Config* conf, QWidget* parent ) +WelcomePage::WelcomePage( Config* config, QWidget* parent ) : QWidget( parent ) , ui( new Ui::WelcomePage ) - , m_checkingWidget( new CheckerContainer( *( conf->requirementsModel() ), this ) ) + , m_checkingWidget( new CheckerContainer( config, this ) ) , m_languages( nullptr ) - , m_conf( conf ) + , m_conf( config ) { using Branding = Calamares::Branding; diff --git a/src/modules/welcome/WelcomePage.h b/src/modules/welcome/WelcomePage.h index 04c17d25f..cbbc7f510 100644 --- a/src/modules/welcome/WelcomePage.h +++ b/src/modules/welcome/WelcomePage.h @@ -27,7 +27,7 @@ class WelcomePage : public QWidget { Q_OBJECT public: - explicit WelcomePage( Config* conf, QWidget* parent = nullptr ); + WelcomePage( Config* config, QWidget* parent = nullptr ); enum class Button { diff --git a/src/modules/welcome/checker/CheckerContainer.cpp b/src/modules/welcome/checker/CheckerContainer.cpp index 860857c3c..19f69ddc9 100644 --- a/src/modules/welcome/checker/CheckerContainer.cpp +++ b/src/modules/welcome/checker/CheckerContainer.cpp @@ -22,12 +22,12 @@ #include -CheckerContainer::CheckerContainer( const Calamares::RequirementsModel& model, QWidget* parent ) +CheckerContainer::CheckerContainer( Config* config, QWidget* parent ) : QWidget( parent ) , m_waitingWidget( new WaitingWidget( QString(), this ) ) , m_checkerWidget( nullptr ) , m_verdict( false ) - , m_model( model ) + , m_config( config ) { QBoxLayout* mainLayout = new QHBoxLayout; setLayout( mainLayout ); @@ -49,13 +49,14 @@ CheckerContainer::requirementsComplete( bool ok ) { if ( !ok ) { - cDebug() << "Requirements not satisfied" << m_model.count() << "entries:"; - for ( int i = 0; i < m_model.count(); ++i ) + auto& model = *( m_config->requirementsModel() ); + cDebug() << "Requirements not satisfied" << model.count() << "entries:"; + for ( int i = 0; i < model.count(); ++i ) { - auto index = m_model.index( i ); - cDebug() << Logger::SubEntry << i << m_model.data( index, Calamares::RequirementsModel::Name ).toString() - << "set?" << m_model.data( index, Calamares::RequirementsModel::Satisfied ).toBool() << "req?" - << m_model.data( index, Calamares::RequirementsModel::Mandatory ).toBool(); + auto index = model.index( i ); + cDebug() << Logger::SubEntry << i << model.data( index, Calamares::RequirementsModel::Name ).toString() + << "set?" << model.data( index, Calamares::RequirementsModel::Satisfied ).toBool() << "req?" + << model.data( index, Calamares::RequirementsModel::Mandatory ).toBool(); } } @@ -63,7 +64,7 @@ CheckerContainer::requirementsComplete( bool ok ) m_waitingWidget->deleteLater(); m_waitingWidget = nullptr; // Don't delete in destructor - m_checkerWidget = new ResultsListWidget( m_model, this ); + m_checkerWidget = new ResultsListWidget( m_config, this ); m_checkerWidget->setObjectName( "requirementsChecker" ); layout()->addWidget( m_checkerWidget ); diff --git a/src/modules/welcome/checker/CheckerContainer.h b/src/modules/welcome/checker/CheckerContainer.h index 93b75ac04..7846f7010 100644 --- a/src/modules/welcome/checker/CheckerContainer.h +++ b/src/modules/welcome/checker/CheckerContainer.h @@ -15,6 +15,7 @@ #define CHECKERCONTAINER_H #include "Config.h" + #include class ResultsListWidget; @@ -31,7 +32,7 @@ class CheckerContainer : public QWidget { Q_OBJECT public: - explicit CheckerContainer( const Calamares::RequirementsModel& model, QWidget* parent = nullptr ); + explicit CheckerContainer( Config* config, QWidget* parent = nullptr ); ~CheckerContainer() override; bool verdict() const; @@ -49,7 +50,7 @@ protected: bool m_verdict; private: - const Calamares::RequirementsModel& m_model; + Config* m_config = nullptr; }; #endif diff --git a/src/modules/welcome/checker/ResultsListWidget.cpp b/src/modules/welcome/checker/ResultsListWidget.cpp index a7c5caf49..e3ef28526 100644 --- a/src/modules/welcome/checker/ResultsListWidget.cpp +++ b/src/modules/welcome/checker/ResultsListWidget.cpp @@ -149,9 +149,9 @@ ResultsListDialog::retranslate() } -ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model, QWidget* parent ) +ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent ) : QWidget( parent ) - , m_model( model ) + , m_config( config ) { setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); @@ -169,23 +169,25 @@ ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model, spacerLayout->addSpacing( paddingSize ); CalamaresUtils::unmarginLayout( spacerLayout ); - m_explanation = new QLabel; - m_explanation->setWordWrap( true ); - m_explanation->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - m_explanation->setOpenExternalLinks( false ); - m_explanation->setObjectName( "resultsExplanation" ); - connect( m_explanation, &QLabel::linkActivated, this, &ResultsListWidget::linkClicked ); - entriesLayout->addWidget( m_explanation ); + auto* explanation = new QLabel; + explanation->setWordWrap( true ); + explanation->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); + explanation->setOpenExternalLinks( false ); + explanation->setObjectName( "resultsExplanation" ); + connect( explanation, &QLabel::linkActivated, this, &ResultsListWidget::linkClicked ); + entriesLayout->addWidget( explanation ); + + connect( config, &Config::warningMessageChanged, explanation, &QLabel::setText ); // Check that all are satisfied (gives warnings if not) and // all *mandatory* entries are satisfied (gives errors if not). - const bool requirementsSatisfied = m_model.satisfiedRequirements(); + const bool requirementsSatisfied = config->requirementsModel()->satisfiedRequirements(); auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i ) { return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool(); }; - createResultWidgets( entriesLayout, m_resultWidgets, model, isUnSatisfied ); + createResultWidgets( entriesLayout, m_resultWidgets, *( config->requirementsModel() ), isUnSatisfied ); if ( !requirementsSatisfied ) { @@ -220,7 +222,7 @@ ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model, mainLayout->addWidget( imageLabel ); } } - m_explanation->setAlignment( Qt::AlignCenter ); + explanation->setAlignment( Qt::AlignCenter ); } CALAMARES_RETRANSLATE_SLOT( &ResultsListWidget::retranslate ); @@ -233,7 +235,7 @@ ResultsListWidget::linkClicked( const QString& link ) { if ( link == "#details" ) { - auto* dialog = new ResultsListDialog( m_model, this ); + auto* dialog = new ResultsListDialog( *( m_config->requirementsModel() ), this ); dialog->exec(); dialog->deleteLater(); } @@ -242,52 +244,15 @@ ResultsListWidget::linkClicked( const QString& link ) void ResultsListWidget::retranslate() { - for ( auto i = 0; i < m_model.count(); i++ ) + const auto& model = *( m_config->requirementsModel() ); + for ( auto i = 0; i < model.count(); i++ ) { if ( m_resultWidgets[ i ] ) { m_resultWidgets[ i ]->setText( - m_model.data( m_model.index( i ), Calamares::RequirementsModel::NegatedText ).toString() ); + model.data( model.index( i ), Calamares::RequirementsModel::NegatedText ).toString() ); } } - - // Check that all are satisfied (gives warnings if not) and - // all *mandatory* entries are satisfied (gives errors if not). - - if ( !m_model.satisfiedRequirements() ) - { - QString message; - const bool setup = Calamares::Settings::instance()->isSetupMode(); - if ( !m_model.satisfiedMandatory() ) - { - message = setup ? tr( "This computer does not satisfy the minimum " - "requirements for setting up %1.
" - "Setup cannot continue. " - "Details..." ) - : tr( "This computer does not satisfy the minimum " - "requirements for installing %1.
" - "Installation cannot continue. " - "Details..." ); - } - else - { - message = setup ? tr( "This computer does not satisfy some of the " - "recommended requirements for setting up %1.
" - "Setup can continue, but some features " - "might be disabled." ) - : tr( "This computer does not satisfy some of the " - "recommended requirements for installing %1.
" - "Installation can continue, but some features " - "might be disabled." ); - } - m_explanation->setText( message.arg( Calamares::Branding::instance()->shortVersionedName() ) ); - } - else - { - m_explanation->setText( tr( "This program will ask you some questions and " - "set up %2 on your computer." ) - .arg( Calamares::Branding::instance()->productName() ) ); - } } #include "utils/moc-warnings.h" diff --git a/src/modules/welcome/checker/ResultsListWidget.h b/src/modules/welcome/checker/ResultsListWidget.h index aa6c62258..5e96b74a0 100644 --- a/src/modules/welcome/checker/ResultsListWidget.h +++ b/src/modules/welcome/checker/ResultsListWidget.h @@ -14,6 +14,7 @@ #include "ResultWidget.h" #include "Config.h" + #include class QLabel; @@ -21,16 +22,15 @@ class ResultsListWidget : public QWidget { Q_OBJECT public: - explicit ResultsListWidget( const Calamares::RequirementsModel& model, QWidget* parent ); + explicit ResultsListWidget( Config* config, QWidget* parent ); private: /// @brief A link in the explanatory text has been clicked void linkClicked( const QString& link ); void retranslate(); - QLabel* m_explanation = nullptr; ///< Explanatory text above the list, with link - const Calamares::RequirementsModel& m_model; QList< ResultWidget* > m_resultWidgets; ///< One widget for each unsatisfied entry + Config* m_config = nullptr; }; #endif // CHECKER_RESULTSLISTWIDGET_H