bigsnitch/pluginhandler.cpp
Tim Blume 600d7146d3 foo
2021-03-20 22:56:03 +01:00

37 lines
1.1 KiB
C++

#include "pluginhandler.h"
/*
const auto staticInstances = QPluginLoader::staticInstances();
for (QObject *plugin : staticInstances)
populateMenus(plugin);
*/
bool PluginHandler::load(QString path)
{
QPluginLoader loader(path);
QObject *plugin = loader.instance();
if (plugin) {
qDebug() << "loading plugin " << plugin;
proxyhandler.loadPlugin(plugin);
loaded_plugins += path;
QObject::connect(plugin, SIGNAL (error(QString)), this, SIGNAL (proxy_error(QString)), Qt::QueuedConnection);
QObject::connect(plugin, SIGNAL (message(http::Flow)), this, SIGNAL (proxy_message(http::Flow)), Qt::QueuedConnection);
return true;
} else {
qDebug() << "fo " << loader.errorString();
}
return false;
}
void PluginHandler::loadPlugins(QDir path)
{
qDebug() << "loading plugins from " << path;
const auto entryList = path.entryList(QDir::Files);
for (const QString &fileName : entryList) {
qDebug() << "loading " << fileName;
load(path.absoluteFilePath(fileName));
}
}