From c22c53e56b4338320a3e86183c3b43e3dbaae610 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Wed, 24 Sep 2008 23:11:58 +0000 Subject: [PATCH 1/1] new: save clip part as westley playlist svn path=/branches/KDE4/; revision=2408 --- src/mainwindow.cpp | 28 ++++++++++++++++++++++++++++ src/mainwindow.h | 2 ++ src/monitor.cpp | 34 +++++++++++++++++++++++----------- src/monitor.h | 2 ++ src/renderer.cpp | 34 ++++++++++++++++++++++++++++++++-- src/renderer.h | 2 ++ 6 files changed, 89 insertions(+), 13 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d042e2e2..1db221c1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -429,6 +429,9 @@ void MainWindow::slotConnectMonitors() { connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor())); connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor())); + + connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint))); + connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint))); } void MainWindow::slotAdjustClipMonitor() { @@ -1566,4 +1569,29 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) { } } +void MainWindow::slotSaveZone(Render *render, QPoint zone) { + KDialog *dialog = new KDialog(this); + dialog->setCaption("Save clip zone"); + dialog->setButtons(KDialog::Ok | KDialog::Cancel); + + QWidget *widget = new QWidget(dialog); + dialog->setMainWidget(widget); + + QVBoxLayout *vbox = new QVBoxLayout(widget); + QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this); + QString path = m_activeDocument->projectFolder().path(); + path.append("/"); + path.append("untitled.westley"); + KUrlRequester *url = new KUrlRequester(KUrl(path), this); + url->setFilter("video/mlt-playlist"); + QLabel *label2 = new QLabel(i18n("Description:"), this); + KLineEdit *edit = new KLineEdit(this); + vbox->addWidget(label1); + vbox->addWidget(url); + vbox->addWidget(label2); + vbox->addWidget(edit); + if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone); + +} + #include "mainwindow.moc" diff --git a/src/mainwindow.h b/src/mainwindow.h index d55d05e0..484d538a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -55,6 +55,7 @@ class CustomTrackView; class RenderWidget; class JogShuttle; class DocClipBase; +class Render; class MainWindow : public KXmlGuiWindow { Q_OBJECT @@ -237,6 +238,7 @@ private slots: void slotAdjustClipMonitor(); void slotAdjustProjectMonitor(); + void slotSaveZone(Render *render, QPoint zone); }; diff --git a/src/monitor.cpp b/src/monitor.cpp index 343a0210..e8c40e2c 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -109,25 +109,33 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent) m_contextMenu = new QMenu(this); m_contextMenu->addMenu(playMenu); - QMenu *goMenu = new QMenu(i18n("Go to..."), this); goMenu->addAction(i18n("Start"), this, SLOT(slotStart())); goMenu->addAction(i18n("End"), this, SLOT(slotEnd())); goMenu->addAction(i18n("Zone start"), this, SLOT(slotZoneStart())); goMenu->addAction(i18n("Zone end"), this, SLOT(slotZoneEnd())); - m_contextMenu->addMenu(goMenu); - - m_contextMenu->addAction(zoneStart); - m_contextMenu->addAction(zoneEnd); - QAction *extractFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame())); connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int))); connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint))); connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int))); connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int))); connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int))); + configMenu->addSeparator(); + configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"), this, SLOT(slotSetSizeOneToOne())); + configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"), this, SLOT(slotSetSizeOneToTwo())); + //render->createVideoXWindow(ui.video_frame->winId(), -1); + m_length = 0; + + m_contextMenu->addMenu(goMenu); + m_contextMenu->addAction(zoneStart); + m_contextMenu->addAction(zoneEnd); + //TODO: add save zone to timeline monitor when fixed + if (name == "clip") m_contextMenu->addAction(KIcon("document-save"), i18n("Save zone"), this, SLOT(slotSaveZone())); + + QAction *extractFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame())); configMenu->addAction(extractFrame); + if (name != "clip") { connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int))); connect(render, SIGNAL(durationChanged(int)), this, SIGNAL(durationChanged(int))); @@ -138,11 +146,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent) QAction *setThumbFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Set current image as thumbnail"), this, SLOT(slotSetThumbFrame())); configMenu->addAction(setThumbFrame); } - configMenu->addSeparator(); - configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"), this, SLOT(slotSetSizeOneToOne())); - configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"), this, SLOT(slotSetSizeOneToTwo())); - //render->createVideoXWindow(ui.video_frame->winId(), -1); - m_length = 0; + m_monitorRefresh->show(); kDebug() << "/////// BUILDING MONITOR, ID: " << ui.video_frame->winId(); } @@ -508,6 +512,14 @@ void Monitor::slotOpenFile(const QString &file) { render->setSceneList(doc, 0); } +void Monitor::slotSaveZone() { + if (render == NULL) return; + emit saveZone(render, m_ruler->zone()); + + //render->setSceneList(doc, 0); +} + + void Monitor::resetProfile() { if (render == NULL) return; render->resetProfile(); diff --git a/src/monitor.h b/src/monitor.h index f0359762..17e097a9 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -94,6 +94,7 @@ private slots: void slotSetSizeOneToTwo(); void slotSetZoneStart(); void slotSetZoneEnd(); + void slotSaveZone(); public slots: void slotOpenFile(const QString &); @@ -124,6 +125,7 @@ signals: void refreshClipThumbnail(const QString &); void adjustMonitorSize(); void zoneUpdated(QPoint); + void saveZone(Render *, QPoint); }; #endif diff --git a/src/renderer.cpp b/src/renderer.cpp index ec4f9922..a4321942 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -803,7 +803,6 @@ void Render::saveSceneList(QString path, QDomElement kdenliveData) { if (split) slotSplitView(false); westleyConsumer.connect(prod); //prod.set("title", "kdenlive document"); - //westleyConsumer.listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show); westleyConsumer.start(); while (!westleyConsumer.is_stopped()) {} if (!kdenliveData.isNull()) { @@ -826,6 +825,38 @@ void Render::saveSceneList(QString path, QDomElement kdenliveData) { } +void Render::saveZone(KUrl url, QString desc, QPoint zone) { + kDebug() << "// SAVING CLIP ZONE, RENDER: " << m_name; + char *tmppath = decodedString("westley:" + url.path()); + Mlt::Consumer westleyConsumer(*m_mltProfile , tmppath); + m_mltProducer->optimise(); + delete[] tmppath; + westleyConsumer.set("terminate_on_pause", 1); + if (m_name == "clip") { + Mlt::Producer *prod = m_mltProducer->cut(zone.x(), zone.y()); + tmppath = decodedString(desc); + Mlt::Playlist list; + list.insert_at(0, prod, 0); + list.set("title", tmppath); + delete[] tmppath; + westleyConsumer.connect(list); + + } else { + //TODO: not working yet, save zone from timeline + Mlt::Producer *p1 = new Mlt::Producer(m_mltProducer->get_producer()); + /* Mlt::Service service(p1->parent().get_service()); + if (service.type() != tractor_type) kWarning() << "// TRACTOR PROBLEM";*/ + + //Mlt::Producer *prod = p1->cut(zone.x(), zone.y()); + tmppath = decodedString(desc); + //prod->set("title", tmppath); + delete[] tmppath; + westleyConsumer.connect(*p1); //list); + } + + westleyConsumer.start(); +} + const double Render::fps() const { return m_fps; } @@ -2271,7 +2302,6 @@ void Render::mltSavePlaylist() { fileConsumer.connect(service); fileConsumer.start(); - } #include "renderer.moc" diff --git a/src/renderer.h b/src/renderer.h index 3624dae7..d74c5183 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -114,6 +114,8 @@ Q_OBJECT public: void playZone(const GenTime & startTime, const GenTime & stopTime); void loopZone(const GenTime & startTime, const GenTime & stopTime); + void saveZone(KUrl url, QString desc, QPoint zone); + /** Returns the name of the renderer. */ const QString & rendererName() const; -- 2.39.2