52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
// include/plugin_manager/IPlugin.h
|
|
#pragma once
|
|
|
|
#include <QtPlugin>
|
|
#include <QIcon>
|
|
#include "iCanvasItem.h"
|
|
|
|
// 形状描述
|
|
struct ShapeDescriptor {
|
|
QString id; // 形状标识符
|
|
QString name; // 显示名称
|
|
QString category; // 分类
|
|
QString iconPath; // 图标路径
|
|
QVariantMap defaults; // 默认属性
|
|
};
|
|
|
|
// 插件描述
|
|
struct PluginDescriptor {
|
|
QString id; // 插件ID
|
|
QString name; // 插件名称
|
|
QString version; // 版本
|
|
QString author; // 作者
|
|
QString description; // 描述
|
|
};
|
|
|
|
// 插件接口
|
|
class IPlugin : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit IPlugin(QObject *parent = nullptr) : QObject(parent) {}
|
|
virtual ~IPlugin() = default;
|
|
|
|
// 插件信息
|
|
virtual PluginDescriptor descriptor() const = 0;
|
|
|
|
// 支持的形状
|
|
virtual QList<ShapeDescriptor> shapes() const = 0;
|
|
|
|
// 创建形状
|
|
virtual ICanvasItem* createShape(const QString &shapeId) = 0;
|
|
|
|
// 插件生命周期
|
|
virtual bool initialize() = 0;
|
|
virtual void shutdown() = 0;
|
|
|
|
// 图标获取
|
|
virtual QIcon shapeIcon(const QString &shapeId) const = 0;
|
|
};
|
|
|
|
Q_DECLARE_INTERFACE(IPlugin, "com.canvas.plugin/1.0")
|