]> git.sesse.net Git - kdenlive/commitdiff
Add render zone between guides
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 25 Sep 2008 22:05:52 +0000 (22:05 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 25 Sep 2008 22:05:52 +0000 (22:05 +0000)
svn path=/branches/KDE4/; revision=2413

src/customtrackview.cpp
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/mainwindow.h
src/renderwidget.cpp
src/renderwidget.h
src/widgets/renderwidget_ui.ui

index 132d68747e52d98d416df583d3e0bb3c487ed684..c332c761152669b48de5a26c615b56b027776fd3 100644 (file)
@@ -1864,7 +1864,9 @@ void CustomTrackView::addMarker(const QString &id, const GenTime &pos, const QSt
     viewport()->update();
 }
 
-
+bool sortGuidesList(const Guide *g1 , const Guide *g2) {
+    return (*g1).position() < (*g2).position();
+}
 
 void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const QString &comment) {
     if (oldPos > GenTime() && pos > GenTime()) {
@@ -1890,6 +1892,7 @@ void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const Q
         }
         if (!found) emit displayMessage(i18n("No guide at cursor time"), ErrorMessage);
     }
+    qSort(m_guides.begin(), m_guides.end(), sortGuidesList);
     m_document->syncGuides(m_guides);
 }
 
@@ -1903,6 +1906,7 @@ bool CustomTrackView::addGuide(const GenTime pos, const QString &comment) {
     Guide *g = new Guide(this, pos, comment, m_document->fps(), m_tracksHeight * m_scene->m_tracksList.count());
     scene()->addItem(g);
     m_guides.append(g);
+    qSort(m_guides.begin(), m_guides.end(), sortGuidesList);
     m_document->syncGuides(m_guides);
     return true;
 }
index 7c35b27303625c652926ea54306459a6373fb521..50d7ea07b04dda0d1aad64bafc6676eb885a015d 100644 (file)
@@ -231,12 +231,18 @@ void KdenliveDoc::syncGuides(QList <Guide *> guides) {
     QDomElement e;
     m_guidesXml.clear();
     m_guidesXml = doc.createElement("guides");
+
     for (int i = 0; i < guides.count(); i++) {
         e = doc.createElement("guide");
         e.setAttribute("time", guides.at(i)->position().ms() / 1000);
         e.setAttribute("comment", guides.at(i)->label());
         m_guidesXml.appendChild(e);
     }
+    emit guidesUpdated();
+}
+
+QDomElement KdenliveDoc::guidesXml() const {
+    return m_guidesXml;
 }
 
 void KdenliveDoc::slotAutoSave() {
@@ -628,6 +634,10 @@ void KdenliveDoc::backupMltPlaylist() {
     if (m_render) m_scenelist = m_render->sceneList();
 }
 
+double KdenliveDoc::projectDuration() const {
+    if (m_render) return GenTime(m_render->getLength(), m_fps).ms() / 1000;
+}
+
 double KdenliveDoc::fps() const {
     return m_fps;
 }
index f62c989d6fb7ff2f283a9e18c2cf38fa2e29a8d0..17df275a0480cd9a9b91a757b055244ff4c92bb5 100644 (file)
@@ -64,6 +64,7 @@ Q_OBJECT public:
     int getProducerDuration(const QString &id);
     Render *renderer();
     QDomElement m_guidesXml;
+    QDomElement guidesXml() const;
     ClipManager *clipManager();
     void addClip(const QDomElement &elem, const QString &clipId);
     void addFolder(const QString foldername, const QString &clipId, bool edit);
@@ -103,6 +104,7 @@ Q_OBJECT public:
     void setZoom(int factor);
     int zoom() const;
     const double dar();
+    double projectDuration() const;
 
 private:
     KUrl m_url;
@@ -149,6 +151,7 @@ signals:
     /** emited when the document state has been modified (= needs saving or not) */
     void docModified(bool);
     void selectLastAddedClip(const QString &);
+    void guidesUpdated();
 };
 
 #endif
index bb8f3c122b4ca99b9fb5970760118c9e9b2dc69d..0abcd1160a5a88fa458f19b4a1ab916c8f44bada 100644 (file)
@@ -1024,7 +1024,8 @@ void MainWindow::slotEditProjectSettings() {
 void MainWindow::slotRenderProject() {
     if (!m_renderWidget) {
         m_renderWidget = new RenderWidget(this);
-        connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool)));
+        connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double)));
+        if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
     }
     /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
     if (currentTab) m_renderWidget->setTimeline(currentTab);
@@ -1032,7 +1033,7 @@ void MainWindow::slotRenderProject() {
     m_renderWidget->show();
 }
 
