]> git.sesse.net Git - kdenlive/blobdiff - src/monitormanager.cpp
Several small adjustments for monitor switching
[kdenlive] / src / monitormanager.cpp
index af5a14cd39e2f539e98d6afc8b132c1890d6e19b..8d0d2341b83929e018a35c8de7f50efd1cd09201 100644 (file)
 
 #include <QObject>
 #include <QTimer>
-
+#include <KDebug>
 
 MonitorManager::MonitorManager(QWidget *parent) :
         QObject(parent),
         m_clipMonitor(NULL),
         m_projectMonitor(NULL),
-        m_activeMonitor(NULL),
-        m_blocked(false)
+        m_activeMonitor(NULL)
 {
 }
 
@@ -49,7 +48,8 @@ void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor,
 
     m_monitorsList.append(clipMonitor);
     m_monitorsList.append(projectMonitor);
-    m_monitorsList.append(recMonitor);
+    if (recMonitor)
+        m_monitorsList.append(recMonitor);
 }
 
 void MonitorManager::appendMonitor(AbstractMonitor *monitor)
@@ -62,27 +62,30 @@ void MonitorManager::removeMonitor(AbstractMonitor *monitor)
     m_monitorsList.removeAll(monitor);
 }
 
-void MonitorManager::activateMonitor(QString name)
+bool MonitorManager::activateMonitor(const QString &name)
 {
-    kDebug()<<"//ACTIVATING MON: "<<name;
-    if (m_blocked || m_clipMonitor == NULL || m_projectMonitor == NULL)
-        return;
+    if (m_clipMonitor == NULL || m_projectMonitor == NULL)
+        return false;
     if (m_activeMonitor && m_activeMonitor->name() == name)
-        return;
+        return false;
     m_activeMonitor = NULL;
     for (int i = 0; i < m_monitorsList.count(); i++) {
-        kDebug()<<"PARSING: "<<m_monitorsList.at(i)->name();
         if (m_monitorsList.at(i)->name() == name) {
             m_activeMonitor = m_monitorsList.at(i);
-            emit raiseMonitor(m_activeMonitor);
         }
         else m_monitorsList.at(i)->stop();
     }
-    if (m_activeMonitor) m_activeMonitor->start();
+    if (m_activeMonitor) {
+        m_activeMonitor->blockSignals(true);
+        m_activeMonitor->parentWidget()->raise();
+        m_activeMonitor->start();
+        m_activeMonitor->blockSignals(false);
+    }
     emit checkColorScopes();
+    return (m_activeMonitor != NULL);
 }
 
-bool MonitorManager::isActive(const QString name) const
+bool MonitorManager::isActive(const QString &name) const
 {
     return m_activeMonitor ? m_activeMonitor->name() == name: false;
 }
@@ -97,7 +100,6 @@ void MonitorManager::slotSwitchMonitors(bool activateClip)
 
 void MonitorManager::stopActiveMonitor()
 {
-    if (m_blocked) return;
     if (m_activeMonitor == m_clipMonitor) m_clipMonitor->pause();
     else m_projectMonitor->pause();
 }
@@ -175,7 +177,6 @@ void MonitorManager::slotEnd()
 
 void MonitorManager::resetProfiles(Timecode tc)
 {
-    if (m_blocked) return;
     m_timecode = tc;
     slotResetProfiles();
     //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
@@ -183,17 +184,23 @@ void MonitorManager::resetProfiles(Timecode tc)
 
 void MonitorManager::slotResetProfiles()
 {
-    if (m_blocked) return;
     if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
+    blockSignals(true);
     QString active = m_activeMonitor ? m_activeMonitor->name() : QString();
-    activateMonitor("clip");
-    m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
-    m_clipMonitor->updateTimecodeFormat();
-    activateMonitor("project");
-    m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
-    m_projectMonitor->updateTimecodeFormat();
-    //m_projectMonitor->refreshMonitor(true);
+    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 (!active.isEmpty()) activateMonitor(active);
+    blockSignals(false);
+    if (m_activeMonitor) m_activeMonitor->parentWidget()->raise();
+    emit checkColorScopes();
 }
 
 void MonitorManager::slotRefreshCurrentMonitor()
@@ -213,6 +220,11 @@ void MonitorManager::slotUpdateAudioMonitoring()
     }
 }
 
+void MonitorManager::clearScopeSource()
+{
+    emit clearScopes();
+}
+
 void MonitorManager::updateScopeSource()
 {
     emit checkColorScopes();
@@ -220,7 +232,9 @@ void MonitorManager::updateScopeSource()
 
 AbstractRender *MonitorManager::activeRenderer()
 {
-    if (m_activeMonitor) return m_activeMonitor->abstractRender();
+    if (m_activeMonitor) {
+        return m_activeMonitor->abstractRender();
+    }
     return NULL;
 }