Commit 7731bd6d authored by Rafał Malinowski's avatar Rafał Malinowski

plugins: allow to get PluginRootComponent of each plugin

Signed-off-by: Rafał Malinowski's avatarRafał Malinowski <[email protected]>
parent 17805c9d
......@@ -27,3 +27,8 @@ ActivePlugin::ActivePlugin(const QString &pluginName, bool firstLoad) :
m_pluginRootComponentHandler{make_unique<PluginRootComponentHandler>(pluginName, firstLoad, m_pluginLoader->instance())}
{
}
PluginRootComponent * ActivePlugin::pluginRootComponent() const
{
return m_pluginRootComponentHandler->pluginRootComponent();
}
......@@ -26,6 +26,8 @@
#include <memory>
#include <QtCore/QScopedPointer>
class PluginRootComponent;
/**
* @addtogroup Plugin
* @{
......@@ -65,6 +67,11 @@ public:
*/
explicit ActivePlugin(const QString &pluginName, bool firstLoad);
/**
* @return Root component of plugin.
*/
PluginRootComponent * pluginRootComponent() const;
private:
// translations must be loaded first and uloaded last, see #2177
std::unique_ptr<PluginTranslationsLoader> m_pluginTranslationsLoader;
......
......@@ -134,3 +134,12 @@ QSet<QString> PluginActivationService::activePlugins() const
result.insert(activePlugin.first);
return result;
}
PluginRootComponent * PluginActivationService::pluginRootComponent(const QString &pluginName) const
{
if (!isActive(pluginName))
return nullptr;
auto &activePlugin = m_activePlugins.at(pluginName);
return activePlugin->pluginRootComponent();
}
......@@ -30,6 +30,7 @@
class ActivePlugin;
class PluginActivationErrorHandler;
class PluginDependencyHandler;
class PluginRootComponent;
class PluginStateService;
/**
......@@ -91,6 +92,12 @@ public:
*/
QSet<QString> activePlugins() const;
/**
* @param pluginName name of plugin
* @return root object from plugin with name pluginName
*/
PluginRootComponent * pluginRootComponent(const QString &pluginName) const;
private:
using map = std::map<QString, std::unique_ptr<ActivePlugin>>;
......
......@@ -36,3 +36,8 @@ PluginRootComponentHandler::~PluginRootComponentHandler() noexcept
{
m_pluginRootComponent->done();
}
PluginRootComponent * PluginRootComponentHandler::pluginRootComponent() const
{
return m_pluginRootComponent;
}
......@@ -61,6 +61,11 @@ public:
*/
~PluginRootComponentHandler() noexcept;
/**
* @return Stored root component of plugin.
*/
PluginRootComponent * pluginRootComponent() const;
private:
PluginRootComponent *m_pluginRootComponent;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment