]> git.sesse.net Git - kdenlive/commitdiff
Allow %width, %height and %dar as placeholders for rendering profiles:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 10 Nov 2008 12:10:07 +0000 (12:10 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 10 Nov 2008 12:10:07 +0000 (12:10 +0000)
http://www.kdenlive.org/mantis/view.php?id=323

svn path=/branches/KDE4/; revision=2650

src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/renderwidget.cpp
src/renderwidget.h

index 1aae9a10a9ed5cfc863eda787feda6e95abb0c6b..5d7c6077d172ad583a3a26c0c5aeaa48f0cce0b0 100644 (file)
@@ -532,12 +532,12 @@ void KdenliveDoc::convertDocument(double version) {
                             content.setAttribute("font-color", colorToString(c));
                             // todo: These fields are missing from the newly generated xmldata:
                             // transform, startviewport, endviewport, background
-                            
+
                             QDomText conttxt = tdoc.createTextNode(ob.attribute("text"));
                             content.appendChild(conttxt);
                             item.appendChild(position);
                             item.appendChild(content);
-                            title.appendChild(item);                            
+                            title.appendChild(item);
                         } else if (ob.attribute("type") == "5") {
                             // rectangle object
                             QDomElement item = tdoc.createElement("item");
@@ -607,25 +607,25 @@ void KdenliveDoc::convertDocument(double version) {
             if (wproducer.isNull()) {
                 kWarning() << "Found producer in westley0, that was not a QDomElement";
             } else {
-              // We have to do slightly different things, depending on the type
-              kDebug() << "Converting producer element with type " << wproducer.attribute("type");
-              if ( wproducer.attribute("type").toInt() == TEXT ) {
-                kDebug() << "Found TEXT element in producer" << endl;
-                QDomElement kproducer = wproducer.cloneNode(true).toElement();
-                kproducer.setTagName("kdenlive_producer"); 
-                kdenlivedoc_new.appendChild(kproducer);
-                // todo: Perhaps needs some more changes here to "frequency", aspect ratio as a float, frame_size, channels, and later, ressource and title name
-              } else {
-                QDomElement kproducer = m_document.createElement("kdenlive_producer");
-                kproducer.setAttribute("id", wproducer.attribute("id"));
-                kproducer.setAttribute("description", wproducer.attribute("description"));
-                kproducer.setAttribute("resource", wproducer.attribute("resource"));
-                kproducer.setAttribute("type", wproducer.attribute("type"));
-                kdenlivedoc_new.appendChild(kproducer);
-              }
-              if (wproducer.attribute("id").toInt() > max_kproducer_id) {
-                  max_kproducer_id = wproducer.attribute("id").toInt();
-              }
+                // We have to do slightly different things, depending on the type
+                kDebug() << "Converting producer element with type " << wproducer.attribute("type");
+                if (wproducer.attribute("type").toInt() == TEXT) {
+                    kDebug() << "Found TEXT element in producer" << endl;
+                    QDomElement kproducer = wproducer.cloneNode(true).toElement();
+                    kproducer.setTagName("kdenlive_producer");
+                    kdenlivedoc_new.appendChild(kproducer);
+                    // todo: Perhaps needs some more changes here to "frequency", aspect ratio as a float, frame_size, channels, and later, ressource and title name
+                } else {
+                    QDomElement kproducer = m_document.createElement("kdenlive_producer");
+                    kproducer.setAttribute("id", wproducer.attribute("id"));
+                    kproducer.setAttribute("description", wproducer.attribute("description"));
+                    kproducer.setAttribute("resource", wproducer.attribute("resource"));
+                    kproducer.setAttribute("type", wproducer.attribute("type"));
+                    kdenlivedoc_new.appendChild(kproducer);
+                }
+                if (wproducer.attribute("id").toInt() > max_kproducer_id) {
+                    max_kproducer_id = wproducer.attribute("id").toInt();
+                }
             }
         }
     }
@@ -784,12 +784,6 @@ KUrl KdenliveDoc::projectFolder() const {
     return m_projectFolder;
 }
 
-QString KdenliveDoc::getDocumentStandard() {
-    //WARNING: this way to tell the video standard is a bit hackish...
-    if (m_profile.description.contains("pal", Qt::CaseInsensitive) || m_profile.description.contains("25", Qt::CaseInsensitive) || m_profile.description.contains("50", Qt::CaseInsensitive)) return "PAL";
-    return "NTSC";
-}
-
 QString KdenliveDoc::profilePath() const {
     return m_profile.path;
 }
index f301c4330b3008834e7ffd9045d25b2bf23744f0..cae8843905b2345d27f30813815a5544fd9bcefc 100644 (file)
@@ -88,8 +88,6 @@ Q_OBJECT public:
     QString profilePath() const;
     MltVideoProfile mltProfile() const;
     QString description() const;
-    /** Returns the document format: PAL or NTSC */
-    QString getDocumentStandard();
     void setUrl(KUrl url);
     QDomElement documentInfoXml();
     void setProfilePath(QString path);
index 4ce338028462ce39425ee063f3b8752dc92d3a98..347c39c10b0a206399fcd6483d0e418060a64561 100644 (file)
@@ -1137,7 +1137,7 @@ void MainWindow::slotEditProjectSettings() {
         KdenliveSettings::setProject_fps(m_activeDocument->fps());
         setCaption(m_activeDocument->description(), m_activeDocument->isModified());
         m_monitorManager->resetProfiles(m_activeDocument->timecode());
-        if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
+        if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
         m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
 
         // We need to desactivate & reactivate monitors to get a refresh
@@ -1151,7 +1151,7 @@ void MainWindow::slotRenderProject() {
         m_renderWidget = new RenderWidget(this);
         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->setDocumentStandard(m_activeDocument->getDocumentStandard());
+            m_renderWidget->setProfile(m_activeDocument->mltProfile());
             m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
         }
     }
@@ -1328,7 +1328,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
 
     trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
     m_activeTimeline = trackView;
-    if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
+    if (m_renderWidget) m_renderWidget->setProfile(doc->mltProfile());
     doc->setRenderer(m_projectMonitor->render);
     m_commandStack->setActiveStack(doc->commandStack());
     KdenliveSettings::setProject_display_ratio(doc->dar());
index d6c9474c26c56c9485a5ebdb965c5fb5c2ec0f34..2db066ebcddd3f8b6a1b084451233664dbdd6697 100644 (file)
@@ -361,13 +361,18 @@ void RenderWidget::slotExport() {
         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->toPlainText().split(' '), m_view.render_zone->isChecked(), m_view.play_after->isChecked(), startPos, endPos);
+    QString renderArgs = m_view.advanced_params->toPlainText();
+    renderArgs.replace("%width", QString::number(m_profile.width));
+    renderArgs.replace("%height", QString::number(m_profile.height));
+    renderArgs.replace("%dar", QString::number((double) m_profile.display_aspect_num / m_profile.display_aspect_den));
+    emit doRender(m_view.out_file->url().path(), item->data(RenderRole).toString(), overlayargs, renderArgs.split(' '), m_view.render_zone->isChecked(), m_view.play_after->isChecked(), startPos, endPos);
 }
 
