]> git.sesse.net Git - kdenlive/blobdiff - src/monitormanager.cpp
Fix several DVD wizard monitor issue, might solve:
[kdenlive] / src / monitormanager.cpp
index f771fabc918cb8df1232f8e9dd9bd9985b09edb1..0656a4d865e5878c65cfcc94107d4cf66bab1d4d 100644 (file)
  ***************************************************************************/
 
 
-#include <QObject>
-#include <QTimer>
-
 #include "monitormanager.h"
+#include "kdenlivesettings.h"
+
 #include <mlt++/Mlt.h>
 
-MonitorManager::MonitorManager(QWidget *parent)
-        : QObject(parent) {
-}
+#include <QObject>
+#include <QTimer>
 
-void MonitorManager::setTimecode(Timecode tc) {
-    m_timecode = tc;
+
+MonitorManager::MonitorManager(QWidget *parent) :
+        QObject(parent),
+        m_clipMonitor(NULL),
+        m_projectMonitor(NULL),
+        m_blocked(false)
+{
 }
 
-Timecode MonitorManager::timecode() {
+Timecode MonitorManager::timecode()
+{
     return m_timecode;
 }
 
-void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor) {
+void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor)
+{
     m_clipMonitor = clipMonitor;
     m_projectMonitor = projectMonitor;
+    connect(m_clipMonitor, SIGNAL(blockMonitors()), this, SLOT(slotBlockMonitors()));
+    connect(m_projectMonitor, SIGNAL(blockMonitors()), this, SLOT(slotBlockMonitors()));
 }
 
-bool MonitorManager::projectMonitorFocused() {
-    if (m_activeMonitor != "clip") return true;
-    return false;
-}
-
-void MonitorManager::activateMonitor(QString name) {
+void MonitorManager::activateMonitor(QString name)
+{
+    if (m_blocked || m_clipMonitor == NULL) return;
     if (m_activeMonitor == name) return;
     if (name == "clip") {
         m_projectMonitor->stop();
@@ -61,8 +65,10 @@ void MonitorManager::activateMonitor(QString name) {
     m_activeMonitor = name;
 }
 
-void MonitorManager::switchMonitors() {
-    if (m_activeMonitor == "clip") {
+void MonitorManager::switchMonitors()
+{
+    if (m_blocked || m_clipMonitor == NULL) return;
+    if (m_clipMonitor->isActive()) {
         m_clipMonitor->stop();
         m_projectMonitor->start();
         m_projectMonitor->raise();
@@ -76,34 +82,109 @@ void MonitorManager::switchMonitors() {
     }
 }
 
-void MonitorManager::slotPlay() {
-    if (m_activeMonitor == "clip") m_clipMonitor->slotPlay();
+void MonitorManager::stopActiveMonitor()
+{
+    if (m_blocked) return;
+    if (m_clipMonitor->isActive()) m_clipMonitor->pause();
+    else m_projectMonitor->pause();
+}
+
+void MonitorManager::slotPlay()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotPlay();
     else m_projectMonitor->slotPlay();
 }
 
-void MonitorManager::slotRewind(double speed) {
-    if (m_activeMonitor == "clip") m_clipMonitor->slotRewind(speed);
+void MonitorManager::slotPlayZone()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotPlayZone();
+    else m_projectMonitor->slotPlayZone();
+}
+
+void MonitorManager::slotLoopZone()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotLoopZone();
+    else m_projectMonitor->slotLoopZone();
+}
+
+void MonitorManager::slotRewind(double speed)
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotRewind(speed);
     else m_projectMonitor->slotRewind(speed);
 }
 
-void MonitorManager::slotForward(double speed) {
-    if (m_activeMonitor == "clip") m_clipMonitor->slotForward(speed);
+void MonitorManager::slotForward(double speed)
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotForward(speed);
     else m_projectMonitor->slotForward(speed);
 }
 
-void MonitorManager::slotRewindOneFrame() {
-    if (m_activeMonitor == "clip") m_clipMonitor->slotRewindOneFrame();
+void MonitorManager::slotRewindOneFrame()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame();
     else m_projectMonitor->slotRewindOneFrame();
 }
 
-void MonitorManager::slotForwardOneFrame() {
-    if (m_activeMonitor == "clip") m_clipMonitor->slotForwardOneFrame();
+void MonitorManager::slotForwardOneFrame()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame();
     else m_projectMonitor->slotForwardOneFrame();
 }
 
-void MonitorManager::resetProfiles(QString prof) {
-    m_clipMonitor->resetProfile(prof);
-    m_projectMonitor->resetProfile(prof);
+void MonitorManager::slotRewindOneSecond()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
+    else m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
+}
+
+void MonitorManager::slotForwardOneSecond()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
+    else m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
+}
+
+void MonitorManager::slotStart()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotStart();
+    else m_projectMonitor->slotStart();
+}
+
+void MonitorManager::slotEnd()
+{
+    if (m_clipMonitor->isActive()) m_clipMonitor->slotEnd();
+    else m_projectMonitor->slotEnd();
+}
+
+void MonitorManager::resetProfiles(Timecode tc)
+{
+    if (m_blocked) return;
+    m_timecode = tc;
+    slotResetProfiles();
+    //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
+}
+
+void MonitorManager::slotResetProfiles()
+{
+    if (m_blocked) return;
+    if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
+    activateMonitor("clip");
+    m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
+    activateMonitor("project");
+    m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
+    //m_projectMonitor->refreshMonitor(true);
+}
+
+void MonitorManager::slotBlockMonitors()
+{
+    m_blocked = true;
+    if (m_clipMonitor) {
+        m_clipMonitor->blockSignals(true);
+        m_clipMonitor->setEnabled(false);
+    }
+    if (m_projectMonitor) {
+        m_projectMonitor->blockSignals(true);
+        m_projectMonitor->setEnabled(false);
+    }
 }
 
 #include "monitormanager.moc"