X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmonitormanager.cpp;h=b05b1da42791e15db987f4adca00546ee0e7613d;hb=c24658bd34221d735f0641c924b890e1a6be7101;hp=8788f385f335f8e3adb595aae1fc92966c712410;hpb=7caecc149e65907e4a57c8115c7cac12042e9308;p=kdenlive diff --git a/src/monitormanager.cpp b/src/monitormanager.cpp index 8788f385..b05b1da4 100644 --- a/src/monitormanager.cpp +++ b/src/monitormanager.cpp @@ -18,126 +18,268 @@ ***************************************************************************/ +#include "monitormanager.h" +#include "renderer.h" +#include "kdenlivesettings.h" +#include "kdenlivedoc.h" + +#include + #include #include +#include -#include "monitormanager.h" -#include -MonitorManager::MonitorManager(QWidget *parent) - : QObject(parent) { +MonitorManager::MonitorManager(QWidget *parent) : + QObject(parent), + m_document(NULL), + m_clipMonitor(NULL), + m_projectMonitor(NULL), + m_activeMonitor(NULL) +{ } -Timecode MonitorManager::timecode() { +Timecode MonitorManager::timecode() const +{ return m_timecode; } -void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor) { +void MonitorManager::setDocument(KdenliveDoc *doc) +{ + m_document = doc; +} + +void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor, RecMonitor *recMonitor) +{ m_clipMonitor = clipMonitor; m_projectMonitor = projectMonitor; + + connect(m_clipMonitor->render, SIGNAL(activateMonitor(Kdenlive::MonitorId)), this, SLOT(activateMonitor(Kdenlive::MonitorId))); + connect(m_projectMonitor->render, SIGNAL(activateMonitor(Kdenlive::MonitorId)), this, SLOT(activateMonitor(Kdenlive::MonitorId))); + + m_monitorsList.append(clipMonitor); + m_monitorsList.append(projectMonitor); + if (recMonitor) + m_monitorsList.append(recMonitor); } -void MonitorManager::activateMonitor(QString name) { - if (m_activeMonitor == name) return; - if (name == "clip") { - m_projectMonitor->stop(); - m_clipMonitor->start(); - emit raiseClipMonitor(true); - } else { - m_clipMonitor->stop(); - m_projectMonitor->start(); - m_projectMonitor->raise(); - emit raiseClipMonitor(false); +void MonitorManager::appendMonitor(AbstractMonitor *monitor) +{ + if (!m_monitorsList.contains(monitor)) m_monitorsList.append(monitor); +} + +void MonitorManager::removeMonitor(AbstractMonitor *monitor) +{ + m_monitorsList.removeAll(monitor); +} + +AbstractMonitor* MonitorManager::monitor(Kdenlive::MonitorId monitorName) +{ + AbstractMonitor *monitor = NULL; + for (int i = 0; i < m_monitorsList.size(); ++i) { + if (m_monitorsList[i]->id() == monitorName) { + monitor = m_monitorsList.at(i); + } + } + return monitor; +} + +void MonitorManager::setConsumerProperty(const QString &name, const QString &value) +{ + if (m_clipMonitor) m_clipMonitor->render->setConsumerProperty(name, value); + if (m_projectMonitor) m_projectMonitor->render->setConsumerProperty(name, value); +} + +bool MonitorManager::activateMonitor(Kdenlive::MonitorId name, bool forceRefresh) +{ + if (m_clipMonitor == NULL || m_projectMonitor == NULL) + return false; + if (m_activeMonitor && m_activeMonitor->id() == name) { + if (forceRefresh) m_activeMonitor->start(); + return false; } - m_activeMonitor = name; -} - -void MonitorManager::switchMonitors() { - if (m_clipMonitor->isActive()) { - m_clipMonitor->stop(); - m_projectMonitor->start(); - m_projectMonitor->raise(); - m_activeMonitor = m_projectMonitor->name(); - emit raiseClipMonitor(false); - } else { - m_projectMonitor->stop(); - m_clipMonitor->start(); - m_activeMonitor = m_clipMonitor->name(); - emit raiseClipMonitor(true); + m_activeMonitor = NULL; + for (int i = 0; i < m_monitorsList.count(); ++i) { + if (m_monitorsList.at(i)->id() == name) { + m_activeMonitor = m_monitorsList.at(i); + } + else m_monitorsList.at(i)->stop(); } + if (m_activeMonitor) { + m_activeMonitor->blockSignals(true); + m_activeMonitor->parentWidget()->raise(); + m_activeMonitor->blockSignals(false); + m_activeMonitor->start(); + + } + emit checkColorScopes(); + return (m_activeMonitor != NULL); +} + +bool MonitorManager::isActive(Kdenlive::MonitorId id) const +{ + return m_activeMonitor ? m_activeMonitor->id() == id: false; +} + +void MonitorManager::slotSwitchMonitors(bool activateClip) +{ + if (activateClip) + activateMonitor(Kdenlive::ClipMonitor); + else + activateMonitor(Kdenlive::ProjectMonitor); } -void MonitorManager::stopActiveMonitor() { - if (m_clipMonitor->isActive()) m_clipMonitor->pause(); - else m_projectMonitor->pause(); +void MonitorManager::stopActiveMonitor() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->pause(); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->pause(); } -void MonitorManager::slotPlay() { - if (m_clipMonitor->isActive()) m_clipMonitor->slotPlay(); - else m_projectMonitor->slotPlay(); +void MonitorManager::slotPlay() +{ + if (m_activeMonitor) m_activeMonitor->slotPlay(); } -void MonitorManager::slotPlayZone() { - if (m_clipMonitor->isActive()) m_clipMonitor->slotPlayZone(); - else m_projectMonitor->slotPlayZone(); +void MonitorManager::slotPause() +{ + stopActiveMonitor(); } -void MonitorManager::slotLoopZone() { - if (m_clipMonitor->isActive()) m_clipMonitor->slotLoopZone(); +void MonitorManager::slotPlayZone() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlayZone(); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotPlayZone(); +} + +void MonitorManager::slotLoopZone() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotLoopZone(); else m_projectMonitor->slotLoopZone(); } -void MonitorManager::slotRewind(double speed) { - if (m_clipMonitor->isActive()) m_clipMonitor->slotRewind(speed); - else m_projectMonitor->slotRewind(speed); +void MonitorManager::slotRewind(double speed) +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewind(speed); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotRewind(speed); } -void MonitorManager::slotForward(double speed) { - if (m_clipMonitor->isActive()) m_clipMonitor->slotForward(speed); - else m_projectMonitor->slotForward(speed); +void MonitorManager::slotForward(double speed) +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForward(speed); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotForward(speed); } -void MonitorManager::slotRewindOneFrame() { - if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame(); - else m_projectMonitor->slotRewindOneFrame(); +void MonitorManager::slotRewindOneFrame() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotRewindOneFrame(); } -void MonitorManager::slotForwardOneFrame() { - if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame(); - else m_projectMonitor->slotForwardOneFrame(); +void MonitorManager::slotForwardOneFrame() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotForwardOneFrame(); } -void MonitorManager::slotRewindOneSecond() { - if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame(m_timecode.fps()); - else m_projectMonitor->slotRewindOneFrame(m_timecode.fps()); +void MonitorManager::slotRewindOneSecond() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(m_timecode.fps()); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotRewindOneFrame(m_timecode.fps()); } -void MonitorManager::slotForwardOneSecond() { - if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame(m_timecode.fps()); - else m_projectMonitor->slotForwardOneFrame(m_timecode.fps()); +void MonitorManager::slotForwardOneSecond() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(m_timecode.fps()); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotForwardOneFrame(m_timecode.fps()); } -void MonitorManager::slotStart() { - if (m_clipMonitor->isActive()) m_clipMonitor->slotStart(); - else m_projectMonitor->slotStart(); +void MonitorManager::slotStart() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotStart(); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotStart(); } -void MonitorManager::slotEnd() { - if (m_clipMonitor->isActive()) m_clipMonitor->slotEnd(); - else m_projectMonitor->slotEnd(); +void MonitorManager::slotEnd() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotEnd(); + else if (m_activeMonitor == m_projectMonitor) m_projectMonitor->slotEnd(); } -void MonitorManager::resetProfiles(Timecode tc) { +void MonitorManager::resetProfiles(const Timecode &tc) +{ m_timecode = tc; slotResetProfiles(); + //QTimer::singleShot(300, this, SLOT(slotResetProfiles())); +} + +void MonitorManager::slotResetProfiles() +{ + if (m_projectMonitor == NULL || m_clipMonitor == NULL) { + return; + } + blockSignals(true); + Kdenlive::MonitorId active = m_activeMonitor ? m_activeMonitor->id() : Kdenlive::NoMonitor; + m_clipMonitor->resetProfile(KdenliveSettings::current_profile()); + m_projectMonitor->resetProfile(KdenliveSettings::current_profile()); + if (active != Kdenlive::NoMonitor) activateMonitor(active); + blockSignals(false); + if (m_activeMonitor) m_activeMonitor->parentWidget()->raise(); + emit checkColorScopes(); +} + +void MonitorManager::slotRefreshCurrentMonitor(const QString &id) +{ + // Clip producer was modified, check if clip is currently displayed in clip monitor + m_clipMonitor->reloadProducer(id); + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->refreshMonitor(); + else m_projectMonitor->refreshMonitor(); +} + +void MonitorManager::slotUpdateAudioMonitoring() +{ + // if(...) added since they are 0x0 when the config wizard is running! --Granjow + /*if (m_clipMonitor) { + m_clipMonitor->render->analyseAudio = KdenliveSettings::monitor_audio(); + } + if (m_projectMonitor) { + m_projectMonitor->render->analyseAudio = KdenliveSettings::monitor_audio(); + }*/ + for (int i = 0; i < m_monitorsList.count(); ++i) { + if (m_monitorsList.at(i)->abstractRender()) m_monitorsList.at(i)->abstractRender()->analyseAudio = KdenliveSettings::monitor_audio(); + } } -void MonitorManager::slotResetProfiles() { - activateMonitor("clip"); - m_clipMonitor->resetProfile(); - activateMonitor("project"); - m_projectMonitor->resetProfile(); - //m_projectMonitor->refreshMonitor(true); +void MonitorManager::clearScopeSource() +{ + emit clearScopes(); } +void MonitorManager::updateScopeSource() +{ + emit checkColorScopes(); +} + +AbstractRender *MonitorManager::activeRenderer() +{ + if (m_activeMonitor) { + return m_activeMonitor->abstractRender(); + } + return NULL; +} + +void MonitorManager::slotSwitchFullscreen() +{ + if (m_activeMonitor) m_activeMonitor->slotSwitchFullScreen(); +} + +QString MonitorManager::getProjectFolder() const +{ + if (m_document == NULL) { + kDebug()<<" + + +NULL DOC!!"; + return QString(); + } + return m_document->projectFolder().path(KUrl::AddTrailingSlash); +} + + #include "monitormanager.moc"