]> git.sesse.net Git - kdenlive/blobdiff - src/monitormanager.cpp
Fix updating of monitor timecode, solving offset between timeline and monitor timecode
[kdenlive] / src / monitormanager.cpp
index 9bf6ce43cd37ec6dc8ba9d404fbfa2bc2bac98a8..1b0a7c6fb278400d20a2867947a0648408ea4681 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)
 {
 }
 
@@ -63,25 +62,30 @@ void MonitorManager::removeMonitor(AbstractMonitor *monitor)
     m_monitorsList.removeAll(monitor);
 }
 
-void MonitorManager::activateMonitor(QString name)
+bool MonitorManager::activateMonitor(const QString &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++) {
         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;
 }
@@ -96,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();
 }
@@ -174,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()));
@@ -182,20 +184,14 @@ 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 (!active.isEmpty()) activateMonitor(active);
     blockSignals(false);
-    emit raiseMonitor(m_activeMonitor);
+    if (m_activeMonitor) m_activeMonitor->parentWidget()->raise();
     emit checkColorScopes();
 }