-void RenderWidget::setDocumentStandard(QString std) {
-    if (std == "PAL") m_view.format_selection->setCurrentIndex(0);
+void RenderWidget::setProfile(MltVideoProfile profile) {
+    m_profile = profile;
+    //WARNING: this way to tell the video standard is a bit hackish...
+    if (m_profile.description.contains("pal", Qt::CaseInsensitive) || m_profile.description.contains("25", Qt::CaseInsensitive) || m_profile.description.contains("50", Qt::CaseInsensitive)) m_view.format_selection->setCurrentIndex(0);
     else m_view.format_selection->setCurrentIndex(1);
-
     refreshView();
 }
 
index 1acf590ed249ded28ce76f620e09d9999a82273b..a39259275c44b482892d94fff7b10d026e0c6fbd 100644 (file)
@@ -24,6 +24,7 @@
 #include <QDialog>
 #include <QPushButton>
 
+#include "definitions.h"
 #include "ui_renderwidget_ui.h"
 
 class RenderWidget : public QDialog {
@@ -31,9 +32,9 @@ class RenderWidget : public QDialog {
 
 public:
     RenderWidget(QWidget * parent = 0);
-    void setDocumentStandard(QString std);
     void setGuides(QDomElement guidesxml, double duration);
     void focusFirstVisibleItem();
+    void setProfile(MltVideoProfile profile);
 
 private slots:
     void slotUpdateButtons();
@@ -50,6 +51,7 @@ private slots:
 
 private:
     Ui::RenderWidget_UI m_view;
+    MltVideoProfile m_profile;
     void parseProfiles(QString group = QString(), QString profile = QString());
     void parseFile(QString exportFile, bool editable);