diff --git a/src/calamares/CMakeLists.txt b/src/calamares/CMakeLists.txt index 94d1716e6..901131cdf 100644 --- a/src/calamares/CMakeLists.txt +++ b/src/calamares/CMakeLists.txt @@ -11,7 +11,7 @@ set( calamaresSources CalamaresApplication.cpp CalamaresWindow.cpp Module.cpp - ModuleLoader.cpp + ModuleManager.cpp ViewManager.cpp Settings.cpp YamlUtils.cpp diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 3054e99b4..cfbff0ede 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -20,10 +20,11 @@ #include "CalamaresWindow.h" #include "CalamaresVersion.h" -#include "ModuleLoader.h" +#include "ModuleManager.h" #include "Settings.h" #include "utils/CalamaresUtils.h" #include "utils/Logger.h" +#include "ViewManager.h" CalamaresApplication::CalamaresApplication( int& argc, char *argv[] ) @@ -112,11 +113,11 @@ CalamaresApplication::initBranding() void CalamaresApplication::initPlugins() { - m_moduleLoader = new Calamares::ModuleLoader( + m_moduleManager = new Calamares::ModuleManager( Calamares::Settings::instance()->modulesSearchPaths(), this ); - connect( m_moduleLoader, &Calamares::ModuleLoader::done, - this, &CalamaresApplication::onPluginsReady ); - m_moduleLoader->start(); + connect( m_moduleManager, &Calamares::ModuleManager::ready, + this, &CalamaresApplication::onPluginsReady ); + m_moduleManager->start(); } @@ -126,6 +127,13 @@ CalamaresApplication::onPluginsReady() initJobQueue(); m_mainwindow = new CalamaresWindow(); + +// foreach ( QString moduleName, Calamares::Settings::instance()->viewModulesPrepare() ) +// { +// Q_ASSERT( m_moduleManager->availableModules().contains( moduleName ) ); +// m_moduleManager->module( moduleName )->loadSelf(); +// } + m_mainwindow->show(); } diff --git a/src/calamares/CalamaresApplication.h b/src/calamares/CalamaresApplication.h index 868281f59..d9ebc39ce 100644 --- a/src/calamares/CalamaresApplication.h +++ b/src/calamares/CalamaresApplication.h @@ -27,7 +27,7 @@ class CalamaresWindow; namespace Calamares { -class ModuleLoader; +class ModuleManager; } class CalamaresApplication : public QApplication @@ -53,7 +53,7 @@ private: void initJobQueue(); CalamaresWindow* m_mainwindow; - Calamares::ModuleLoader* m_moduleLoader; + Calamares::ModuleManager* m_moduleManager; bool m_debugMode; //QPointer< Calamares::JobQueue > m_jobQueue; diff --git a/src/calamares/Module.cpp b/src/calamares/Module.cpp index 16ddec66a..750b479f8 100644 --- a/src/calamares/Module.cpp +++ b/src/calamares/Module.cpp @@ -81,7 +81,7 @@ operator>>( const YAML::Node& node, Calamares::Module& m ) Calamares::Module* -Calamares::Module::loadFromFile( const QString& path ) +Calamares::Module::fromConfigFile( const QString& path ) { QFile metadataFile( path ); if ( metadataFile.exists() && metadataFile.open( QFile::ReadOnly | QFile::Text ) ) diff --git a/src/calamares/Module.h b/src/calamares/Module.h index 51c5929c2..0ad5520f5 100644 --- a/src/calamares/Module.h +++ b/src/calamares/Module.h @@ -42,7 +42,7 @@ namespace Calamares class UIDLLEXPORT Module { public: - static Module* loadFromFile( const QString& path ); + static Module* fromConfigFile( const QString& path ); QString name(); QStringList requiredModules(); diff --git a/src/calamares/ModuleLoader.cpp b/src/calamares/ModuleManager.cpp similarity index 88% rename from src/calamares/ModuleLoader.cpp rename to src/calamares/ModuleManager.cpp index 564aa69b9..18977f83d 100644 --- a/src/calamares/ModuleLoader.cpp +++ b/src/calamares/ModuleManager.cpp @@ -16,7 +16,7 @@ * along with Calamares. If not, see . */ -#include "ModuleLoader.h" +#include "ModuleManager.h" #include "utils/Logger.h" @@ -30,13 +30,13 @@ namespace Calamares { -ModuleLoader::ModuleLoader( const QStringList& paths, QObject* parent ) +ModuleManager::ModuleManager( const QStringList& paths, QObject* parent ) : QObject( parent ) , m_paths( paths ) { } -ModuleLoader::~ModuleLoader() +ModuleManager::~ModuleManager() { foreach ( Module* m, m_availableModules ) { @@ -46,14 +46,28 @@ ModuleLoader::~ModuleLoader() void -ModuleLoader::start() +ModuleManager::start() { QTimer::singleShot( 0, this, SLOT( doWork() ) ); } +QStringList +ModuleManager::availableModules() +{ + return m_availableModules.keys(); +} + + +Module* +ModuleManager::module( const QString& name ) +{ + return m_availableModules.value( name ); +} + + void -ModuleLoader::doWork() +ModuleManager::doWork() { // We start from a list of paths in m_paths. Each of those is a directory that // might (should) contain Calamares modules of any type/interface. @@ -82,7 +96,7 @@ ModuleLoader::doWork() continue; } - Module* moduleInfo = Module::loadFromFile( metadataFileInfo.absoluteFilePath() ); + Module* moduleInfo = Module::fromConfigFile( metadataFileInfo.absoluteFilePath() ); if ( moduleInfo && ( moduleInfo->name() == currentDir.dirName() ) && @@ -106,12 +120,12 @@ ModuleLoader::doWork() // At this point m_availableModules is filled with whatever was found in the // search paths. checkDependencies(); - emit done(); + emit ready(); } void -ModuleLoader::checkDependencies() +ModuleManager::checkDependencies() { // This goes through the map of available modules, and deletes those whose // dependencies are not met, if any. diff --git a/src/calamares/ModuleLoader.h b/src/calamares/ModuleManager.h similarity index 83% rename from src/calamares/ModuleLoader.h rename to src/calamares/ModuleManager.h index 2a7ff5d36..e7cb11266 100644 --- a/src/calamares/ModuleLoader.h +++ b/src/calamares/ModuleManager.h @@ -30,17 +30,20 @@ namespace Calamares class Module; -class ModuleLoader : public QObject +class ModuleManager : public QObject { Q_OBJECT public: - explicit ModuleLoader( const QStringList& paths, QObject* parent = 0 ); - virtual ~ModuleLoader(); + explicit ModuleManager( const QStringList& paths, QObject* parent = 0 ); + virtual ~ModuleManager(); void start(); + QStringList availableModules(); + Module* module( const QString& name ); + signals: - void done(); + void ready(); private slots: void doWork();