]> git.sesse.net Git - kdenlive/blobdiff - src/renderwidget.cpp
First draft for keyframes in frei0r effects
[kdenlive] / src / renderwidget.cpp
index dc3db831a4ff68efe13c5c923d03bcd7caf82562..fc011e23d67c43bdc009aa35380665ead8983159 100644 (file)
@@ -31,6 +31,7 @@
 #include <KIO/NetAccess>
 #include <KColorScheme>
 #include <KNotification>
+#include <KStartupInfo>
 // #include <knewstuff2/engine.h>
 
 #include <QDomDocument>
 #include <QListWidgetItem>
 #include <QHeaderView>
 #include <QMenu>
-#include <QProcess>
 #include <QInputDialog>
+#include <QProcess>
+#include <QDBusConnectionInterface>
+#include <QDBusInterface>
 
 const int GroupRole = Qt::UserRole;
 const int ExtensionRole = GroupRole + 1;
@@ -185,6 +188,11 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
         if (m_renderer.isEmpty()) m_renderer = "kdenlive_render";
     }
 
+    QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
+    if (!interface || !interface->isServiceRegistered("org.kde.ksmserver")) {
+        m_view.shutdown->setEnabled(false);
+    }
+
     focusFirstVisibleItem();
 }
 
@@ -286,6 +294,10 @@ void RenderWidget::slotUpdateButtons(KUrl url)
     }
     if (url != 0) {
         QListWidgetItem *item = m_view.size_list->currentItem();
+        if (!item) {
+            m_view.buttonStart->setEnabled(false);
+            return;
+        }
         QString extension = item->data(ExtensionRole).toString();
         url = filenameWithExtension(url, extension);
         m_view.out_file->setUrl(url);
@@ -793,7 +805,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
         if (m_view.open_dvd->isChecked()) {
             renderItem->setData(0, Qt::UserRole, group);
             if (renderArgs.contains("profile=")) {
-                // rendering profile contains an MLT profile, so pass it to the running jog item, useful for dvd
+                // rendering profile contains an MLT profile, so pass it to the running jog item, useful for dvd
                 QString prof = renderArgs.section("profile=", 1, 1);
                 prof = prof.section(' ', 0, 0);
                 kDebug() << "// render profile: " << prof;
@@ -803,7 +815,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
     } else {
         if (group == "websites" && m_view.open_browser->isChecked()) {
             renderItem->setData(0, Qt::UserRole, group);
-            // pass the url
+            // pass the url
             QString url = m_view.size_list->currentItem()->data(ExtraRole).toString();
             renderItem->setData(0, Qt::UserRole + 1, url);
         }
@@ -814,6 +826,7 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
 
 void RenderWidget::checkRenderStatus()
 {
+    // check if we have a job waiting to render
     if (m_blockProcessing) return;
     QTreeWidgetItem *item = m_view.running_jobs->topLevelItem(0);
     while (item) {
@@ -821,9 +834,11 @@ void RenderWidget::checkRenderStatus()
         item = m_view.running_jobs->itemBelow(item);
     }
     item = m_view.running_jobs->topLevelItem(0);
+    bool waitingJob = false;
     while (item) {
         if (item->data(1, Qt::UserRole + 2).toInt() == WAITINGJOB) {
             item->setData(1, Qt::UserRole + 1, QTime::currentTime());
+            waitingJob = true;
             if (item->data(1, Qt::UserRole + 4).isNull()) {
                 // Normal render process
                 if (QProcess::startDetached(m_renderer, item->data(1, Qt::UserRole + 3).toStringList()) == false) {
@@ -845,6 +860,7 @@ void RenderWidget::checkRenderStatus()
         }
         item = m_view.running_jobs->itemBelow(item);
     }
+    if (waitingJob == false && m_view.shutdown->isChecked()) emit shutdown();
 }
 
 int RenderWidget::waitingJobsCount() const
@@ -1153,6 +1169,8 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
     const QStringList acodecsList = KdenliveSettings::audiocodecs();
     bool replaceVorbisCodec = false;
     if (!acodecsList.contains("vorbis") && acodecsList.contains("libvorbis")) replaceVorbisCodec = true;
+    bool replaceLibfaacCodec = false;
+    if (!acodecsList.contains("libfaac") && acodecsList.contains("aac")) replaceLibfaacCodec = true;
 
 
     if (editable || groups.count() == 0) {
@@ -1206,7 +1224,10 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
                 // replace vorbis with libvorbis
                 params = params.replace("vorbis", "libvorbis");
             }
-
+            if (replaceLibfaacCodec && params.contains("acodec=libfaac")) {
+                // replace libfaac with aac
+                params = params.replace("libfaac", "aac");
+            }
 
             QString category = profile.attribute("category", i18n("Custom"));
             QString dest = profile.attribute("destinationid");
@@ -1319,6 +1340,11 @@ void RenderWidget::parseFile(QString exportFile, bool editable)
                 // replace vorbis with libvorbis
                 params = params.replace("vorbis", "libvorbis");
             }
+            if (replaceLibfaacCodec && params.contains("acodec=libfaac")) {
+                // replace libfaac with aac
+                params = params.replace("libfaac", "aac");
+            }
+
             prof_extension = profileElement.attribute("extension");
             if (!prof_extension.isEmpty()) extension = prof_extension;
             item = new QListWidgetItem(profileName, m_view.size_list);
@@ -1658,7 +1684,9 @@ QString RenderWidget::getFreeScriptName(const QString &prefix)
 void RenderWidget::slotPlayRendering(QTreeWidgetItem *item, int)
 {
     if (KdenliveSettings::defaultplayerapp().isEmpty() || item->data(1, Qt::UserRole + 2).toInt() != FINISHEDJOB) return;
-    QProcess::startDetached(KdenliveSettings::defaultplayerapp(), QStringList() << item->text(1));
+    const QByteArray startId = KStartupInfo::createNewStartupId();
+    const QString command = KdenliveSettings::defaultplayerapp() + ' ' + item->text(1);
+    KRun::runCommand(command, KdenliveSettings::defaultplayerapp(), KdenliveSettings::defaultplayerapp(), this, startId);
 }