1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "monitormanager.h"
22 #include "kdenlivesettings.h"
24 #include <mlt++/Mlt.h>
30 MonitorManager::MonitorManager(QWidget *parent) :
33 m_projectMonitor(NULL),
38 Timecode MonitorManager::timecode()
43 void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor)
45 m_clipMonitor = clipMonitor;
46 m_projectMonitor = projectMonitor;
49 void MonitorManager::activateMonitor(QString name)
51 if (m_blocked || m_clipMonitor == NULL) return;
52 if (m_activeMonitor == name) return;
54 m_projectMonitor->stop();
55 m_clipMonitor->start();
56 emit raiseClipMonitor(true);
58 m_clipMonitor->stop();
59 m_projectMonitor->start();
60 emit raiseClipMonitor(false);
62 m_activeMonitor = name;
65 void MonitorManager::slotSwitchMonitors(bool activateClip)
67 if (m_blocked || m_clipMonitor == NULL) return;
68 if (!activateClip && m_clipMonitor->isActive()) {
69 m_clipMonitor->stop();
70 m_projectMonitor->start();
71 m_activeMonitor = m_projectMonitor->name();
72 emit raiseClipMonitor(false);
73 } else if (activateClip && m_projectMonitor->isActive()) {
74 m_projectMonitor->stop();
75 m_clipMonitor->start();
76 m_activeMonitor = m_clipMonitor->name();
77 emit raiseClipMonitor(true);
81 void MonitorManager::stopActiveMonitor()
83 if (m_blocked) return;
84 if (m_clipMonitor->isActive()) m_clipMonitor->pause();
85 else m_projectMonitor->pause();
88 void MonitorManager::slotPlay()
90 if (m_clipMonitor->isActive()) m_clipMonitor->slotPlay();
91 else m_projectMonitor->slotPlay();
94 void MonitorManager::slotPlayZone()
96 if (m_clipMonitor->isActive()) m_clipMonitor->slotPlayZone();
97 else m_projectMonitor->slotPlayZone();
100 void MonitorManager::slotLoopZone()
102 if (m_clipMonitor->isActive()) m_clipMonitor->slotLoopZone();
103 else m_projectMonitor->slotLoopZone();
106 void MonitorManager::slotRewind(double speed)
108 if (m_clipMonitor->isActive()) m_clipMonitor->slotRewind(speed);
109 else m_projectMonitor->slotRewind(speed);
112 void MonitorManager::slotForward(double speed)
114 if (m_clipMonitor->isActive()) m_clipMonitor->slotForward(speed);
115 else m_projectMonitor->slotForward(speed);
118 void MonitorManager::slotRewindOneFrame()
120 if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame();
121 else m_projectMonitor->slotRewindOneFrame();
124 void MonitorManager::slotForwardOneFrame()
126 if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame();
127 else m_projectMonitor->slotForwardOneFrame();
130 void MonitorManager::slotRewindOneSecond()
132 if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
133 else m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
136 void MonitorManager::slotForwardOneSecond()
138 if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
139 else m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
142 void MonitorManager::slotStart()
144 if (m_clipMonitor->isActive()) m_clipMonitor->slotStart();
145 else m_projectMonitor->slotStart();
148 void MonitorManager::slotEnd()
150 if (m_clipMonitor->isActive()) m_clipMonitor->slotEnd();
151 else m_projectMonitor->slotEnd();
154 void MonitorManager::resetProfiles(Timecode tc)
156 if (m_blocked) return;
159 //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
162 void MonitorManager::slotResetProfiles()
164 if (m_blocked) return;
165 if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
166 activateMonitor("clip");
167 m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
168 m_clipMonitor->updateTimecodeFormat();
169 activateMonitor("project");
170 m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
171 m_projectMonitor->updateTimecodeFormat();
172 //m_projectMonitor->refreshMonitor(true);
176 #include "monitormanager.moc"