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>
32 MonitorManager::MonitorManager(QWidget *parent) :
35 m_projectMonitor(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 bool MonitorManager::activateMonitor(const QString &name)
68 if (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->blockSignals(true);
81 m_activeMonitor->parentWidget()->raise();
82 m_activeMonitor->start();
83 m_activeMonitor->blockSignals(false);
85 emit checkColorScopes();
86 return (m_activeMonitor != NULL);
89 bool MonitorManager::isActive(const QString &name) const
91 return m_activeMonitor ? m_activeMonitor->name() == name: false;
94 void MonitorManager::slotSwitchMonitors(bool activateClip)
97 activateMonitor("clip");
99 activateMonitor("project");
102 void MonitorManager::stopActiveMonitor()
104 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->pause();
105 else m_projectMonitor->pause();
108 void MonitorManager::slotPlay()
110 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlay();
111 else m_projectMonitor->slotPlay();
114 void MonitorManager::slotPause()
119 void MonitorManager::slotPlayZone()
121 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlayZone();
122 else m_projectMonitor->slotPlayZone();
125 void MonitorManager::slotLoopZone()
127 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotLoopZone();
128 else m_projectMonitor->slotLoopZone();
131 void MonitorManager::slotRewind(double speed)
133 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewind(speed);
134 else m_projectMonitor->slotRewind(speed);
137 void MonitorManager::slotForward(double speed)
139 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForward(speed);
140 else m_projectMonitor->slotForward(speed);
143 void MonitorManager::slotRewindOneFrame()
145 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame();
146 else m_projectMonitor->slotRewindOneFrame();
149 void MonitorManager::slotForwardOneFrame()
151 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame();
152 else m_projectMonitor->slotForwardOneFrame();
155 void MonitorManager::slotRewindOneSecond()
157 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
158 else m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
161 void MonitorManager::slotForwardOneSecond()
163 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
164 else m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
167 void MonitorManager::slotStart()
169 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotStart();
170 else m_projectMonitor->slotStart();
173 void MonitorManager::slotEnd()
175 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotEnd();
176 else m_projectMonitor->slotEnd();
179 void MonitorManager::resetProfiles(Timecode tc)
183 //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
186 void MonitorManager::slotResetProfiles()
188 if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
190 QString active = m_activeMonitor ? m_activeMonitor->name() : QString();
191 m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
192 m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
193 if (!active.isEmpty()) activateMonitor(active);
195 if (m_activeMonitor) m_activeMonitor->parentWidget()->raise();
196 emit checkColorScopes();
199 void MonitorManager::slotRefreshCurrentMonitor(const QString &id)
201 // Clip producer was modified, check if clip is currently displayed in clip monitor
202 m_clipMonitor->reloadProducer(id);
203 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->refreshMonitor();
204 else m_projectMonitor->refreshMonitor();
207 void MonitorManager::slotUpdateAudioMonitoring()
209 // if(...) added since they are 0x0 when the config wizard is running! --Granjow
211 m_clipMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
213 if (m_projectMonitor) {
214 m_projectMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
218 void MonitorManager::clearScopeSource()
223 void MonitorManager::updateScopeSource()
225 emit checkColorScopes();
228 AbstractRender *MonitorManager::activeRenderer()
230 if (m_activeMonitor) {
231 return m_activeMonitor->abstractRender();
236 #include "monitormanager.moc"