bigsnitch/pluginhandler.cpp
2021-03-19 17:40:33 +01:00

33 lines
837 B
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;
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));
}
}