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 AbstractMonitor* MonitorManager::monitor(Kdenlive::MONITORID monitorName)
68 AbstractMonitor *monitor = NULL;
69 for (int i = 0; i < m_monitorsList.size(); i++) {
70 if (m_monitorsList[i]->id() == monitorName) {
71 monitor = m_monitorsList[i];
77 bool MonitorManager::activateMonitor(Kdenlive::MONITORID name, bool forceRefresh)
79 if (m_clipMonitor == NULL || m_projectMonitor == NULL)
81 if (m_activeMonitor && m_activeMonitor->id() == name) {
82 if (forceRefresh) m_activeMonitor->start();
85 m_activeMonitor = NULL;
86 for (int i = 0; i < m_monitorsList.count(); i++) {
87 if (m_monitorsList.at(i)->id() == name) {
88 m_activeMonitor = m_monitorsList.at(i);
90 else m_monitorsList.at(i)->stop();
92 if (m_activeMonitor) {
93 m_activeMonitor->blockSignals(true);
94 m_activeMonitor->parentWidget()->raise();
95 m_activeMonitor->start();
96 m_activeMonitor->blockSignals(false);
98 emit checkColorScopes();
99 return (m_activeMonitor != NULL);
102 bool MonitorManager::isActive(Kdenlive::MONITORID id) const
104 return m_activeMonitor ? m_activeMonitor->id() == id: false;
107 void MonitorManager::slotSwitchMonitors(bool activateClip)
110 activateMonitor(Kdenlive::clipMonitor);
112 activateMonitor(Kdenlive::projectMonitor);
115 void MonitorManager::stopActiveMonitor()
117 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->pause();
118 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->pause();
121 void MonitorManager::slotPlay()
123 if (m_activeMonitor) m_activeMonitor->slotPlay();
126 void MonitorManager::slotPause()
131 void MonitorManager::slotPlayZone()
133 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlayZone();
134 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotPlayZone();
137 void MonitorManager::slotLoopZone()
139 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotLoopZone();
140 else m_projectMonitor->slotLoopZone();
143 void MonitorManager::slotRewind(double speed)
145 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewind(speed);
146 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotRewind(speed);
149 void MonitorManager::slotForward(double speed)
151 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForward(speed);
152 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotForward(speed);
155 void MonitorManager::slotRewindOneFrame()
157 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame();
158 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotRewindOneFrame();
161 void MonitorManager::slotForwardOneFrame()
163 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame();
164 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotForwardOneFrame();
167 void MonitorManager::slotRewindOneSecond()
169 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
170 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
173 void MonitorManager::slotForwardOneSecond()
175 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
176 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
179 void MonitorManager::slotStart()
181 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotStart();
182 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotStart();
185 void MonitorManager::slotEnd()
187 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotEnd();
188 else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotEnd();
191 void MonitorManager::resetProfiles(Timecode tc)
195 //QTimer::singleShot(300, this, SLOT(slotResetProfiles()));
198 void MonitorManager::slotResetProfiles()
200 if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
202 Kdenlive::MONITORID active = m_activeMonitor ? m_activeMonitor->id() : Kdenlive::noMonitor;
203 m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
204 m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
205 if (active != Kdenlive::noMonitor) activateMonitor(active);
207 if (m_activeMonitor) m_activeMonitor->parentWidget()->raise();
208 emit checkColorScopes();
211 void MonitorManager::slotRefreshCurrentMonitor(const QString &id)
213 // Clip producer was modified, check if clip is currently displayed in clip monitor
214 m_clipMonitor->reloadProducer(id);
215 if (m_activeMonitor == m_clipMonitor) m_clipMonitor->refreshMonitor();
216 else m_projectMonitor->refreshMonitor();
219 void MonitorManager::slotUpdateAudioMonitoring()
221 // if(...) added since they are 0x0 when the config wizard is running! --Granjow
222 /*if (m_clipMonitor) {
223 m_clipMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
225 if (m_projectMonitor) {
226 m_projectMonitor->render->analyseAudio = KdenliveSettings::monitor_audio();
228 for (int i = 0; i < m_monitorsList.count(); i++) {
229 if (m_monitorsList.at(i)->abstractRender()) m_monitorsList.at(i)->abstractRender()->analyseAudio = KdenliveSettings::monitor_audio();
233 void MonitorManager::clearScopeSource()
238 void MonitorManager::updateScopeSource()
240 emit checkColorScopes();
243 AbstractRender *MonitorManager::activeRenderer()
245 if (m_activeMonitor) {
246 return m_activeMonitor->abstractRender();
251 void MonitorManager::slotSwitchFullscreen()
253 if (m_activeMonitor) m_activeMonitor->slotSwitchFullScreen();
256 #include "monitormanager.moc"