]> git.sesse.net Git - kdenlive/blobdiff - src/renderwidget.cpp
Updated Hungarian translation
[kdenlive] / src / renderwidget.cpp
index e352450c0985217c7f8baf851c0b99102fb1b4e5..8af8002bb702dad3cd7d6bcbd8b484fb154bb409 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;
@@ -156,7 +159,8 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
     m_view.out_file->setMode(KFile::File);
 
     m_view.running_jobs->setHeaderLabels(QStringList() << QString() << i18n("File") << i18n("Progress"));
-    m_view.running_jobs->setItemDelegate(new RenderViewDelegate(this));
+    m_jobsDelegate = new RenderViewDelegate(this);
+    m_view.running_jobs->setItemDelegate(m_jobsDelegate);
 
     QHeaderView *header = m_view.running_jobs->header();
     QFontMetrics fm = fontMetrics();
@@ -170,7 +174,8 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
 
 
     m_view.scripts_list->setHeaderLabels(QStringList() << QString() << i18n("Script Files"));
-    m_view.scripts_list->setItemDelegate(new RenderViewDelegate(this));
+    m_scriptsDelegate = new RenderViewDelegate(this);
+    m_view.scripts_list->setItemDelegate(m_scriptsDelegate);
     header = m_view.scripts_list->header();
     header->setResizeMode(0, QHeaderView::Fixed);
     header->resizeSection(0, 30);
@@ -183,9 +188,24 @@ 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();
 }
 
+RenderWidget::~RenderWidget()
+{
+    m_view.running_jobs->blockSignals(true);
+    m_view.scripts_list->blockSignals(true);
+    m_view.running_jobs->clear();
+    m_view.scripts_list->clear();
+    delete m_jobsDelegate;
+    delete m_scriptsDelegate;
+}
+
 void RenderWidget::slotEditItem(QListWidgetItem *item)
 {
     QString edit = item->data(EditableRole).toString();
@@ -781,7 +801,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;
@@ -791,7 +811,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);
         }
@@ -802,6 +822,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) {
@@ -809,9 +830,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) {
@@ -833,6 +856,7 @@ void RenderWidget::checkRenderStatus()
         }
         item = m_view.running_jobs->itemBelow(item);
     }
+    if (waitingJob == false && m_view.shutdown->isChecked()) emit shutdown();
 }
 
 int RenderWidget::waitingJobsCount() const
@@ -1141,6 +1165,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) {
@@ -1194,7 +1220,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");
@@ -1307,6 +1336,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);
@@ -1646,7 +1680,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);
 }