-void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter) {
+void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd) {
     if (dest.isEmpty()) return;
     int in;
     int out;
@@ -1049,6 +1050,9 @@ void MainWindow::slotDoRender(const QString &dest, const QString &render, const
         QStringList args;
         args << "-erase";
         if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
+        else if (guideStart != -1) {
+            args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
+        }
         if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
         QString videoPlayer = "-";
         if (playAfter) {
@@ -1103,6 +1107,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
             disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
             disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
             disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
+            disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
             disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
             disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
             disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
@@ -1154,7 +1159,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
 
     connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
     connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
-
+    connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
 
 
     connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
@@ -1200,6 +1205,10 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     m_activeDocument = doc;
 }
 
+void MainWindow::slotGuidesUpdated() {
+    if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
+}
+
 void MainWindow::slotPreferences(int page, int option) {
     //An instance of your dialog could be already created and could be
     // cached, in which case you want to display the cached dialog
index 484d538a420f9b1135bd9e7b97ca2810b4b6a5cb..568fa1042426209e020b0d298ebc45e9d90d495d 100644 (file)
@@ -193,7 +193,7 @@ private slots:
     void slotSwitchMarkersComments();
     void slotSwitchSnap();
     void slotRenderProject();
-    void slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter);
+    void slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd);
     void slotFullScreen();
     void slotUpdateDocumentState(bool modified);
     void slotZoomIn();
@@ -229,6 +229,7 @@ private slots:
     void slotEditGuide();
     void slotDeleteGuide();
     void slotDeleteAllGuides();
+    void slotGuidesUpdated();
 
     void slotCopy();
     void slotPaste();
index 8f8db8f0223892f4f8a245ade060016638657be6..39c3ca9096bb42d0937b76f9a0c33b847d4dea94 100644 (file)
@@ -57,10 +57,52 @@ RenderWidget::RenderWidget(QWidget * parent): QDialog(parent), m_standard("PAL")
     connect(m_view.format_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshView()));
     connect(m_view.size_list, SIGNAL(currentRowChanged(int)), this, SLOT(refreshParams()));
 
+    connect(m_view.render_guide, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
+    connect(m_view.render_zone, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
+    connect(m_view.render_full, SIGNAL(clicked(bool)), this, SLOT(slotUpdateGuideBox()));
+
+    connect(m_view.guide_end, SIGNAL(activated(int)), this, SLOT(slotCheckStartGuidePosition()));
+    connect(m_view.guide_start, SIGNAL(activated(int)), this, SLOT(slotCheckEndGuidePosition()));
+
+
     m_view.buttonStart->setEnabled(false);
+    m_view.guides_box->setVisible(false);
     parseProfiles();
 }
 
+void RenderWidget::slotUpdateGuideBox() {
+    m_view.guides_box->setVisible(m_view.render_guide->isChecked());
+}
+
+void RenderWidget::slotCheckStartGuidePosition() {
+    if (m_view.guide_start->currentIndex() > m_view.guide_end->currentIndex())
+        m_view.guide_start->setCurrentIndex(m_view.guide_end->currentIndex());
+}
+
+void RenderWidget::slotCheckEndGuidePosition() {
+    if (m_view.guide_end->currentIndex() < m_view.guide_start->currentIndex())
+        m_view.guide_end->setCurrentIndex(m_view.guide_start->currentIndex());
+}
+
+void RenderWidget::setGuides(QDomElement guidesxml, double duration) {
+    m_view.guide_start->clear();
+    m_view.guide_end->clear();
+    QDomNodeList nodes = guidesxml.elementsByTagName("guide");
+    if (nodes.count() > 0) {
+        m_view.guide_start->addItem(i18n("Start"), "0");
+        m_view.render_guide->setEnabled(true);
+    } else m_view.render_guide->setEnabled(false);
+    for (int i = 0; i < nodes.count(); i++) {
+        QDomElement e = nodes.item(i).toElement();
+        if (!e.isNull()) {
+            m_view.guide_start->addItem(e.attribute("comment"), e.attribute("time").toDouble());
+            m_view.guide_end->addItem(e.attribute("comment"), e.attribute("time").toDouble());
+        }
+    }
+    if (nodes.count() > 0)
+        m_view.guide_end->addItem(i18n("End"), QString::number(duration));
+}
+
 void RenderWidget::slotUpdateButtons() {
     if (m_view.out_file->url().isEmpty()) m_view.buttonStart->setEnabled(false);
     else m_view.buttonStart->setEnabled(true);
@@ -275,7 +317,13 @@ void RenderWidget::slotExport() {
         overlayargs << "-attach" << "data_feed:attr_check" << "-attach";
         overlayargs << "data_show:" + filterFile << "_fezzik=1" << "dynamic=1";
     }
-    emit doRender(m_view.out_file->url().path(), item->data(RenderRole).toString(), overlayargs, m_view.advanced_params->text().split(' '), m_view.zone_only->isChecked(), m_view.play_after->isChecked());
+    double startPos = -1;
+    double endPos = -1;
+    if (m_view.render_guide->isChecked()) {
+        startPos = m_view.guide_start->itemData(m_view.guide_start->currentIndex()).toDouble();
+        endPos = m_view.guide_end->itemData(m_view.guide_end->currentIndex()).toDouble();
+    }
+    emit doRender(m_view.out_file->url().path(), item->data(RenderRole).toString(), overlayargs, m_view.advanced_params->text().split(' '), m_view.render_zone->isChecked(), m_view.play_after->isChecked(), startPos, endPos);
 }
 
 void RenderWidget::setDocumentStandard(QString std) {
index 52f3ff79e71e2a625ff2941a00cf5b6da732edbd..8f9f3e1d2c4ce3819fd925fc7a128d743cfa7f9d 100644 (file)
@@ -32,6 +32,7 @@ class RenderWidget : public QDialog {
 public:
     RenderWidget(QWidget * parent = 0);
     void setDocumentStandard(QString std);
+    void setGuides(QDomElement guidesxml, double duration);
 
 private slots:
     void slotUpdateButtons();
@@ -41,6 +42,10 @@ private slots:
     void slotSaveProfile();
     void slotEditProfile();
     void slotDeleteProfile();
+    void slotUpdateGuideBox();
+    void slotCheckStartGuidePosition();
+    void slotCheckEndGuidePosition();
+
 
 private:
     Ui::RenderWidget_UI m_view;
@@ -49,7 +54,7 @@ private:
     void parseFile(QString exportFile, bool editable);
 
 signals:
-    void doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool);
+    void doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double);
 };
 
 
