]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Inform user when no render profile is available (usually because frame rate not matching)
[kdenlive] / src / mainwindow.cpp
index e72108fe541a3596ed3627f5801d8e4e1ab62329..e01b5e259611a91ee4d51f05a861fc7ca7617b71 100644 (file)
 #include "renderwidget.h"
 #include "renderer.h"
 #include "audiosignal.h"
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
 #include "jogshuttle.h"
 #include "jogaction.h"
 #include "jogshuttleconfig.h"
-#endif /* NO_JOGSHUTTLE */
+#endif
 #include "clipproperties.h"
 #include "wizard.h"
-#include "editclipcommand.h"
+#include "commands/editclipcommand.h"
 #include "titlewidget.h"
 #include "markerdialog.h"
 #include "clipitem.h"
 #include "interfaces.h"
-#include "kdenlive-config.h"
+#include "config-kdenlive.h"
 #include "cliptranscode.h"
 #include "ui_templateclip_ui.h"
 #include "colorscopes/vectorscope.h"
 #include "colorscopes/waveform.h"
 #include "colorscopes/rgbparade.h"
 #include "colorscopes/histogram.h"
-#include "audiospectrum.h"
-#include "spectrogram.h"
+#include "audioscopes/audiospectrum.h"
+#include "audioscopes/spectrogram.h"
 #include "archivewidget.h"
 #include "databackup/backupwidget.h"
 
+
 #include <KApplication>
 #include <KAction>
 #include <KLocale>
@@ -98,7 +99,7 @@
 #include <knewstuff2/engine.h>
 #include <knewstuff2/ui/knewstuffaction.h>
 #define KNS3 KNS
-#endif /* KDE_IS_VERSION(4,3,80) */
+#endif
 #include <KToolBar>
 #include <KColorScheme>
 #include <KProgressDialog>
@@ -142,10 +143,10 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     m_activeTimeline(NULL),
     m_recMonitor(NULL),
     m_renderWidget(NULL),
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
     m_jogProcess(NULL),
     m_jogShuttle(NULL),
-#endif /* NO_JOGSHUTTLE */
+#endif
     m_findActivated(false),
     m_stopmotion(NULL)
 {   
@@ -181,7 +182,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     closeTabButton->adjustSize();
     closeTabButton->setToolTip(i18n("Close the current tab"));
     m_timelineArea->setCornerWidget(closeTabButton);
-    connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
+    //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
 
     connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
     m_findTimer.setSingleShot(true);
@@ -208,9 +209,19 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     m_clipMonitorDock->setObjectName("clip_monitor");
     m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
     m_clipMonitorDock->setWidget(m_clipMonitor);
+    
+    // Connect the project list
     connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint)));
     connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(activateMonitor()));
-    
+    connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
+    connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
+    connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
+    connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
+    connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
+    connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
+    connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
+    connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
+
     m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
     m_projectMonitorDock->setObjectName("project_monitor");
     m_projectMonitor = new Monitor("project", m_monitorManager, QString());
@@ -224,7 +235,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
     connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
     connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
-#endif
+#endif /* ! Q_WS_MAC */
     m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
 
     m_notesDock = new QDockWidget(i18n("Project Notes"), this);
@@ -574,7 +585,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
 
     connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
     connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
-    //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
     connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
     connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
     connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
@@ -605,13 +615,49 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
         m_projectList->slotAddClip(urls);
     }
 
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
     activateShuttleDevice();
-#endif /* NO_JOGSHUTTLE */
+#endif
     m_projectListDock->raise();
 
     actionCollection()->addAssociatedWidget(m_clipMonitor->container());
     actionCollection()->addAssociatedWidget(m_projectMonitor->container());
+    
+    // Populate encoding profiles
+    KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
+    if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
+        KConfigGroup group(&conf, "proxy");
+        QMap< QString, QString > values = group.entryMap();
+        QMapIterator<QString, QString> i(values);
+        if (i.hasNext()) {
+            i.next();
+            QString data = i.value();
+            KdenliveSettings::setProxyparams(data.section(';', 0, 0));
+            KdenliveSettings::setProxyextension(data.section(';', 1, 1));
+        }
+    }
+    if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
+        KConfigGroup group(&conf, "video4linux");
+        QMap< QString, QString > values = group.entryMap();
+        QMapIterator<QString, QString> i(values);
+        if (i.hasNext()) {
+            i.next();
+            QString data = i.value();
+            KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
+            KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
+        }
+    }
+    if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
+        KConfigGroup group(&conf, "decklink");
+        QMap< QString, QString > values = group.entryMap();
+        QMapIterator<QString, QString> i(values);
+        if (i.hasNext()) {
+            i.next();
+            QString data = i.value();
+            KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
+            KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
+        }
+    }
 }
 
 MainWindow::~MainWindow()
@@ -783,7 +829,7 @@ void MainWindow::slotReloadEffects()
     m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
 }
 
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
 void MainWindow::activateShuttleDevice()
 {
     delete m_jogShuttle;
@@ -801,7 +847,7 @@ void MainWindow::activateShuttleDevice()
     connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
     connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
 }
-#endif /* NO_JOGSHUTTLE */
+#endif /* USE_JOGSHUTTLE */
 
 void MainWindow::slotDoAction(const QString& action_name)
 {
@@ -1778,14 +1824,6 @@ void MainWindow::newFile(bool showProjectSettings, bool force)
     QMap <QString, QString> documentProperties;
     QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
     if (!showProjectSettings) {
-        // set up default properties
-        documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
-        documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
-        documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
-        documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
-        documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
-        documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
-        documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
         if (!KdenliveSettings::activatetabs())
             if (!closeCurrentDocument())
                 return;
@@ -1874,6 +1912,7 @@ bool MainWindow::closeCurrentDocument(bool saveChanges)
         }
     }
     m_clipMonitor->slotSetClipProducer(NULL);
+    m_projectList->slotResetProjectList();
     m_timelineArea->removeTab(m_timelineArea->indexOf(w));
     if (m_timelineArea->count() == 1) {
         m_timelineArea->setTabBarHidden(true);
@@ -2070,7 +2109,7 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
 
     bool ok;
     TrackView *trackView = new TrackView(doc, &ok, this);
-
+    connectDocument(trackView, doc);
     progressDialog.progressBar()->setValue(3);
     qApp->processEvents();
 
@@ -2091,8 +2130,6 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
     slotGotProgressInfo(QString(), -1);
     m_projectMonitor->adjustRulerSize(trackView->duration());
     m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
-    m_clipMonitor->refreshMonitor(true);
-
     progressDialog.progressBar()->setValue(4);
     if (openBackup) slotOpenBackupDialog(url);
 }
@@ -2223,7 +2260,7 @@ void MainWindow::slotEditProjectSettings()
     if (w->exec() == QDialog::Accepted) {
         QString profile = w->selectedProfile();
         m_activeDocument->setProjectFolder(w->selectedFolder());
-#ifndef   Q_WS_MAC
+#ifndef Q_WS_MAC
         m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
 #endif
         if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
@@ -2314,7 +2351,9 @@ void MainWindow::slotRenderProject()
 {
     if (!m_renderWidget) {
         QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
-        m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
+        MltVideoProfile profile;
+        if (m_activeDocument) profile = m_activeDocument->mltProfile();
+        m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
         connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
         connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
         connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
@@ -2412,7 +2451,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
             disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
             disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
             disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
-            disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
 
             disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
 
@@ -2448,33 +2486,24 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
             disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
             disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
             disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
-            disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
-            disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
-            disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&)), this, SLOT(slotUpdateClip(const QString &)));
             disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
             m_effectStack->clear();
         }
         //m_activeDocument->setRenderer(NULL);
-        disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
         m_clipMonitor->stop();
     }
     KdenliveSettings::setCurrent_profile(doc->profilePath());
     KdenliveSettings::setProject_fps(doc->fps());
     m_monitorManager->resetProfiles(doc->timecode());
+    m_clipMonitorDock->raise();
     m_projectList->setDocument(doc);
     m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
     m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
-    connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
     connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
-    connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
 
     connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
-    connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
     connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
 
-    connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
-
-
     //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
     connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
     connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
@@ -2484,7 +2513,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
     connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
     connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
-    connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
     connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
     connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
     connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
@@ -2537,9 +2565,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
     connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
     connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
-    connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
-    connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
-    connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
 
 
     trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
@@ -2566,11 +2591,12 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     m_activeDocument = doc;
     m_activeTimeline->updateProjectFps();
     m_activeDocument->checkProjectClips();
-#ifndef   Q_WS_MAC
+#ifndef Q_WS_MAC
     m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
 #endif
     //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
     slotUpdateMousePosition(0);
+    m_monitorManager->activateMonitor("clip");
     // set tool to select tool
     m_buttonSelectTool->setChecked(true);
 }
@@ -2632,7 +2658,7 @@ void MainWindow::slotPreferences(int page, int option)
 void MainWindow::slotUpdateCaptureFolder()
 {
 
-#ifndef   Q_WS_MAC
+#ifndef Q_WS_MAC
     if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
     else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
 #endif
@@ -2655,9 +2681,9 @@ void MainWindow::updateConfiguration()
 
     // Update list of transcoding profiles
     loadTranscoders();
-#ifndef NO_JOGSHUTTLE
+#ifdef USE_JOGSHUTTLE
     activateShuttleDevice();
-#endif /* NO_JOGSHUTTLE */
+#endif
 
 }
 
@@ -3661,7 +3687,7 @@ int MainWindow::getNewStuff(const QString &configFile)
         if (entry->status() == KNS::Entry::Installed)
             kDebug() << "// Installed files: " << entry->installedFiles();
     }
-#endif /* KDE_IS_VERSION(4,3,80) */
+#endif
     return entries.size();
 }
 
@@ -3937,6 +3963,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
                     // We need to delete the "aspect_ratio" property because proxy clips
                     // sometimes have different ratio than original clips
                     EffectsList::removeProperty(e, "aspect_ratio");
+                    EffectsList::removeMetaProperties(e);
                 }
             }
         }