void InputMap::loadPlugins() { QString path; #ifdef __APPLE__ path = QString("%1/../%2").arg(QApplication::applicationDirPath()) .arg(INPUTPLUGINDIR); #else path = QString(INPUTPLUGINDIR); #endif /* Find plugins from input plugin dir, sort by name, get regular files */ QDir dir(path, QString("*%1").arg(PLUGINEXT), QDir::Name, QDir::Files); /* Check that we can access the directory */ if (dir.exists() == false || dir.isReadable() == false) { qWarning() << "Unable to load input plugins from" << dir.absolutePath(); return; } /* Loop thru all files in the directory */ QStringListIterator it(dir.entryList()); while (it.hasNext() == true) { QLCInPlugin* p; QString path; /* Attempt to load a plugin from the path */ path = dir.absoluteFilePath(it.next()); QPluginLoader loader(path, this); p = qobject_cast<QLCInPlugin*> (loader.instance()); if (p != NULL) { /* Check for duplicates */ if (plugin(p->name()) == NULL) { /* New plugin. Append and init. */ p->init(); appendPlugin(p); p->connectInputData(this); } else { /* Duplicate plugin. Unload it. */ qWarning() << "Discarded duplicate plugin" << path; loader.unload(); } } else { qWarning() << "Unable to load an input plugin from" << path << "because:" << loader.errorString(); } } }
void InputMap::loadPlugins(const QDir& dir) { /* Check that we can access the directory */ if (dir.exists() == false || dir.isReadable() == false) return; /* Loop thru all files in the directory */ QStringListIterator it(dir.entryList()); while (it.hasNext() == true) { /* Attempt to load a plugin from the path */ QString fileName(it.next()); QString path = dir.absoluteFilePath(fileName); QPluginLoader loader(path, this); QLCInPlugin* p = qobject_cast<QLCInPlugin*> (loader.instance()); if (p != NULL) { /* Check for duplicates */ if (plugin(p->name()) == NULL) { /* New plugin. Append and init. */ qDebug() << "Input plugin" << p->name() << "from" << fileName; p->init(); appendPlugin(p); QLCi18n::loadTranslation(p->name().replace(" ", "_")); } else { /* Duplicate plugin. Unload it. */ qWarning() << Q_FUNC_INFO << "Discarded duplicate input plugin" << fileName; loader.unload(); } } else { qWarning() << Q_FUNC_INFO << fileName << "doesn't contain a QLC input plugin:" << loader.errorString(); loader.unload(); } } }
QLCInPlugin* InputMap::plugin(const QString& name) { QListIterator <QLCInPlugin*> it(m_plugins); while (it.hasNext() == true) { QLCInPlugin* plugin = it.next(); if (plugin->name() == name) return plugin; } return NULL; }
void InputMap::slotConfigurationChanged() { QLCInPlugin* plugin = qobject_cast<QLCInPlugin*> (QObject::sender()); if (plugin == NULL) // The signal comes from a plugin that isn't guaranteed to behave return; for (quint32 i = 0; i < universes(); i++) { InputPatch* ip = patch(i); Q_ASSERT(ip != NULL); if (ip->plugin() == plugin) ip->reconnect(); } emit pluginConfigurationChanged(plugin->name()); }
void InputMap::slotConfigurationChanged() { QLCInPlugin* plugin = qobject_cast<QLCInPlugin*> (QObject::sender()); if (plugin != NULL) emit pluginConfigurationChanged(plugin->name()); }