summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-07-30 23:24:41 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2016-07-30 23:24:41 (GMT)
commit5fdbdf94d63acb9c2410a4893c478a3c5afc4d66 (patch)
treedfe9b40bf1648894836e60c64a3b0ce7509809b2
parentc9fd3bd0242f0d0331b600675d266249f8b692c9 (diff)
Add scriptable methods to add a bin/timeline clip and effect
Useful for testing purposes
-rw-r--r--src/dialogs/renderwidget.cpp4
-rw-r--r--src/dialogs/renderwidget.h10
-rw-r--r--src/effectslist/effectslistwidget.h2
-rw-r--r--src/mainwindow.cpp72
-rw-r--r--src/mainwindow.h8
-rw-r--r--src/org.kdenlive.MainWindow.xml8
6 files changed, 83 insertions, 21 deletions
diff --git a/src/dialogs/renderwidget.cpp b/src/dialogs/renderwidget.cpp
index 0e5aa00..3e94e17 100644
--- a/src/dialogs/renderwidget.cpp
+++ b/src/dialogs/renderwidget.cpp
@@ -931,7 +931,7 @@ void RenderWidget::focusFirstVisibleItem(const QString &profile)
updateButtons();
}
-void RenderWidget::slotPrepareExport(bool scriptExport)
+void RenderWidget::slotPrepareExport(bool scriptExport, const QString scriptPath)
{
if (!QFile::exists(KdenliveSettings::rendererpath())) {
KMessageBox::sorry(this, i18n("Cannot find the melt program required for rendering (part of Mlt)"));
@@ -947,7 +947,7 @@ void RenderWidget::slotPrepareExport(bool scriptExport)
return;
}
- emit prepareRenderingData(scriptExport, m_view.render_zone->isChecked(), chapterFile);
+ emit prepareRenderingData(scriptExport, m_view.render_zone->isChecked(), chapterFile, scriptPath);
}
void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut,
diff --git a/src/dialogs/renderwidget.h b/src/dialogs/renderwidget.h
index c1b4b4f..ab8c4ff 100644
--- a/src/dialogs/renderwidget.h
+++ b/src/dialogs/renderwidget.h
@@ -143,10 +143,11 @@ protected:
public slots:
void slotExport(bool scriptExport, int zoneIn, int zoneOut,
- const QMap <QString, QString> &metadata,
- const QList<QString> &playlistPaths, const QList<QString> &trackNames,
- const QString &scriptPath, bool exportAudio);
+ const QMap <QString, QString> &metadata,
+ const QList<QString> &playlistPaths, const QList<QString> &trackNames,
+ const QString &scriptPath, bool exportAudio);
void slotAbortCurrentJob();
+ void slotPrepareExport(bool scriptExport = false, QString scriptPath = QString());
private slots:
void slotUpdateButtons(const QUrl &url);
@@ -171,7 +172,6 @@ private slots:
void slotEditItem(QTreeWidgetItem *item);
void slotCLeanUpJobs();
void slotHideLog();
- void slotPrepareExport(bool scriptExport = false);
void slotPlayRendering(QTreeWidgetItem *item, int);
void slotStartCurrentJob();
void slotCopyToFavorites();
@@ -218,7 +218,7 @@ signals:
/** Send the info about rendering that will be saved in the document:
(profile destination, profile name and url of rendered file */
void selectedRenderProfile(const QMap <QString, QString> &renderProps);
- void prepareRenderingData(bool scriptExport, bool zoneOnly, const QString &chapterFile);
+ void prepareRenderingData(bool scriptExport, bool zoneOnly, const QString &chapterFile, const QString scriptPath);
void shutdown();
};
diff --git a/src/effectslist/effectslistwidget.h b/src/effectslist/effectslistwidget.h
index c0f63dc..0ad8e26 100644
--- a/src/effectslist/effectslistwidget.h
+++ b/src/effectslist/effectslistwidget.h
@@ -72,7 +72,7 @@ private:
private slots:
void slotExpandItem(const QModelIndex & index);
-
+
signals:
void applyEffect(const QDomElement);
void displayMenu(QTreeWidgetItem *, const QPoint &);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 5f4626a..a636877 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -52,7 +52,6 @@
#include "titler/titlewidget.h"
#include "timeline/markerdialog.h"
#include "timeline/clipitem.h"
-#include "interfaces.h"
#include "project/cliptranscode.h"
#include "scopes/scopemanager.h"
#include "project/dialogs/archivewidget.h"
@@ -65,6 +64,8 @@
#include <config-kdenlive.h>
#include "utils/thememanager.h"
#include "utils/progressbutton.h"
+#include "effectslist/effectslistwidget.h"
+
#include "utils/KoIconUtils.h"
#include "project/dialogs/temporarydata.h"
#ifdef USE_JOGSHUTTLE
@@ -1688,7 +1689,7 @@ void MainWindow::slotRenderProject()
m_renderWidget = new RenderWidget(projectfolder, project->useProxy(), profile, this);
connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap<QString,QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap<QString,QString>)));
- connect(m_renderWidget, SIGNAL(prepareRenderingData(bool,bool,QString)), this, SLOT(slotPrepareRendering(bool,bool,QString)));
+ connect(m_renderWidget, SIGNAL(prepareRenderingData(bool,bool,QString,QString)), this, SLOT(slotPrepareRendering(bool,bool,QString,QString)));
connect(m_renderWidget, SIGNAL(abortProcess(QString)), this, SIGNAL(abortRenderJob(QString)));
connect(m_renderWidget, SIGNAL(openDvdWizard(QString)), this, SLOT(slotDvdWizard(QString)));
m_renderWidget->setProfile(project->mltProfile());
@@ -1730,6 +1731,54 @@ void MainWindow::setRenderingFinished(const QString &url, int status, const QStr
m_renderWidget->setRenderStatus(url, status, error);
}
+void MainWindow::addProjectClip(const QString &url)
+{
+ if (pCore->projectManager()->current()) {
+ QStringList ids = pCore->binController()->getBinIdsByResource(QUrl::fromLocalFile(url));
+ if (!ids.isEmpty()) {
+ // Clip is already in project bin, abort
+ return;
+ }
+ ClipCreationDialog::createClipsCommand(pCore->projectManager()->current(), QList <QUrl>() << QUrl::fromLocalFile(url), QStringList(), pCore->bin());
+ }
+}
+
+void MainWindow::addTimelineClip(const QString &url)
+{
+ if (pCore->projectManager()->current()) {
+ QStringList ids = pCore->binController()->getBinIdsByResource(QUrl::fromLocalFile(url));
+ if (!ids.isEmpty()) {
+ pCore->bin()->selectClipById(ids.first());
+ slotInsertClipInsert();
+ }
+ }
+}
+
+void MainWindow::addEffect(const QString &effectName)
+{
+ QStringList effectInfo;
+ effectInfo << effectName << effectName;
+ const QDomElement effect = EffectsListWidget::itemEffect(5, effectInfo);
+ if (!effect.isNull()) {
+ slotAddEffect(effect);
+ } else {
+ qDebug()<<" * * *EFFECT: "<<effectName<<" NOT AVAILABLE";
+ exitApp();
+ }
+}
+
+void MainWindow::scriptRender(const QString &url)
+{
+ slotRenderProject();
+ m_renderWidget->slotPrepareExport(true, url);
+}
+
+void MainWindow::exitApp()
+{
+ QApplication::exit(0);
+}
+
+
void MainWindow::slotCleanProject()
{
if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
@@ -3116,12 +3165,11 @@ void MainWindow::slotSetDocumentRenderProfile(const QMap <QString, QString> &pro
}
-void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
+void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile, QString scriptPath)
{
KdenliveDoc *project = pCore->projectManager()->current();
if (m_renderWidget == NULL) return;
- QString scriptPath;
QString playlistPath;
QString mltSuffix(QStringLiteral(".mlt"));
QList<QString> playlistPaths;
@@ -3131,15 +3179,17 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
if (scriptExport) {
//QString scriptsFolder = project->projectFolder().path(QUrl::AddTrailingSlash) + "scripts/";
- QString path = m_renderWidget->getFreeScriptName(project->url());
- QPointer<KUrlRequesterDialog> getUrl = new KUrlRequesterDialog(QUrl::fromLocalFile(path), i18n("Create Render Script"), this);
- getUrl->urlRequester()->setMode(KFile::File);
- if (getUrl->exec() == QDialog::Rejected) {
+ if (scriptPath.isEmpty()) {
+ QString path = m_renderWidget->getFreeScriptName(project->url());
+ QPointer<KUrlRequesterDialog> getUrl = new KUrlRequesterDialog(QUrl::fromLocalFile(path), i18n("Create Render Script"), this);
+ getUrl->urlRequester()->setMode(KFile::File);
+ if (getUrl->exec() == QDialog::Rejected) {
+ delete getUrl;
+ return;
+ }
+ scriptPath = getUrl->selectedUrl().path();
delete getUrl;
- return;
}
- scriptPath = getUrl->selectedUrl().path();
- delete getUrl;
QFile f(scriptPath);
if (f.exists()) {
if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
diff --git a/src/mainwindow.h b/src/mainwindow.h
index a13ad1e..85c99ff 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -28,6 +28,7 @@
#include <QMap>
#include <QString>
#include <QImage>
+#include <QDBusAbstractAdaptor>
#include <KXmlGuiWindow>
#include <QTabWidget>
@@ -250,6 +251,11 @@ public slots:
void slotReloadEffects();
Q_SCRIPTABLE void setRenderingProgress(const QString &url, int progress);
Q_SCRIPTABLE void setRenderingFinished(const QString &url, int status, const QString &error);
+ Q_SCRIPTABLE void addProjectClip(const QString &url);
+ Q_SCRIPTABLE void addTimelineClip(const QString &url);
+ Q_SCRIPTABLE void addEffect(const QString &effectName);
+ Q_SCRIPTABLE void scriptRender(const QString &url);
+ Q_NOREPLY void exitApp();
void slotSwitchVideoThumbs();
void slotSwitchAudioThumbs();
@@ -393,7 +399,7 @@ private slots:
/** @brief Archive project: creates a copy of the project file with all clips in a new folder. */
void slotArchiveProject();
void slotSetDocumentRenderProfile(const QMap<QString, QString> &props);
- void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile);
+ void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile, QString scriptPath = QString());
/** @brief Switches between displaying frames or timecode.
* @param ix 0 = display timecode, 1 = display frames. */
diff --git a/src/org.kdenlive.MainWindow.xml b/src/org.kdenlive.MainWindow.xml
index 511aa80..eb2e829 100644
--- a/src/org.kdenlive.MainWindow.xml
+++ b/src/org.kdenlive.MainWindow.xml
@@ -13,5 +13,11 @@
<arg name="status" type="i" direction="in"/>
<arg name="error" type="s" direction="in"/>
</method>
- </interface>
+ <method name="addProjectClip">
+ <arg name="url" type="s" direction="in"/>
+ </method>
+ <method name="addTimelineClip">
+ <arg name="url" type="s" direction="in"/>
+ </method>
+ </interface>
</node>