From f856c07b04a7245999742b6a19e4fe713f34a69c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 12 May 2020 16:09:13 +0200 Subject: [PATCH] [libcalamares] Move progress signal to RequirementsModel - It is the requirements model (checking) that reports progress, and now the model is accessible (ask for it with requirementsModel(), make the messages come from there. --- src/libcalamares/modulesystem/RequirementsChecker.cpp | 4 ++-- src/libcalamares/modulesystem/RequirementsModel.cpp | 7 +++++++ src/libcalamares/modulesystem/RequirementsModel.h | 9 +++++++++ src/libcalamaresui/modulesystem/ModuleManager.cpp | 1 - src/libcalamaresui/modulesystem/ModuleManager.h | 1 - 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/libcalamares/modulesystem/RequirementsChecker.cpp b/src/libcalamares/modulesystem/RequirementsChecker.cpp index 92e194818..0904d0c36 100644 --- a/src/libcalamares/modulesystem/RequirementsChecker.cpp +++ b/src/libcalamares/modulesystem/RequirementsChecker.cpp @@ -41,6 +41,7 @@ RequirementsChecker::RequirementsChecker( QVector< Module* > modules, Requiremen , m_progressTimeouts( 0 ) { m_watchers.reserve( m_modules.count() ); + connect( this, &RequirementsChecker::requirementsProgress, model, &RequirementsModel::setProgressMessage ); } RequirementsChecker::~RequirementsChecker() {} @@ -97,8 +98,7 @@ RequirementsChecker::addCheckedRequirements( Module* m ) m_model->addRequirementsList( l ); } - requirementsProgress( - tr( "Requirements checking for module %1 is complete." ).arg( m->name() ) ); + requirementsProgress( tr( "Requirements checking for module %1 is complete." ).arg( m->name() ) ); } void diff --git a/src/libcalamares/modulesystem/RequirementsModel.cpp b/src/libcalamares/modulesystem/RequirementsModel.cpp index eb2f892be..eed3b8b3b 100644 --- a/src/libcalamares/modulesystem/RequirementsModel.cpp +++ b/src/libcalamares/modulesystem/RequirementsModel.cpp @@ -105,4 +105,11 @@ RequirementsModel::describe() const } } +void +RequirementsModel::setProgressMessage( const QString& m ) +{ + m_progressMessage = m; + emit progressMessageChanged( m_progressMessage ); +} + } // namespace Calamares diff --git a/src/libcalamares/modulesystem/RequirementsModel.h b/src/libcalamares/modulesystem/RequirementsModel.h index ce9f23168..2318421c4 100644 --- a/src/libcalamares/modulesystem/RequirementsModel.h +++ b/src/libcalamares/modulesystem/RequirementsModel.h @@ -46,6 +46,7 @@ class DLLEXPORT RequirementsModel : public QAbstractListModel Q_OBJECT Q_PROPERTY( bool satisfiedRequirements READ satisfiedRequirements NOTIFY satisfiedRequirementsChanged FINAL ) Q_PROPERTY( bool satisfiedMandatory READ satisfiedMandatory NOTIFY satisfiedMandatoryChanged FINAL ) + Q_PROPERTY( QString progressMessage READ progressMessage NOTIFY progressMessageChanged FINAL ) public: using QAbstractListModel::QAbstractListModel; @@ -65,6 +66,9 @@ public: bool satisfiedRequirements() const { return m_satisfiedRequirements; } ///@brief Are all the **mandatory** requirements satisfied? bool satisfiedMandatory() const { return m_satisfiedMandatory; } + ///@brief Message (from an ongoing check) about progress + QString progressMessage() const { return m_progressMessage; } + QVariant data( const QModelIndex& index, int role ) const override; int rowCount( const QModelIndex& ) const override; @@ -76,6 +80,7 @@ public: signals: void satisfiedRequirementsChanged( bool value ); void satisfiedMandatoryChanged( bool value ); + void progressMessageChanged( QString message ); protected: QHash< int, QByteArray > roleNames() const override; @@ -83,10 +88,14 @@ protected: ///@brief Append some requirements; resets the model void addRequirementsList( const Calamares::RequirementsList& requirements ); + ///@brief Update progress message (called by the checker) + void setProgressMessage( const QString& m ); + private: ///@brief Implementation for {set,add}RequirementsList void changeRequirementsList(); + QString m_progressMessage; QMutex m_addLock; RequirementsList m_requirements; bool m_satisfiedRequirements = false; diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index b6040371b..3a3174935 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -358,7 +358,6 @@ ModuleManager::checkRequirements() } RequirementsChecker* rq = new RequirementsChecker( modules, m_requirementsModel, this ); - connect( rq, &RequirementsChecker::requirementsProgress, this, &ModuleManager::requirementsProgress ); connect( rq, &RequirementsChecker::done, rq, &RequirementsChecker::deleteLater ); connect( rq, &RequirementsChecker::done, this, [=](){ this->requirementsComplete( m_requirementsModel->satisfiedMandatory() ); } ); diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index 2c2685a3a..0c8a4bdaf 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -100,7 +100,6 @@ signals: void modulesFailed( QStringList ); /// .. or not // Below, see RequirementsChecker documentation void requirementsComplete( bool ); - void requirementsProgress( const QString& ); private slots: void doInit();