]> git.sesse.net Git - kdenlive/blobdiff - src/renderwidget.cpp
reindent
[kdenlive] / src / renderwidget.cpp
index afd745ef13384bc884af2b78a2ed8907ea3a29f2..f9468a82df7e7ac61a617a9870bc1959fe0ca62d 100644 (file)
@@ -200,10 +200,13 @@ void RenderWidget::showInfoPanel()
 
 void RenderWidget::setDocumentPath(const QString path)
 {
+    if (m_view.out_file->url().directory() == KUrl(m_projectFolder).directory()) {
+        const QString fileName = m_view.out_file->url().fileName();
+        m_view.out_file->setUrl(KUrl(path + fileName));
+    }
     m_projectFolder = path;
-    const QString fileName = m_view.out_file->url().fileName();
-    m_view.out_file->setUrl(KUrl(m_projectFolder + fileName));
     parseScriptFiles();
+
 }
 
 void RenderWidget::slotUpdateGuideBox()
@@ -591,6 +594,10 @@ void RenderWidget::slotPrepareExport(bool scriptExport)
         KMessageBox::sorry(this, i18n("Cannot play video after rendering because the default video player application is not set.\nPlease define it in Kdenlive settings dialog."));
     QString chapterFile;
     if (m_view.create_chapter->isChecked()) chapterFile = m_view.out_file->url().path() + ".dvdchapter";
+
+    // mantisbt 1051
+    KStandardDirs::makeDir(m_view.out_file->url().directory());
+
     emit prepareRenderingData(scriptExport, m_view.render_zone->isChecked(), chapterFile);
 }
 
@@ -606,7 +613,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     // Check whether target file has an extension.
     // If not, ask whether extension should be added or not.
     QString extension = item->data(ExtensionRole).toString();
