平台获取模块中定义的QAction显示在ToolBar, 点击QAction, 加载插件插入到tab中 getPrjAllSlf封装到Slfio中,可以在插件模块中使用。
117 lines
2.8 KiB
C++
117 lines
2.8 KiB
C++
#include "CallPlugin.h"
|
|
#include "HPluginInterface.h"
|
|
#include "HPluginManage.h"
|
|
|
|
CallPlugin::CallPlugin(QObject *parent) : QObject(parent)
|
|
{
|
|
|
|
}
|
|
|
|
CallPlugin::~CallPlugin()
|
|
{
|
|
|
|
}
|
|
|
|
CallPlugin *CallPlugin::getInstance()
|
|
{
|
|
static CallPlugin ref;
|
|
return &ref;
|
|
}
|
|
|
|
QWidget *CallPlugin::getPluginWidget(QString strPluginName, QWidget *parent)
|
|
{
|
|
if (strPluginName == "")
|
|
return nullptr;
|
|
|
|
foreach (HPLUGIN_INFO *pluItem, HPluginManage::getInstance()->getPluginList())
|
|
{
|
|
HPluginInterface *pluInter = reinterpret_cast<HPluginInterface *>(pluItem->pluClass);
|
|
if (pluItem->pluName == strPluginName)
|
|
{
|
|
QWidget *pWidget = pluInter->createWindow(parent);
|
|
return pWidget;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
int CallPlugin::getPluginType(QString strPluginName)
|
|
{
|
|
if (strPluginName == "")
|
|
return -1;
|
|
|
|
foreach (HPLUGIN_INFO *pluItem, HPluginManage::getInstance()->getPluginList())
|
|
{
|
|
HPluginInterface *pluInter = reinterpret_cast<HPluginInterface *>(pluItem->pluClass);
|
|
if (pluItem->pluName == strPluginName)
|
|
{
|
|
return pluInter->windowType();
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
QString CallPlugin::getPluginParams(QString strPluginName)
|
|
{
|
|
if (strPluginName == "")
|
|
return "";
|
|
|
|
foreach (HPLUGIN_INFO *pluItem, HPluginManage::getInstance()->getPluginList())
|
|
{
|
|
HPluginInterface *pluInter = reinterpret_cast<HPluginInterface *>(pluItem->pluClass);
|
|
if (pluItem->pluName == strPluginName)
|
|
{
|
|
return pluInter->getParams();
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
void CallPlugin::setPluginParams(QString strPluginName, QString strParams)
|
|
{
|
|
if (strPluginName == "")
|
|
return;
|
|
|
|
foreach (HPLUGIN_INFO *pluItem, HPluginManage::getInstance()->getPluginList())
|
|
{
|
|
HPluginInterface *pluInter = reinterpret_cast<HPluginInterface *>(pluItem->pluClass);
|
|
if (pluItem->pluName == strPluginName)
|
|
{
|
|
return pluInter->setParams(strParams);
|
|
}
|
|
}
|
|
}
|
|
|
|
QList<QAction *> CallPlugin::getPluginActionList(QWidget *parent)
|
|
{
|
|
QList<QAction *> ret;
|
|
foreach (HPLUGIN_INFO *pluItem, HPluginManage::getInstance()->getPluginList())
|
|
{
|
|
HPluginInterface *pluInter = reinterpret_cast<HPluginInterface *>(pluItem->pluClass);
|
|
QWidget *pWidget = pluInter->createWindow(parent);
|
|
if(pWidget)
|
|
pWidget->hide();
|
|
QAction *p = pluInter->createAction(parent);
|
|
if(p)
|
|
ret << p;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
QAction *CallPlugin::getPluginAction(QString strPluginName, QWidget *parent)
|
|
{
|
|
if (strPluginName == "")
|
|
return nullptr;
|
|
|
|
foreach (HPLUGIN_INFO *pluItem, HPluginManage::getInstance()->getPluginList())
|
|
{
|
|
HPluginInterface *pluInter = reinterpret_cast<HPluginInterface *>(pluItem->pluClass);
|
|
if (pluItem->pluName == strPluginName)
|
|
{
|
|
QAction *pAct = pluInter->createAction(parent);
|
|
return pAct;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|