From d3e0b836c07dc05ced4bd8b8cbc224412f4ce2bf Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 10 Nov 2008 12:10:07 +0000 Subject: [PATCH] Allow %width, %height and %dar as placeholders for rendering profiles: http://www.kdenlive.org/mantis/view.php?id=323 svn path=/branches/KDE4/; revision=2650 --- src/kdenlivedoc.cpp | 48 +++++++++++++++++++------------------------- src/kdenlivedoc.h | 2 -- src/mainwindow.cpp | 6 +++--- src/renderwidget.cpp | 13 ++++++++---- src/renderwidget.h | 4 +++- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 1aae9a10..5d7c6077 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -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; } diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index f301c433..cae88439 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4ce33802..347c39c1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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()); diff --git a/src/renderwidget.cpp b/src/renderwidget.cpp index d6c9474c..2db066eb 100644 --- a/src/renderwidget.cpp +++ b/src/renderwidget.cpp @@ -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(); } diff --git a/src/renderwidget.h b/src/renderwidget.h index 1acf590e..a3925927 100644 --- a/src/renderwidget.h +++ b/src/renderwidget.h @@ -24,6 +24,7 @@ #include #include +#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); -- 2.39.2