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"
23 #include "kdenlivesettings.h"
25 #include <mlt++/Mlt.h>
31 MonitorManager::MonitorManager(QWidget *parent) :
34 m_projectMonitor(NULL),
39 Timecode MonitorManager::timecode()
44 void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor)
46 m_clipMonitor = clipMonitor;
47 m_projectMonitor = projectMonitor;
50 void MonitorManager::activateMonitor(QString name)
52 if (m_blocked || m_clipMonitor == NULL || m_projectMonitor == NULL)
54 if (m_activeMonitor == name)
57 m_projectMonitor->stop();
58 m_clipMonitor->start();
59 emit raiseClipMonitor(true);
61 m_clipMonitor->stop();
62 m_projectMonitor->start();
63 emit raiseClipMonitor(false);
65 m_activeMonitor = name;
66 emit checkColorScopes();
69 void MonitorManager::slotSwitchMonitors(bool activateClip)
72 activateMonitor("clip");
74 activateMonitor("project");
77 void MonitorManager::stopActiveMonitor()
79 if (m_blocked) return;
80 if (m_clipMonitor->isActive()) m_clipMonitor->pause();
81 else m_projectMonitor->pause();
84 void MonitorManager::slotPlay()
86 if (m_clipMonitor->isActive()) m_clipMonitor->slotPlay();
87 else m_projectMonitor->slotPlay();
90 void MonitorManager::slotPlayZone()
92 if (m_clipMonitor->isActive()) m_clipMonitor->slotPlayZone();
93 else m_projectMonitor->slotPlayZone();
96 void MonitorManager::slotLoopZone()
98 if (m_clipMonitor->isActive()) m_clipMonitor->slotLoopZone();
99 else m_projectMonitor->slotLoopZone();
102 void MonitorManager::slotRewind(double speed)
104 if (m_clipMonitor->isActive()) m_clipMonitor->slotRewind(speed);
105 else m_projectMonitor->slotRewind(speed);
108 void MonitorManager::slotForward(double speed)
110 if (m_clipMonitor->isActive()) m_clipMonitor->slotForward(speed);
111 else m_projectMonitor->slotForward(speed);
114 void MonitorManager::slotRewindOneFrame()
116 if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame();
117 else m_projectMonitor->slotRewindOneFrame();
120 void MonitorManager::slotForwardOneFrame()
122 if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame();
123 else m_projectMonitor->slotForwardOneFrame();
126 void MonitorManager::slotRewindOneSecond()
128 if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
129 else m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
132 void MonitorManager::slotForwardOneSecond()
134 if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
135 else m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
138 void MonitorManager::slotStart()
140 if (m_clipMonitor->isActive()) m_clipMonitor->slotStart();
141 else m_projectMonitor->slotStart();
144 void MonitorManager::slotEnd()
146 if (m_clipMonitor->isActive()) m_clipMonitor->slotEnd();
147 else m_projectMonitor->slotEnd();
150 void MonitorManager::resetProfiles(Timecode tc)
152 if (m_blocked) return;
155 //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
158 void MonitorManager::slotResetProfiles()
160 if (m_blocked) return;
161 if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
162 QString active = m_activeMonitor;
163 activateMonitor("clip");
164 m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
165 m_clipMonitor->updateTimecodeFormat();
166 activateMonitor("project");
167 m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
168 m_projectMonitor->updateTimecodeFormat();
169 //m_projectMonitor->refreshMonitor(true);
170 activateMonitor(active);
173 void MonitorManager::slotRefreshCurrentMonitor()
175 if (m_clipMonitor->isActive()) m_clipMonitor->refreshMonitor();
176 else m_projectMonitor->refreshMonitor();
179 void MonitorManager::slotUpdateAudioMonitoring()
181 m_clipMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
182 m_projectMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
185 #include "monitormanager.moc"