mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-29 10:25:36 -04:00
Load modules by phase, in preparation for actually using new settings.
This commit is contained in:
parent
a09ab36386
commit
2e47c248ac
5 changed files with 61 additions and 51 deletions
|
@ -27,6 +27,14 @@ class Job;
|
||||||
|
|
||||||
typedef QSharedPointer< Job > job_ptr;
|
typedef QSharedPointer< Job > job_ptr;
|
||||||
|
|
||||||
|
enum Phase
|
||||||
|
{
|
||||||
|
Phase_NULL = 0,
|
||||||
|
Prepare,
|
||||||
|
Install,
|
||||||
|
PostInstall
|
||||||
|
};
|
||||||
|
|
||||||
} //ns
|
} //ns
|
||||||
|
|
||||||
#endif // TYPEDEFS_H
|
#endif // TYPEDEFS_H
|
||||||
|
|
|
@ -112,30 +112,26 @@ Settings::Settings( bool debugMode, QObject* parent )
|
||||||
|
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
Settings::modulesSearchPaths()
|
Settings::modulesSearchPaths() const
|
||||||
{
|
{
|
||||||
return m_modulesSearchPaths;
|
return m_modulesSearchPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
Settings::modulesPrepare()
|
Settings::modules( Phase phase ) const
|
||||||
{
|
{
|
||||||
return m_modulesPrepareList;
|
switch ( phase )
|
||||||
}
|
{
|
||||||
|
case Prepare:
|
||||||
|
return m_modulesPrepareList;
|
||||||
QStringList
|
case Install:
|
||||||
Settings::modulesInstall()
|
return m_modulesInstallList;
|
||||||
{
|
case PostInstall:
|
||||||
return m_modulesInstallList;
|
return m_modulesPostInstallList;
|
||||||
}
|
default:
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
QStringList
|
|
||||||
Settings::modulesPostInstall()
|
|
||||||
{
|
|
||||||
return m_modulesPostInstallList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
#include "UiDllMacro.h"
|
#include "UiDllMacro.h"
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
@ -37,19 +38,15 @@ public:
|
||||||
static Settings* instance();
|
static Settings* instance();
|
||||||
//TODO: load from JSON then emit ready
|
//TODO: load from JSON then emit ready
|
||||||
|
|
||||||
QStringList modulesSearchPaths();
|
QStringList modulesSearchPaths() const;
|
||||||
|
|
||||||
QStringList modulesPrepare();
|
|
||||||
|
|
||||||
QStringList modulesInstall();
|
|
||||||
|
|
||||||
QStringList modulesPostInstall();
|
|
||||||
|
|
||||||
|
QStringList modules( Phase phase ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Settings* s_instance;
|
static Settings* s_instance;
|
||||||
|
|
||||||
QStringList m_modulesSearchPaths;
|
QStringList m_modulesSearchPaths;
|
||||||
|
|
||||||
QStringList m_modulesPrepareList;
|
QStringList m_modulesPrepareList;
|
||||||
QStringList m_modulesInstallList;
|
QStringList m_modulesInstallList;
|
||||||
QStringList m_modulesPostInstallList;
|
QStringList m_modulesPostInstallList;
|
||||||
|
|
|
@ -69,9 +69,35 @@ ModuleManager::module( const QString& name )
|
||||||
|
|
||||||
|
|
||||||
void
|
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
|
void
|
||||||
ModuleManager::recursiveLoad( const QString& moduleName )
|
ModuleManager::recursiveLoad( const QString& moduleName )
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define MODULELOADER_H
|
#define MODULELOADER_H
|
||||||
|
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -37,12 +38,18 @@ public:
|
||||||
explicit ModuleManager( const QStringList& paths, QObject* parent = nullptr );
|
explicit ModuleManager( const QStringList& paths, QObject* parent = nullptr );
|
||||||
virtual ~ModuleManager();
|
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();
|
void init();
|
||||||
|
|
||||||
QStringList availableModules();
|
QStringList availableModules();
|
||||||
Module* module( const QString& name );
|
Module* module( const QString& name );
|
||||||
|
|
||||||
void loadModulesPrepare();
|
void loadModules( Phase phase );
|
||||||
|
void loadModulesPrepare() { loadModules( Prepare ); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void initDone();
|
void initDone();
|
||||||
|
@ -50,7 +57,6 @@ signals:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void doInit();
|
void doInit();
|
||||||
void doLoadModulesPrepare();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recursiveLoad( const QString& moduleName );
|
void recursiveLoad( const QString& moduleName );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue