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 bool MonitorManager::activateMonitor(const 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->blockSignals(true);
80 m_activeMonitor->parentWidget()->raise();
81 m_activeMonitor->start();
82 m_activeMonitor->blockSignals(false);
84 emit checkColorScopes();
85 return (m_activeMonitor != NULL);
88 bool MonitorManager::isActive(const QString &name) const
90 return m_activeMonitor ? m_activeMonitor->name() == name: false;
93 void MonitorManager::slotSwitchMonitors(bool activateClip)
96 activateMonitor("clip");
98 activateMonitor("project");
101 void MonitorManager::stopActiveMonitor()
103 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->pause();
104 else m_projectMonitor->pause();
107 void MonitorManager::slotPlay()
109 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlay();
110 else m_projectMonitor->slotPlay();
113 void MonitorManager::slotPause()
118 void MonitorManager::slotPlayZone()
120 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlayZone();
121 else m_projectMonitor->slotPlayZone();
124 void MonitorManager::slotLoopZone()
126 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotLoopZone();
127 else m_projectMonitor->slotLoopZone();
130 void MonitorManager::slotRewind(double speed)
132 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewind(speed);
133 else m_projectMonitor->slotRewind(speed);
136 void MonitorManager::slotForward(double speed)
138 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForward(speed);
139 else m_projectMonitor->slotForward(speed);
142 void MonitorManager::slotRewindOneFrame()
144 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame();
145 else m_projectMonitor->slotRewindOneFrame();
148 void MonitorManager::slotForwardOneFrame()
150 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame();
151 else m_projectMonitor->slotForwardOneFrame();
154 void MonitorManager::slotRewindOneSecond()
156 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
157 else m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
160 void MonitorManager::slotForwardOneSecond()
162 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
163 else m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
166 void MonitorManager::slotStart()
168 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotStart();
169 else m_projectMonitor->slotStart();
172 void MonitorManager::slotEnd()
174 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotEnd();
175 else m_projectMonitor->slotEnd();
178 void MonitorManager::resetProfiles(Timecode tc)
182 //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
185 void MonitorManager::slotResetProfiles()
187 if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
189 QString active = m_activeMonitor ? m_activeMonitor->name() : QString();
190 m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
191 m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
192 if (!active.isEmpty()) activateMonitor(active);
194 if (m_activeMonitor) m_activeMonitor->parentWidget()->raise();
195 emit checkColorScopes();
198 void MonitorManager::slotRefreshCurrentMonitor()
200 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->refreshMonitor();
201 else m_projectMonitor->refreshMonitor();
204 void MonitorManager::slotUpdateAudioMonitoring()
206 // if(...) added since they are 0x0 when the config wizard is running! --Granjow
208 m_clipMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
210 if (m_projectMonitor) {
211 m_projectMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
215 void MonitorManager::clearScopeSource()
220 void MonitorManager::updateScopeSource()
222 emit checkColorScopes();
225 AbstractRender *MonitorManager::activeRenderer()
227 if (m_activeMonitor) {
228 return m_activeMonitor->abstractRender();
233 #include "monitormanager.moc"