58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
// pluginManager.h
|
|
#pragma once
|
|
|
|
#include "export.hpp"
|
|
#include "../common/include/pluginCommon/iCanvasItem.h"
|
|
#include "../common/include/pluginCommon/iPlugin.h"
|
|
#include <QObject>
|
|
|
|
class DIAGRAM_DESIGNER_PUBLIC PluginManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit PluginManager(QObject *parent = nullptr);
|
|
virtual ~PluginManager();
|
|
|
|
// 单例模式
|
|
static PluginManager* instance();
|
|
|
|
// 插件管理
|
|
bool loadPlugin(const QString &filePath);
|
|
bool unloadPlugin(const QString &pluginId);
|
|
void loadAllPlugins(const QString &directory);
|
|
|
|
// 插件目录管理
|
|
void addPluginDirectory(const QString &dir);
|
|
void setPluginDirectories(const QStringList &dirs);
|
|
QStringList pluginDirectories() const;
|
|
|
|
// 创建原始插件项
|
|
ICanvasItem* createItem(const QString &shapeId);
|
|
|
|
// 查询接口
|
|
QStringList availableShapes() const;
|
|
bool contains(const QString &shapeId) const;
|
|
ShapeDescriptor shapeDescriptor(const QString &shapeId) const;
|
|
QIcon shapeIcon(const QString &shapeId) const;
|
|
|
|
// 插件信息
|
|
PluginDescriptor pluginDescriptor(const QString &pluginId) const;
|
|
QStringList loadedPlugins() const;
|
|
|
|
// 内置形状注册
|
|
void registerBuiltinShape(const QString &shapeId,
|
|
const QString &name,
|
|
std::function<ICanvasItem*()> creator,
|
|
const QString &iconPath = QString());
|
|
|
|
signals:
|
|
void pluginLoaded(const PluginDescriptor &descriptor);
|
|
void pluginUnloaded(const QString &pluginId);
|
|
void shapesChanged();
|
|
|
|
private:
|
|
class Private;
|
|
QScopedPointer<Private> d;
|
|
};
|