X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmonitormanager.cpp;h=1b0a7c6fb278400d20a2867947a0648408ea4681;hb=91792a57eb3511443f5ec585dbfb0af9775e45df;hp=a8045c1d0543acbe0b217969b4f20e978923d072;hpb=a31b56a148d40ac6757ef95245dc259cd79cfa57;p=kdenlive diff --git a/src/monitormanager.cpp b/src/monitormanager.cpp index a8045c1d..1b0a7c6f 100644 --- a/src/monitormanager.cpp +++ b/src/monitormanager.cpp @@ -18,105 +18,216 @@ ***************************************************************************/ -#include -#include - #include "monitormanager.h" -#include +#include "renderer.h" +#include "kdenlivesettings.h" -MonitorManager::MonitorManager(QWidget *parent) - : QObject(parent) { -} +#include -void MonitorManager::setTimecode(Timecode tc) { - m_timecode = tc; +#include +#include +#include + +MonitorManager::MonitorManager(QWidget *parent) : + QObject(parent), + m_clipMonitor(NULL), + m_projectMonitor(NULL), + m_activeMonitor(NULL) +{ } -Timecode MonitorManager::timecode() { +Timecode MonitorManager::timecode() +{ return m_timecode; } -void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor) { +void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor, RecMonitor *recMonitor) +{ m_clipMonitor = clipMonitor; m_projectMonitor = projectMonitor; + + m_monitorsList.append(clipMonitor); + m_monitorsList.append(projectMonitor); + if (recMonitor) + m_monitorsList.append(recMonitor); +} + +void MonitorManager::appendMonitor(AbstractMonitor *monitor) +{ + if (!m_monitorsList.contains(monitor)) m_monitorsList.append(monitor); } -bool MonitorManager::projectMonitorFocused() { - if (m_activeMonitor != "clip") return true; - return false; +void MonitorManager::removeMonitor(AbstractMonitor *monitor) +{ + m_monitorsList.removeAll(monitor); } -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); +bool MonitorManager::activateMonitor(const QString &name) +{ + if (m_clipMonitor == NULL || m_projectMonitor == NULL) + return false; + if (m_activeMonitor && m_activeMonitor->name() == name) + return false; + m_activeMonitor = NULL; + for (int i = 0; i < m_monitorsList.count(); i++) { + if (m_monitorsList.at(i)->name() == name) { + m_activeMonitor = m_monitorsList.at(i); + } + else m_monitorsList.at(i)->stop(); } - m_activeMonitor = name; -} - -void MonitorManager::switchMonitors() { - if (m_activeMonitor == "clip") { - 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); + if (m_activeMonitor) { + m_activeMonitor->blockSignals(true); + m_activeMonitor->parentWidget()->raise(); + m_activeMonitor->start(); + m_activeMonitor->blockSignals(false); } + emit checkColorScopes(); + return (m_activeMonitor != NULL); +} + +bool MonitorManager::isActive(const QString &name) const +{ + return m_activeMonitor ? m_activeMonitor->name() == name: false; } -void MonitorManager::slotPlay() { - if (m_activeMonitor == "clip") m_clipMonitor->slotPlay(); +void MonitorManager::slotSwitchMonitors(bool activateClip) +{ + if (activateClip) + activateMonitor("clip"); + else + activateMonitor("project"); +} + +void MonitorManager::stopActiveMonitor() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->pause(); + else m_projectMonitor->pause(); +} + +void MonitorManager::slotPlay() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlay(); else m_projectMonitor->slotPlay(); } -void MonitorManager::slotRewind(double speed) { - if (m_activeMonitor == "clip") m_clipMonitor->slotRewind(speed); +void MonitorManager::slotPause() +{ + stopActiveMonitor(); +} + +void MonitorManager::slotPlayZone() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotPlayZone(); + else 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_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewind(speed); else m_projectMonitor->slotRewind(speed); } -void MonitorManager::slotForward(double speed) { - if (m_activeMonitor == "clip") m_clipMonitor->slotForward(speed); +void MonitorManager::slotForward(double speed) +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForward(speed); else m_projectMonitor->slotForward(speed); } -void MonitorManager::slotRewindOneFrame() { - if (m_activeMonitor == "clip") m_clipMonitor->slotRewindOneFrame(); +void MonitorManager::slotRewindOneFrame() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(); else m_projectMonitor->slotRewindOneFrame(); } -void MonitorManager::slotForwardOneFrame() { - if (m_activeMonitor == "clip") m_clipMonitor->slotForwardOneFrame(); +void MonitorManager::slotForwardOneFrame() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(); else m_projectMonitor->slotForwardOneFrame(); } -void MonitorManager::slotStart() { - if (m_activeMonitor == "clip") m_clipMonitor->slotStart(); +void MonitorManager::slotRewindOneSecond() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotRewindOneFrame(m_timecode.fps()); + else m_projectMonitor->slotRewindOneFrame(m_timecode.fps()); +} + +void MonitorManager::slotForwardOneSecond() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotForwardOneFrame(m_timecode.fps()); + else m_projectMonitor->slotForwardOneFrame(m_timecode.fps()); +} + +void MonitorManager::slotStart() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotStart(); else m_projectMonitor->slotStart(); } -void MonitorManager::slotEnd() { - if (m_activeMonitor == "clip") m_clipMonitor->slotEnd(); +void MonitorManager::slotEnd() +{ + if (m_activeMonitor == m_clipMonitor) m_clipMonitor->slotEnd(); else m_projectMonitor->slotEnd(); } -void MonitorManager::resetProfiles(QString prof) { - activateMonitor("clip"); - m_clipMonitor->resetProfile(prof); - activateMonitor("project"); - m_projectMonitor->resetProfile(prof); - //m_projectMonitor->refreshMonitor(true); +void MonitorManager::resetProfiles(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); + QString active = m_activeMonitor ? m_activeMonitor->name() : QString(); + m_clipMonitor->resetProfile(KdenliveSettings::current_profile()); + m_projectMonitor->resetProfile(KdenliveSettings::current_profile()); + if (!active.isEmpty()) activateMonitor(active); + blockSignals(false); + if (m_activeMonitor) m_activeMonitor->parentWidget()->raise(); + emit checkColorScopes(); +} + +void MonitorManager::slotRefreshCurrentMonitor() +{ + 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(); + } +} + +void MonitorManager::clearScopeSource() +{ + emit clearScopes(); +} + +void MonitorManager::updateScopeSource() +{ + emit checkColorScopes(); +} + +AbstractRender *MonitorManager::activeRenderer() +{ + if (m_activeMonitor) { + return m_activeMonitor->abstractRender(); + } + return NULL; } #include "monitormanager.moc"