Commit 5fdbdf94 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Add scriptable methods to add a bin/timeline clip and effect

Useful for testing purposes
parent c9fd3bd0
......@@ -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,
......
......@@ -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();
};
......
......@@ -72,7 +72,7 @@ private:
private slots:
void slotExpandItem(const QModelIndex & index);
signals:
void applyEffect(const QDomElement);
void displayMenu(QTreeWidgetItem *, const QPoint &);
......
......@@ -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)
......
......@@ -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. */
......
......@@ -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>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment