]> git.sesse.net Git - kdenlive/blobdiff - src/monitormanager.cpp
Cleaning code style of Definitions.
[kdenlive] / src / monitormanager.cpp
index 8d0d2341b83929e018a35c8de7f50efd1cd09201..b05b1da42791e15db987f4adca00546ee0e7613d 100644 (file)
@@ -21,6 +21,7 @@
 #include "monitormanager.h"
 #include "renderer.h"
 #include "kdenlivesettings.h"
+#include "kdenlivedoc.h"
 
 #include <mlt++/Mlt.h>
 
 #include <QTimer>
 #include <KDebug>
 
+
 MonitorManager::MonitorManager(QWidget *parent) :
         QObject(parent),
+        m_document(NULL),
         m_clipMonitor(NULL),
         m_projectMonitor(NULL),
         m_activeMonitor(NULL)
 {
 }
 
-Timecode MonitorManager::timecode()
+Timecode MonitorManager::timecode() const
 {
     return m_timecode;
 }
 
+void MonitorManager::setDocument(KdenliveDoc *doc)
+{
+    m_document = doc;
+}
+
 void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor, RecMonitor *recMonitor)
 {
     m_clipMonitor = clipMonitor;
     m_projectMonitor = projectMonitor;
+    
+    connect(m_clipMonitor->render, SIGNAL(activateMonitor(Kdenlive::MonitorId)), this, SLOT(activateMonitor(Kdenlive::MonitorId)));
+    connect(m_projectMonitor->render, SIGNAL(activateMonitor(Kdenlive::MonitorId)), this, SLOT(activateMonitor(Kdenlive::MonitorId)));
 
     m_monitorsList.append(clipMonitor);
     m_monitorsList.append(projectMonitor);
@@ -62,15 +73,34 @@ void MonitorManager::removeMonitor(AbstractMonitor *monitor)
     m_monitorsList.removeAll(monitor);
 }
 
-bool MonitorManager::activateMonitor(const QString &name)
+AbstractMonitor* MonitorManager::monitor(Kdenlive::MonitorId monitorName)
+{
+    AbstractMonitor *monitor = NULL;
+    for (int i = 0; i < m_monitorsList.size(); ++i) {
+        if (m_monitorsList[i]->id() == monitorName) {
+        monitor = m_monitorsList.at(i);
+       }
+    }
+    return monitor;
+}
+
+void MonitorManager::setConsumerProperty(const QString &name, const QString &value)
+{
+    if (m_clipMonitor) m_clipMonitor->render->setConsumerProperty(name, value);
+    if (m_projectMonitor) m_projectMonitor->render->setConsumerProperty(name, value);
+}
+
+bool MonitorManager::activateMonitor(Kdenlive::MonitorId name, bool forceRefresh)
 {
     if (m_clipMonitor == NULL || m_projectMonitor == NULL)
         return false;
-    if (m_activeMonitor && m_activeMonitor->name() == name)
+    if (m_activeMonitor && m_activeMonitor->id() == name) {
+       if (forceRefresh) m_activeMonitor->start();
         return false;
+    }
     m_activeMonitor = NULL;
-    for (int i = 0; i < m_monitorsList.count(); i++) {
-        if (m_monitorsList.at(i)->name() == name) {
+    for (int i = 0; i < m_monitorsList.count(); ++i) {
+        if (m_monitorsList.at(i)->id() == name) {
             m_activeMonitor = m_monitorsList.at(i);
         }
         else m_monitorsList.at(i)->stop();
@@ -78,36 +108,36 @@ bool MonitorManager::activateMonitor(const QString &name)
     if (m_activeMonitor) {
         m_activeMonitor->blockSignals(true);
         m_activeMonitor->parentWidget()->raise();
+       m_activeMonitor->blockSignals(false);
         m_activeMonitor->start();
-        m_activeMonitor->blockSignals(false);
+        
     }
     emit checkColorScopes();
     return (m_activeMonitor != NULL);
 }
 
-bool MonitorManager::isActive(const QString &name) const
+bool MonitorManager::isActive(Kdenlive::MonitorId id) const
 {
-    return m_activeMonitor ? m_activeMonitor->name() == name: false;
+    return m_activeMonitor ? m_activeMonitor->id() == id: false;
 }
 
 void MonitorManager::slotSwitchMonitors(bool activateClip)
 {
     if (activateClip)
-        activateMonitor("clip");
+        activateMonitor(Kdenlive::ClipMonitor);
     else
-        activateMonitor("project");
+        activateMonitor(Kdenlive::ProjectMonitor);
 }
 
 void MonitorManager::stopActiveMonitor()
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->pause();
-    else m_projectMonitor->pause();
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->pause();
 }
 
 void MonitorManager::slotPlay()
 {
-    if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlay();
-    else m_projectMonitor->slotPlay();
+    if (m_activeMonitor) m_activeMonitor->slotPlay();
 }
 
 void MonitorManager::slotPause()
@@ -118,7 +148,7 @@ void MonitorManager::slotPause()
 void MonitorManager::slotPlayZone()
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlayZone();
-    else m_projectMonitor->slotPlayZone();
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotPlayZone();
 }
 
 void MonitorManager::slotLoopZone()
@@ -130,52 +160,52 @@ void MonitorManager::slotLoopZone()
 void MonitorManager::slotRewind(double speed)
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewind(speed);
-    else m_projectMonitor->slotRewind(speed);
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotRewind(speed);
 }
 
 void MonitorManager::slotForward(double speed)
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForward(speed);
-    else m_projectMonitor->slotForward(speed);
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotForward(speed);
 }
 
 void MonitorManager::slotRewindOneFrame()
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame();
-    else m_projectMonitor->slotRewindOneFrame();
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotRewindOneFrame();
 }
 
 void MonitorManager::slotForwardOneFrame()
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame();
-    else m_projectMonitor->slotForwardOneFrame();
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotForwardOneFrame();
 }
 
 void MonitorManager::slotRewindOneSecond()
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
-    else m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
 }
 
 void MonitorManager::slotForwardOneSecond()
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
-    else m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
 }
 
 void MonitorManager::slotStart()
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotStart();
-    else m_projectMonitor->slotStart();
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotStart();
 }
 
 void MonitorManager::slotEnd()
 {
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotEnd();
-    else m_projectMonitor->slotEnd();
+    else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotEnd();
 }
 
-void MonitorManager::resetProfiles(Timecode tc)
+void MonitorManager::resetProfiles(const Timecode &tc)
 {
     m_timecode = tc;
     slotResetProfiles();
@@ -184,27 +214,23 @@ void MonitorManager::resetProfiles(Timecode tc)
 
 void MonitorManager::slotResetProfiles()
 {
-    if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
-    blockSignals(true);
-    QString active = m_activeMonitor ? m_activeMonitor->name() : QString();
-    if (!m_clipMonitor->render->hasProfile(KdenliveSettings::current_profile())) {
-        activateMonitor("clip");
-        m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
-        m_clipMonitor->updateTimecodeFormat();
-    }
-    if (!m_projectMonitor->render->hasProfile(KdenliveSettings::current_profile())) {
-        activateMonitor("project");
-        m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
-        m_projectMonitor->updateTimecodeFormat();
+    if (m_projectMonitor == NULL || m_clipMonitor == NULL) {
+       return;
     }
-    if (!active.isEmpty()) activateMonitor(active);
+    blockSignals(true);
+    Kdenlive::MonitorId active = m_activeMonitor ? m_activeMonitor->id() : Kdenlive::NoMonitor;
+    m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
+    m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
+    if (active != Kdenlive::NoMonitor) activateMonitor(active);
     blockSignals(false);
     if (m_activeMonitor) m_activeMonitor->parentWidget()->raise();
     emit checkColorScopes();
 }
 
-void MonitorManager::slotRefreshCurrentMonitor()
+void MonitorManager::slotRefreshCurrentMonitor(const QString &id)
 {
+    // Clip producer was modified, check if clip is currently displayed in clip monitor
+    m_clipMonitor->reloadProducer(id);
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->refreshMonitor();
     else m_projectMonitor->refreshMonitor();
 }
@@ -212,11 +238,14 @@ void MonitorManager::slotRefreshCurrentMonitor()
 void MonitorManager::slotUpdateAudioMonitoring()
 {
     // if(...) added since they are 0x0 when the config wizard is running! --Granjow
-    if (m_clipMonitor) {
+    /*if (m_clipMonitor) {
         m_clipMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
     }
     if (m_projectMonitor) {
         m_projectMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
+    }*/
+    for (int i = 0; i < m_monitorsList.count(); ++i) {
+        if (m_monitorsList.at(i)->abstractRender()) m_monitorsList.at(i)->abstractRender()->analyseAudio = KdenliveSettings::monitor_audio();
     }
 }
 
@@ -238,4 +267,19 @@ AbstractRender *MonitorManager::activeRenderer()
     return NULL;
 }
 
+void MonitorManager::slotSwitchFullscreen()
+{
+    if (m_activeMonitor) m_activeMonitor->slotSwitchFullScreen();
+}
+
+QString MonitorManager::getProjectFolder() const
+{
+    if (m_document == NULL) {
+       kDebug()<<" + + +NULL DOC!!";
+       return QString();
+    }
+    return m_document->projectFolder().path(KUrl::AddTrailingSlash);
+}
+
+
 #include "monitormanager.moc"