]> git.sesse.net Git - kdenlive/blobdiff - src/monitormanager.cpp
Do not uselessly switch monitors at startup
[kdenlive] / src / monitormanager.cpp
index 1077967fe11bcb84389e389cb62aa712e57220b3..466501913cb8b6fa9f971152792affd4862ef80b 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)
 {
 }
 
@@ -65,7 +64,7 @@ void MonitorManager::removeMonitor(AbstractMonitor *monitor)
 
 void MonitorManager::activateMonitor(QString name)
 {
-    if (m_blocked || m_clipMonitor == NULL || m_projectMonitor == NULL)
+    if (m_clipMonitor == NULL || m_projectMonitor == NULL)
         return;
     if (m_activeMonitor && m_activeMonitor->name() == name)
         return;
@@ -73,15 +72,17 @@ void MonitorManager::activateMonitor(QString name)
     for (int i = 0; i < m_monitorsList.count(); i++) {
         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->parentWidget()->raise();
+        m_activeMonitor->start();
+    }
     emit checkColorScopes();
 }
 
-bool MonitorManager::isActive(const QString name) const
+bool MonitorManager::isActive(const QString &name) const
 {
     return m_activeMonitor ? m_activeMonitor->name() == name: false;
 }
@@ -96,7 +97,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();
 }
@@ -174,7 +174,6 @@ void MonitorManager::slotEnd()
 
 void MonitorManager::resetProfiles(Timecode tc)
 {
-    if (m_blocked) return;
     m_timecode = tc;
     slotResetProfiles();
     //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
@@ -182,17 +181,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()
@@ -212,6 +217,11 @@ void MonitorManager::slotUpdateAudioMonitoring()
     }
 }
 
+void MonitorManager::clearScopeSource()
+{
+    emit clearScopes();
+}
+
 void MonitorManager::updateScopeSource()
 {
     emit checkColorScopes();
@@ -219,7 +229,9 @@ void MonitorManager::updateScopeSource()
 
 AbstractRender *MonitorManager::activeRenderer()
 {
-    if (m_activeMonitor) return m_activeMonitor->abstractRender();
+    if (m_activeMonitor) {
+        return m_activeMonitor->abstractRender();
+    }
     return NULL;
 }