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, RecMonitor *recMonitor)
46 m_clipMonitor = clipMonitor;
47 m_projectMonitor = projectMonitor;
49 m_monitorsList.append(clipMonitor);
50 m_monitorsList.append(projectMonitor);
52 m_monitorsList.append(recMonitor);
55 void MonitorManager::appendMonitor(AbstractMonitor *monitor)
57 if (!m_monitorsList.contains(monitor)) m_monitorsList.append(monitor);
60 void MonitorManager::removeMonitor(AbstractMonitor *monitor)
62 m_monitorsList.removeAll(monitor);
65 void MonitorManager::activateMonitor(QString name)
67 if (m_clipMonitor == NULL || m_projectMonitor == NULL)
69 if (m_activeMonitor && m_activeMonitor->name() == name)
71 m_activeMonitor = NULL;
72 for (int i = 0; i < m_monitorsList.count(); i++) {
73 if (m_monitorsList.at(i)->name() == name) {
74 m_activeMonitor = m_monitorsList.at(i);
76 else m_monitorsList.at(i)->stop();
78 if (m_activeMonitor) {
79 m_activeMonitor->parentWidget()->raise();
80 m_activeMonitor->start();
82 emit checkColorScopes();
85 bool MonitorManager::isActive(const QString &name) const
87 return m_activeMonitor ? m_activeMonitor->name() == name: false;
90 void MonitorManager::slotSwitchMonitors(bool activateClip)
93 activateMonitor("clip");
95 activateMonitor("project");
98 void MonitorManager::stopActiveMonitor()
100 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->pause();
101 else m_projectMonitor->pause();
104 void MonitorManager::slotPlay()
106 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlay();
107 else m_projectMonitor->slotPlay();
110 void MonitorManager::slotPause()
115 void MonitorManager::slotPlayZone()
117 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlayZone();
118 else m_projectMonitor->slotPlayZone();
121 void MonitorManager::slotLoopZone()
123 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotLoopZone();
124 else m_projectMonitor->slotLoopZone();
127 void MonitorManager::slotRewind(double speed)
129 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewind(speed);
130 else m_projectMonitor->slotRewind(speed);
133 void MonitorManager::slotForward(double speed)
135 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForward(speed);
136 else m_projectMonitor->slotForward(speed);
139 void MonitorManager::slotRewindOneFrame()
141 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame();
142 else m_projectMonitor->slotRewindOneFrame();
145 void MonitorManager::slotForwardOneFrame()
147 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame();
148 else m_projectMonitor->slotForwardOneFrame();
151 void MonitorManager::slotRewindOneSecond()
153 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
154 else m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
157 void MonitorManager::slotForwardOneSecond()
159 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
160 else m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
163 void MonitorManager::slotStart()
165 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotStart();
166 else m_projectMonitor->slotStart();
169 void MonitorManager::slotEnd()
171 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotEnd();
172 else m_projectMonitor->slotEnd();
175 void MonitorManager::resetProfiles(Timecode tc)
179 //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
182 void MonitorManager::slotResetProfiles()
184 if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
186 QString active = m_activeMonitor ? m_activeMonitor->name() : QString();
187 if (!m_clipMonitor->render->hasProfile(KdenliveSettings::current_profile())) {
188 activateMonitor("clip");
189 m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
190 m_clipMonitor->updateTimecodeFormat();
192 if (!m_projectMonitor->render->hasProfile(KdenliveSettings::current_profile())) {
193 activateMonitor("project");
194 m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
195 m_projectMonitor->updateTimecodeFormat();
197 if (!active.isEmpty()) activateMonitor(active);
199 if (m_activeMonitor) m_activeMonitor->parentWidget()->raise();
200 emit checkColorScopes();
203 void MonitorManager::slotRefreshCurrentMonitor()
205 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->refreshMonitor();
206 else m_projectMonitor->refreshMonitor();
209 void MonitorManager::slotUpdateAudioMonitoring()
211 // if(...) added since they are 0x0 when the config wizard is running! --Granjow
213 m_clipMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
215 if (m_projectMonitor) {
216 m_projectMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
220 void MonitorManager::clearScopeSource()
225 void MonitorManager::updateScopeSource()
227 emit checkColorScopes();
230 AbstractRender *MonitorManager::activeRenderer()
232 if (m_activeMonitor) {
233 return m_activeMonitor->abstractRender();
238 #include "monitormanager.moc"