index 7f2b8bc272aebd920139aee7657afc246a2ee595..e149b1b5fcb06d26e052177084ee83b1772b6111 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>340</width>
-    <height>339</height>
+    <width>424</width>
+    <height>381</height>
    </rect>
   </property>
   <property name="windowTitle" >
      </property>
     </widget>
    </item>
-   <item row="0" column="1" colspan="3" >
+   <item row="0" column="1" colspan="2" >
     <widget class="KUrlRequester" name="out_file" />
    </item>
-   <item row="2" column="0" colspan="3" >
-    <widget class="QCheckBox" name="zone_only" >
-     <property name="text" >
-      <string>Selected zone only</string>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="3" >
-    <widget class="QCheckBox" name="play_after" >
-     <property name="text" >
-      <string>Play after render</string>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="0" >
-    <widget class="KPushButton" name="buttonStart" >
-     <property name="text" >
-      <string>Start</string>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="1" >
-    <spacer name="horizontalSpacer" >
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" stdset="0" >
-      <size>
-       <width>153</width>
-       <height>27</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="4" column="2" colspan="2" >
-    <widget class="QDialogButtonBox" name="buttonBox" >
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons" >
-      <set>QDialogButtonBox::Close</set>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="0" colspan="4" >
+   <item row="1" column="0" colspan="3" >
     <widget class="KTabWidget" name="ktabwidget" >
      <property name="currentIndex" >
       <number>0</number>
      </widget>
     </widget>
    </item>
-   <item row="3" column="0" colspan="2" >
-    <widget class="QCheckBox" name="tc_overlay" >
+   <item row="2" column="0" colspan="2" >
+    <layout class="QHBoxLayout" name="horizontalLayout" >
+     <item>
+      <widget class="QRadioButton" name="render_full" >
+       <property name="text" >
+        <string>Full project</string>
+       </property>
+       <property name="checked" >
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QRadioButton" name="render_zone" >
+       <property name="text" >
+        <string>Selected zone</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QRadioButton" name="render_guide" >
+       <property name="text" >
+        <string>Guide zone</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="3" column="0" colspan="3" >
+    <widget class="QGroupBox" name="guides_box" >
+     <property name="title" >
+      <string/>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_2" >
+      <item row="0" column="0" >
+       <widget class="QLabel" name="label_4" >
+        <property name="text" >
+         <string>From</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" >
+       <widget class="KComboBox" name="guide_start" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2" >
+       <widget class="QLabel" name="label_2" >
+        <property name="text" >
+         <string>to</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="3" >
+       <widget class="KComboBox" name="guide_end" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="4" column="0" colspan="3" >
+    <layout class="QHBoxLayout" name="horizontalLayout_3" >
+     <item>
+      <widget class="QCheckBox" name="play_after" >
+       <property name="text" >
+        <string>Play after render</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="tc_overlay" >
+       <property name="text" >
+        <string>Timecode overlay</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="5" column="0" >
+    <widget class="KPushButton" name="buttonStart" >
      <property name="text" >
-      <string>Timecode overlay</string>
+      <string>Start</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="1" >
+    <spacer name="horizontalSpacer" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>153</width>
+       <height>27</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="5" column="2" >
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Close</set>
      </property>
     </widget>
    </item>
   </layout>
  </widget>
  <customwidgets>
+  <customwidget>
+   <class>KComboBox</class>
+   <extends>QComboBox</extends>
+   <header>kcombobox.h</header>
+  </customwidget>
   <customwidget>
    <class>KLineEdit</class>
    <extends>QLineEdit</extends>