+
+void MainWindow::loadPlugins() {
+ foreach(QObject *plugin, QPluginLoader::staticInstances())
+ populateMenus(plugin);
+
+ QStringList directories = KGlobal::dirs()->findDirs("module", QString());
+ QStringList filters;
+ filters << "libkdenlive*";
+ foreach(const QString &folder, directories) {
+ kDebug() << "// PARSING FIOLER: " << folder;
+ QDir pluginsDir(folder);
+ foreach(QString fileName, pluginsDir.entryList(filters, QDir::Files)) {
+ kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
+ QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
+ QObject *plugin = loader.instance();
+ if (plugin) {
+ populateMenus(plugin);
+ m_pluginFileNames += fileName;
+ } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
+ }
+ }
+ //exit(1);
+}
+
+void MainWindow::populateMenus(QObject *plugin) {
+ QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
+ ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
+ if (iGenerator)
+ addToMenu(plugin, iGenerator->generators(), addMenu, SLOT(generateClip()),
+ NULL);
+}
+
+void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
+ QMenu *menu, const char *member,
+ QActionGroup *actionGroup) {
+ kDebug() << "// ADD to MENU" << texts;
+ foreach(QString text, texts) {
+ QAction *action = new QAction(text, plugin);
+ action->setData(text);
+ connect(action, SIGNAL(triggered()), this, member);
+ menu->addAction(action);
+
+ if (actionGroup) {
+ action->setCheckable(true);
+ actionGroup->addAction(action);
+ }
+ }
+}
+
+void MainWindow::aboutPlugins() {
+ //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
+ //dialog.exec();
+}
+
+
+void MainWindow::generateClip() {
+ QAction *action = qobject_cast<QAction *>(sender());
+ ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
+
+ KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
+ if (!clipUrl.isEmpty()) {
+ m_projectList->slotAddClip(clipUrl);
+ }
+}
+