ModuleLoader ==> ModuleManager

main
Teo Mrnjavac 11 years ago
parent c23d198923
commit 205250e7c4

@ -11,7 +11,7 @@ set( calamaresSources
CalamaresApplication.cpp
CalamaresWindow.cpp
Module.cpp
ModuleLoader.cpp
ModuleManager.cpp
ViewManager.cpp
Settings.cpp
YamlUtils.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();
}

@ -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;

@ -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 ) )

@ -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();

@ -16,7 +16,7 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#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.

@ -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();
Loading…
Cancel
Save