bigsnitch/pluginhandler.cpp

34 lines
837 B
C++
Raw Normal View History

2021-01-09 10:17:50 +00:00
#include "pluginhandler.h"
/*
const auto staticInstances = QPluginLoader::staticInstances();
for (QObject *plugin : staticInstances)
2021-03-19 16:40:33 +00:00
populateMenus(plugin);
2021-01-09 10:17:50 +00:00
*/
bool PluginHandler::load(QString path)
{
QPluginLoader loader(path);
QObject *plugin = loader.instance();
if (plugin) {
2021-03-19 16:40:33 +00:00
qDebug() << "loading plugin " << plugin;
2021-01-09 10:17:50 +00:00
proxyhandler.loadPlugin(plugin);
loaded_plugins += path;
return true;
2021-03-19 16:40:33 +00:00
} else {
qDebug() << "fo " << loader.errorString();
2021-01-09 10:17:50 +00:00
}
return false;
}
void PluginHandler::loadPlugins(QDir path)
{
2021-03-19 16:40:33 +00:00
qDebug() << "loading plugins from " << path;
2021-01-09 10:17:50 +00:00
const auto entryList = path.entryList(QDir::Files);
for (const QString &fileName : entryList) {
2021-03-19 16:40:33 +00:00
qDebug() << "loading " << fileName;
2021-01-09 10:17:50 +00:00
load(path.absoluteFilePath(fileName));
}
}