Load modules by phase, in preparation for actually using new settings.
This commit is contained in:
parent
a09ab36386
commit
2e47c248ac
@ -27,6 +27,14 @@ class Job;
|
||||
|
||||
typedef QSharedPointer< Job > job_ptr;
|
||||
|
||||
enum Phase
|
||||
{
|
||||
Phase_NULL = 0,
|
||||
Prepare,
|
||||
Install,
|
||||
PostInstall
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
||||
#endif // TYPEDEFS_H
|
||||
|
@ -112,30 +112,26 @@ Settings::Settings( bool debugMode, QObject* parent )
|
||||
|
||||
|
||||
QStringList
|
||||
Settings::modulesSearchPaths()
|
||||
Settings::modulesSearchPaths() const
|
||||
{
|
||||
return m_modulesSearchPaths;
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
Settings::modulesPrepare()
|
||||
Settings::modules( Phase phase ) const
|
||||
{
|
||||
return m_modulesPrepareList;
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
Settings::modulesInstall()
|
||||
{
|
||||
return m_modulesInstallList;
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
Settings::modulesPostInstall()
|
||||
{
|
||||
return m_modulesPostInstallList;
|
||||
switch ( phase )
|
||||
{
|
||||
case Prepare:
|
||||
return m_modulesPrepareList;
|
||||
case Install:
|
||||
return m_modulesInstallList;
|
||||
case PostInstall:
|
||||
return m_modulesPostInstallList;
|
||||
default:
|
||||
return QStringList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define SETTINGS_H
|
||||
|
||||
#include "UiDllMacro.h"
|
||||
#include "Typedefs.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
@ -37,19 +38,15 @@ public:
|
||||
static Settings* instance();
|
||||
//TODO: load from JSON then emit ready
|
||||
|
||||
QStringList modulesSearchPaths();
|
||||
|
||||
QStringList modulesPrepare();
|
||||
|
||||
QStringList modulesInstall();
|
||||
|
||||
QStringList modulesPostInstall();
|
||||
QStringList modulesSearchPaths() const;
|
||||
|
||||
QStringList modules( Phase phase ) const;
|
||||
|
||||
private:
|
||||
static Settings* s_instance;
|
||||
|
||||
QStringList m_modulesSearchPaths;
|
||||
|
||||
QStringList m_modulesPrepareList;
|
||||
QStringList m_modulesInstallList;
|
||||
QStringList m_modulesPostInstallList;
|
||||
|
@ -69,9 +69,35 @@ ModuleManager::module( const QString& name )
|
||||
|
||||
|
||||
void
|
||||
ModuleManager::loadModulesPrepare()
|
||||
ModuleManager::loadModules( Phase phase )
|
||||
{
|
||||
QTimer::singleShot( 0, this, SLOT( doLoadModulesPrepare() ) );
|
||||
//FIXME: When we depend on Qt 5.4 this ugly hack should be replaced with
|
||||
// QTimer::singleShot.
|
||||
QTimer* timer = new QTimer();
|
||||
timer->setSingleShot( true );
|
||||
connect( timer, &QTimer::timeout,
|
||||
this, [ this, timer, phase ]()
|
||||
{
|
||||
foreach ( const QString& moduleName, Settings::instance()->modules( phase ) )
|
||||
{
|
||||
if ( !m_availableModules.contains( moduleName ) )
|
||||
{
|
||||
cDebug() << "Module" << moduleName << "not found in module search paths."
|
||||
<< "\nCalamares will now quit.";
|
||||
qApp->quit();
|
||||
}
|
||||
recursiveLoad( moduleName );
|
||||
}
|
||||
emit modulesLoaded();
|
||||
// Loading sequence:
|
||||
// 1) deps are already fine. check if we have all the modules needed by the roster
|
||||
// 2) ask ModuleManager to load them from the list provided by Settings
|
||||
// 3) MM must load them asyncly but one at a time, by calling Module::loadSelf
|
||||
// 4) Module must have subclasses that reimplement loadSelf for various module types
|
||||
|
||||
timer->deleteLater();
|
||||
});
|
||||
timer->start( 0 );
|
||||
}
|
||||
|
||||
|
||||
@ -133,29 +159,6 @@ ModuleManager::doInit()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ModuleManager::doLoadModulesPrepare()
|
||||
{
|
||||
foreach ( const QString& moduleName, Settings::instance()->modulesPrepare() )
|
||||
{
|
||||
if ( !m_availableModules.contains( moduleName ) )
|
||||
{
|
||||
cDebug() << "Module" << moduleName << "not found in module search paths."
|
||||
<< "\nCalamares will now quit.";
|
||||
qApp->quit();
|
||||
}
|
||||
recursiveLoad( moduleName );
|
||||
}
|
||||
emit modulesLoaded();
|
||||
|
||||
//IDEA:
|
||||
// 1) deps are already fine. check if we have all the modules needed by the roster
|
||||
// 2) ask MM to load them from the list provided by Settings
|
||||
// 3) MM must load them asyncly but one at a time, by calling Module::loadSelf
|
||||
// 4) Module must have subclasses that reimplement loadSelf for various module types
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ModuleManager::recursiveLoad( const QString& moduleName )
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define MODULELOADER_H
|
||||
|
||||
#include "Module.h"
|
||||
#include "Typedefs.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
@ -37,12 +38,18 @@ public:
|
||||
explicit ModuleManager( const QStringList& paths, QObject* parent = nullptr );
|
||||
virtual ~ModuleManager();
|
||||
|
||||
/**
|
||||
* @brief init goes through the module search directories and gets a list of
|
||||
* modules available for loading, along with their metadata.
|
||||
* This information is stored as a map of Module* objects, indexed by name.
|
||||
*/
|
||||
void init();
|
||||
|
||||
QStringList availableModules();
|
||||
Module* module( const QString& name );
|
||||
|
||||
void loadModulesPrepare();
|
||||
void loadModules( Phase phase );
|
||||
void loadModulesPrepare() { loadModules( Prepare ); }
|
||||
|
||||
signals:
|
||||
void initDone();
|
||||
@ -50,7 +57,6 @@ signals:
|
||||
|
||||
private slots:
|
||||
void doInit();
|
||||
void doLoadModulesPrepare();
|
||||
|
||||
private:
|
||||
void recursiveLoad( const QString& moduleName );
|
||||
|
Loading…
Reference in New Issue
Block a user