From dda7ea211d907c5c0e02b217550ae744639c8754 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Tue, 10 Mar 2015 19:48:11 +0100 Subject: [PATCH] Make ModuleManager accessible from outside CalamaresApplication. --- src/libcalamaresui/modulesystem/ModuleManager.cpp | 13 +++++++++++++ src/libcalamaresui/modulesystem/ModuleManager.h | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index b20a1b3ad..57ba12db8 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -32,11 +32,24 @@ namespace Calamares { + +ModuleManager* ModuleManager::s_instance = nullptr; + + +ModuleManager* +ModuleManager::instance() +{ + return s_instance; +} + + ModuleManager::ModuleManager( const QStringList& paths, QObject* parent ) : QObject( parent ) , m_paths( paths ) , m_lastPhaseLoaded( Phase_NULL ) { + Q_ASSERT( !s_instance ); + s_instance = this; } ModuleManager::~ModuleManager() diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index 2701c9c08..d2e36faea 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -38,6 +38,8 @@ public: explicit ModuleManager( const QStringList& paths, QObject* parent = nullptr ); virtual ~ModuleManager(); + static ModuleManager* instance(); + /** * @brief init goes through the module search directories and gets a list of * modules available for loading, along with their metadata. @@ -64,10 +66,10 @@ private: void checkDependencies(); QMap< QString, Module* > m_availableModules; - QStringList m_paths; - Phase m_lastPhaseLoaded; + + static ModuleManager* s_instance; }; }