-    if (!dest.endsWith(extension)) {
+    if (!dest.endsWith(extension, Qt::CaseInsensitive)) {
         if (KMessageBox::questionYesNo(this, i18n("File has no extension. Add extension (%1)?", extension)) == KMessageBox::Yes) {
             dest.append("." + extension);
         }
@@ -642,7 +649,8 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
         render_process_args << "in=" + QString::number(GenTime(guideStart).frames(fps)) << "out=" + QString::number(GenTime(guideEnd).frames(fps));
     }
 
-    render_process_args << overlayargs;
+    if (!overlayargs.isEmpty()) render_process_args << "preargs=" + overlayargs.join(" ");
+
     render_process_args << KdenliveSettings::rendererpath() << m_profile.path << item->data(RenderRole).toString();
     if (m_view.play_after->isChecked()) render_process_args << KdenliveSettings::KdenliveSettings::defaultplayerapp();
     else render_process_args << "-";
@@ -741,7 +749,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     m_view.tabWidget->setCurrentIndex(1);
 
     // Save rendering profile to document
-    emit selectedRenderProfile(m_view.size_list->currentItem()->data(MetaGroupRole).toString(), m_view.size_list->currentItem()->text());
+    emit selectedRenderProfile(m_view.size_list->currentItem()->data(MetaGroupRole).toString(), m_view.size_list->currentItem()->text(), dest);
 
     // insert item in running jobs list
     QTreeWidgetItem *renderItem;
@@ -928,7 +936,6 @@ void RenderWidget::refreshView()
             if (!sizeItem->isHidden()) {
                 // Make sure the selected profile uses an installed avformat codec / format
                 std = sizeItem->data(ParamsRole).toString();
-
                 if (!formatsList.isEmpty()) {
                     QString format;
                     if (std.startsWith("f=")) format = std.section("f=", 1, 1);
@@ -988,17 +995,24 @@ void RenderWidget::refreshView()
 
 KUrl RenderWidget::filenameWithExtension(KUrl url, QString extension)
 {
-    QString path;
-    if (!url.isEmpty()) {
-        path = url.path();
-        int pos = path.lastIndexOf('.') + 1;
-        if (pos == 0) path.append('.' + extension);
-        else path = path.left(pos) + extension;
+    QString directory = url.directory(KUrl::AppendTrailingSlash | KUrl::ObeyTrailingSlash);
+    QString filename = url.fileName(KUrl::ObeyTrailingSlash);
+    QString ext;
 
-    } else {
-        path = m_projectFolder + "untitled." + extension;
+    if (extension.at(0) == '.') ext = extension;
+    else ext = '.' + extension;
+
+    if (filename.isEmpty()) filename = i18n("untitled");
+
+    int pos = filename.lastIndexOf('.');
+    if (pos == 0) filename.append(ext);
+    else {
+        if (!filename.endsWith(ext, Qt::CaseInsensitive)) {
+            filename = filename.left(pos) + ext;
+        }
     }
-    return KUrl(path);
+
+    return KUrl(directory + filename);
 }
 
 
@@ -1119,6 +1133,11 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
     QListWidgetItem *item;
     QDomNodeList groups = doc.elementsByTagName("group");
 
+    const QStringList acodecsList = KdenliveSettings::audiocodecs();
+    bool replaceVorbisCodec = false;
+    if (!acodecsList.contains("vorbis") && acodecsList.contains("libvorbis")) replaceVorbisCodec = true;
+
+
     if (editable || groups.count() == 0) {
         QDomElement profiles = doc.documentElement();
         if (editable && profiles.attribute("version", 0).toInt() < 1) {
@@ -1165,6 +1184,13 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
             QString profileName = profile.attribute("name");
             QString standard = profile.attribute("standard");
             QString params = profile.attribute("args");
+
+            if (replaceVorbisCodec && params.contains("acodec=vorbis")) {
+                // replace vorbis with libvorbis
+                params = params.replace("vorbis", "libvorbis");
+            }
+
+
             QString category = profile.attribute("category", i18n("Custom"));
             QString dest = profile.attribute("destinationid");
             QString prof_extension = profile.attribute("extension");
@@ -1234,7 +1260,8 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
         if (!gname.isNull()) {
             metagroupName = gname.firstChild().nodeValue();
             metagroupId = gname.toElement().attribute("id");
-            if (!metagroupName.isEmpty() && !m_view.destination_list->contains(metagroupName)) {
+
+            if (!metagroupName.isEmpty() && m_view.destination_list->findData(metagroupId) == -1) {
                 if (metagroupId == "dvd") icon = KIcon("media-optical");
                 else if (metagroupId == "audioonly") icon = KIcon("audio-x-generic");
                 else if (metagroupId == "websites") icon = KIcon("applications-internet");
@@ -1270,6 +1297,11 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
             profileName = profileElement.attribute("name");
             standard = profileElement.attribute("standard");
             params = profileElement.attribute("args");
+
+            if (replaceVorbisCodec && params.contains("acodec=vorbis")) {
+                // replace vorbis with libvorbis
+                params = params.replace("vorbis", "libvorbis");
+            }
             prof_extension = profileElement.attribute("extension");
             if (!prof_extension.isEmpty()) extension = prof_extension;
             item = new QListWidgetItem(profileName, m_view.size_list);
@@ -1519,11 +1551,14 @@ void RenderWidget::slotHideLog()
     m_view.error_box->setVisible(false);
 }
 
-void RenderWidget::setRenderProfile(const QString &dest, const QString &name)
+void RenderWidget::setRenderProfile(const QString &dest, const QString &name, const QString &url)
 {
     m_view.destination_list->blockSignals(true);
     m_view.format_list->blockSignals(true);
     m_view.size_list->blockSignals(true);
+
+    if (!url.isEmpty()) m_view.out_file->setUrl(KUrl(url));
+
     for (int i = 0; i < m_view.destination_list->count(); i++) {
         if (m_view.destination_list->itemData(i, Qt::UserRole) == dest) {
             m_view.destination_list->setCurrentIndex(i);