From 24e04645b688fc76052aac08fdfb0469ade46014 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 30 Nov 2017 12:01:11 -0500 Subject: [PATCH] [libcalamaresui] Stub requirements checking. Introduce a method checkRequirements() into the module system so that individual modules can do their own checking (as opposed to stuffing it all into the welcome module). --- src/calamares/CalamaresApplication.cpp | 1 + src/libcalamaresui/modulesystem/Module.cpp | 5 +++++ src/libcalamaresui/modulesystem/Module.h | 6 ++++++ src/libcalamaresui/modulesystem/ModuleManager.cpp | 14 ++++++++++++++ src/libcalamaresui/modulesystem/ModuleManager.h | 7 +++++++ 5 files changed, 33 insertions(+) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index caba96f5d..58190fae5 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -355,6 +355,7 @@ void CalamaresApplication::initViewSteps() { cDebug() << "STARTUP: loadModules for all modules done"; + m_moduleManager->checkRequirements(); m_mainwindow->show(); ProgressTreeModel* m = new ProgressTreeModel( nullptr ); ProgressTreeView::instance()->setModel( m ); diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 7af5dbb75..0af30e08e 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -297,4 +297,9 @@ Module::initFrom( const QVariantMap& moduleDescriptor ) m_name = moduleDescriptor.value( "name" ).toString(); } +void +Module::checkRequirements() +{ +} + } //ns diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index 4da904dae..294b516e2 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -161,6 +162,11 @@ public: */ QVariantMap configurationMap(); + /** + * @brief Check the requirements of this module. + */ + virtual void checkRequirements(); + protected: explicit Module(); virtual void initFrom( const QVariantMap& moduleDescriptor ); diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index f5eed42b0..573cfa915 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -315,4 +315,18 @@ ModuleManager::loadModules() } ); } +void +ModuleManager::checkRequirements() +{ + QTimer::singleShot( 0, this, [ this ]() + { + for (const auto& module : m_loadedModulesByInstanceKey ) + { + module->checkRequirements(); + } + + emit modulesChecked(); + } ); +} + } // namespace diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index daa988064..9444b96f3 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -80,9 +80,16 @@ public: */ void loadModules(); + /** + * @brief Starts asynchronous requirements checking for each module. + * When this is done, the signal modulesChecked is emitted. + */ + void checkRequirements(); + signals: void initDone(); void modulesLoaded(); + void modulesChecked(); private slots: void doInit();