2019-02-09 13:05:06 +00:00
|
|
|
|
|
|
|
#ifndef PLUGINMANAGER_H
|
|
|
|
#define PLUGINMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QDir>
|
2020-01-31 10:13:28 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
2019-02-09 13:05:06 +00:00
|
|
|
|
|
|
|
class CutterPlugin;
|
|
|
|
|
|
|
|
class PluginManager: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
static PluginManager *getInstance();
|
|
|
|
|
2020-01-31 10:13:28 +00:00
|
|
|
class PluginTerminator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void operator()(CutterPlugin*) const;
|
|
|
|
};
|
|
|
|
using PluginPtr = std::unique_ptr<CutterPlugin, PluginTerminator>;
|
|
|
|
|
2019-02-09 13:05:06 +00:00
|
|
|
PluginManager();
|
|
|
|
~PluginManager();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Load all plugins, should be called once on application start
|
2019-02-09 13:05:06 +00:00
|
|
|
*/
|
|
|
|
void loadPlugins();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Destroy all loaded plugins, should be called once on application shutdown
|
2019-02-09 13:05:06 +00:00
|
|
|
*/
|
|
|
|
void destroyPlugins();
|
|
|
|
|
2020-01-31 10:13:28 +00:00
|
|
|
const std::vector<PluginPtr> &getPlugins() { return plugins; }
|
2019-02-09 13:05:06 +00:00
|
|
|
|
2019-12-12 07:35:25 +00:00
|
|
|
QVector<QDir> getPluginDirectories() const;
|
|
|
|
QString getUserPluginsDirectory() const;
|
2019-03-11 10:54:19 +00:00
|
|
|
|
2019-02-09 13:05:06 +00:00
|
|
|
private:
|
2020-01-31 10:13:28 +00:00
|
|
|
std::vector<PluginPtr> plugins;
|
2019-02-09 13:05:06 +00:00
|
|
|
|
|
|
|
void loadNativePlugins(const QDir &directory);
|
2019-12-12 07:35:25 +00:00
|
|
|
void loadPluginsFromDir(const QDir &pluginsDir, bool writable = false);
|
2019-02-09 13:05:06 +00:00
|
|
|
|
2019-02-13 22:24:22 +00:00
|
|
|
#ifdef CUTTER_ENABLE_PYTHON_BINDINGS
|
2019-02-09 13:05:06 +00:00
|
|
|
void loadPythonPlugins(const QDir &directory);
|
|
|
|
CutterPlugin *loadPythonPlugin(const char *moduleName);
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#define Plugins() (PluginManager::getInstance())
|
|
|
|
|
|
|
|
#endif //PLUGINMANAGER_H
|