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),
35 m_activeMonitor(NULL),
40 Timecode MonitorManager::timecode()
45 void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor, RecMonitor *recMonitor)
47 m_clipMonitor = clipMonitor;
48 m_projectMonitor = projectMonitor;
50 m_monitorsList.append(clipMonitor);
51 m_monitorsList.append(projectMonitor);
53 m_monitorsList.append(recMonitor);
56 void MonitorManager::appendMonitor(AbstractMonitor *monitor)
58 if (!m_monitorsList.contains(monitor)) m_monitorsList.append(monitor);
61 void MonitorManager::removeMonitor(AbstractMonitor *monitor)
63 m_monitorsList.removeAll(monitor);
66 void MonitorManager::activateMonitor(QString name)
68 if (m_blocked || m_clipMonitor == NULL || m_projectMonitor == NULL)
70 if (m_activeMonitor && m_activeMonitor->name() == name)
72 m_activeMonitor = NULL;
73 for (int i = 0; i < m_monitorsList.count(); i++) {
74 if (m_monitorsList.at(i)->name() == name) {
75 m_activeMonitor = m_monitorsList.at(i);
77 else m_monitorsList.at(i)->stop();
79 if (m_activeMonitor) {
80 m_activeMonitor->parentWidget()->raise();
81 m_activeMonitor->start();
83 emit checkColorScopes();
86 bool MonitorManager::isActive(const QString &name) const
88 return m_activeMonitor ? m_activeMonitor->name() == name: false;
91 void MonitorManager::slotSwitchMonitors(bool activateClip)
94 activateMonitor("clip");
96 activateMonitor("project");
99 void MonitorManager::stopActiveMonitor()
101 if (m_blocked) return;
102 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->pause();
103 else m_projectMonitor->pause();
106 void MonitorManager::slotPlay()
108 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlay();
109 else m_projectMonitor->slotPlay();
112 void MonitorManager::slotPause()
117 void MonitorManager::slotPlayZone()
119 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlayZone();
120 else m_projectMonitor->slotPlayZone();
123 void MonitorManager::slotLoopZone()
125 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotLoopZone();
126 else m_projectMonitor->slotLoopZone();
129 void MonitorManager::slotRewind(double speed)
131 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewind(speed);
132 else m_projectMonitor->slotRewind(speed);
135 void MonitorManager::slotForward(double speed)
137 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForward(speed);
138 else m_projectMonitor->slotForward(speed);
141 void MonitorManager::slotRewindOneFrame()
143 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame();
144 else m_projectMonitor->slotRewindOneFrame();
147 void MonitorManager::slotForwardOneFrame()
149 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame();
150 else m_projectMonitor->slotForwardOneFrame();
153 void MonitorManager::slotRewindOneSecond()
155 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
156 else m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
159 void MonitorManager::slotForwardOneSecond()
161 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
162 else m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
165 void MonitorManager::slotStart()
167 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotStart();
168 else m_projectMonitor->slotStart();
171 void MonitorManager::slotEnd()
173 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotEnd();
174 else m_projectMonitor->slotEnd();
177 void MonitorManager::resetProfiles(Timecode tc)
179 if (m_blocked) return;
182 //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
185 void MonitorManager::slotResetProfiles()
187 if (m_blocked) return;
188 if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
190 QString active = m_activeMonitor ? m_activeMonitor->name() : QString();
191 activateMonitor("clip");
192 m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
193 m_clipMonitor->updateTimecodeFormat();
194 activateMonitor("project");
195 m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
196 m_projectMonitor->updateTimecodeFormat();
197 //m_projectMonitor->refreshMonitor(true);
198 if (!active.isEmpty()) activateMonitor(active);
200 m_activeMonitor->parentWidget()->raise();
201 emit checkColorScopes();
204 void MonitorManager::slotRefreshCurrentMonitor()
206 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->refreshMonitor();
207 else m_projectMonitor->refreshMonitor();
210 void MonitorManager::slotUpdateAudioMonitoring()
212 // if(...) added since they are 0x0 when the config wizard is running! --Granjow
214 m_clipMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
216 if (m_projectMonitor) {
217 m_projectMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
221 void MonitorManager::clearScopeSource()
226 void MonitorManager::updateScopeSource()
228 emit checkColorScopes();
231 AbstractRender *MonitorManager::activeRenderer()
233 if (m_activeMonitor) {
234 return m_activeMonitor->abstractRender();
239 #include "monitormanager.moc"