62 #include <QPluginLoader>
65 #include <QScrollArea>
171 (*it)->setCloneID(
id++);
172 (*it)->unique_name();
200 for (
const QString&
bn : bns)
208 bool success = loader->unload();
214 for (
const QString&
bn : bns) {
237 return "Error: Plugin already loaded.";
243 return "File does not exist";
244 if (!
fi.isReadable())
245 return "File is not readable";
251 QString pluginAbsPath =
fi.absoluteFilePath();
253 QPluginLoader * loader =
new QPluginLoader(pluginAbsPath);
256 bool loadOk = loader->load();
259 VP1Msg::message(
"ERROR! Failed to load plugin. Error message: "+loader->errorString());
280 pluginAbsPath.replace(
"opt",
"dbg");
282 loader =
new QPluginLoader(pluginAbsPath);
283 loadOk = loader->load();
285 if (loadOk)
VP1Msg::message(
"Ok! 'dbg' build of the plugin successfully loaded!");
291 QObject *
plugin = loader->instance();
296 bool error = loader->errorString().isNull();
299 QString errStr =
"ERROR!!";
301 errStr = QString(
"Did not find any compatible plugins in file");
303 errStr = loader->errorString();
315 return "Did not find any channel factory in plugin file";
321 if (providedbasenames.count()==0)
322 return "Found channel factory in plugin file, but no advertised channels!";
328 for (
const QString&
bn : providedbasenames) {
330 return "Channels navp1 '"+
bn+
"' are already provided by plugin file "
335 for (
const QString&
bn : providedbasenames) {
360 return QStringList();
367 err =
"Did not find plugin providing channel named '"+channelbasename+
"'";
376 err =
"Plugin file '"+plf+
"' did not provide channel navp1 '"+channelbasename+
"' despite advertising this capability!";
382 if (channelbasename!=cw->
name()) {
383 err =
"Actual basename of channel widget constructed by factory is not the one requested: '"+cw->
name()
384 +
"' vs. '"+channelbasename+
"'. This is most likely due to a mistake in the plugin!!";
407 cw->setUpdatesEnabled(
false);
419 QScrollArea * scrollarea =
new QScrollArea;
421 scrollarea->setObjectName(
"VP1ControllerScrollArea");
422 scrollarea->setWidgetResizable(
true);
423 scrollarea->setFrameShape(QFrame::NoFrame);
424 scrollarea->setFrameShadow(QFrame::Plain);
428 scrollarea->setWidget(controller);
434 cw->setUpdatesEnabled(
true);
488 std::map<QString,QString>::const_iterator
it = basename_2_pluginfile.begin();
489 std::map<QString,QString>::const_iterator
itE = basename_2_pluginfile.end();
493 channelmanager->availableChannelListChanged(
l);
512 std::map<QString,QString>::const_iterator
it = basename_2_pluginfile.begin();
513 std::map<QString,QString>::const_iterator
itE = basename_2_pluginfile.end();
515 if (channelmanager->nActive(
it->first)==0)
519 channelmanager->availableUnusedChannelListChanged(
l);
524 std::map<QString,std::pair<QStringList,IVP1ChannelWidgetFactory *> >::const_iterator
529 l<<QFileInfo(
it->first).fileName();
549 return QStringList();
556 l << (*it)->unique_name();