]> git.sesse.net Git - kdenlive/blob - src/monitormanager.cpp
0800fe95a31a5b1a439cc9df3d032063b8a14d8d
[kdenlive] / src / monitormanager.cpp
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20
21 #include <QObject>
22 #include <QTimer>
23
24 #include <mlt++/Mlt.h>
25
26 #include "monitormanager.h"
27 #include "kdenlivesettings.h"
28
29 MonitorManager::MonitorManager(QWidget *parent)
30         : QObject(parent) {
31 }
32
33 Timecode MonitorManager::timecode() {
34     return m_timecode;
35 }
36
37 void MonitorManager::initMonitors(Monitor *clipMonitor, Monitor *projectMonitor) {
38     m_clipMonitor = clipMonitor;
39     m_projectMonitor = projectMonitor;
40 }
41
42 void MonitorManager::activateMonitor(QString name) {
43     if (m_activeMonitor == name) return;
44     if (name == "clip") {
45         m_projectMonitor->stop();
46         m_clipMonitor->start();
47         emit raiseClipMonitor(true);
48     } else {
49         m_clipMonitor->stop();
50         m_projectMonitor->start();
51         m_projectMonitor->raise();
52         emit raiseClipMonitor(false);
53     }
54     m_activeMonitor = name;
55 }
56
57 void MonitorManager::switchMonitors() {
58     if (m_clipMonitor->isActive()) {
59         m_clipMonitor->stop();
60         m_projectMonitor->start();
61         m_projectMonitor->raise();
62         m_activeMonitor = m_projectMonitor->name();
63         emit raiseClipMonitor(false);
64     } else {
65         m_projectMonitor->stop();
66         m_clipMonitor->start();
67         m_activeMonitor = m_clipMonitor->name();
68         emit raiseClipMonitor(true);
69     }
70 }
71
72 void MonitorManager::stopActiveMonitor() {
73     if (m_clipMonitor->isActive()) m_clipMonitor->pause();
74     else m_projectMonitor->pause();
75 }
76
77 void MonitorManager::slotPlay() {
78     if (m_clipMonitor->isActive()) m_clipMonitor->slotPlay();
79     else m_projectMonitor->slotPlay();
80 }
81
82 void MonitorManager::slotPlayZone() {
83     if (m_clipMonitor->isActive()) m_clipMonitor->slotPlayZone();
84     else m_projectMonitor->slotPlayZone();
85 }
86
87 void MonitorManager::slotLoopZone() {
88     if (m_clipMonitor->isActive()) m_clipMonitor->slotLoopZone();
89     else m_projectMonitor->slotLoopZone();
90 }
91
92 void MonitorManager::slotRewind(double speed) {
93     if (m_clipMonitor->isActive()) m_clipMonitor->slotRewind(speed);
94     else m_projectMonitor->slotRewind(speed);
95 }
96
97 void MonitorManager::slotForward(double speed) {
98     if (m_clipMonitor->isActive()) m_clipMonitor->slotForward(speed);
99     else m_projectMonitor->slotForward(speed);
100 }
101
102 void MonitorManager::slotRewindOneFrame() {
103     if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame();
104     else m_projectMonitor->slotRewindOneFrame();
105 }
106
107 void MonitorManager::slotForwardOneFrame() {
108     if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame();
109     else m_projectMonitor->slotForwardOneFrame();
110 }
111
112 void MonitorManager::slotRewindOneSecond() {
113     if (m_clipMonitor->isActive()) m_clipMonitor->slotRewindOneFrame(m_timecode.fps());
114     else m_projectMonitor->slotRewindOneFrame(m_timecode.fps());
115 }
116
117 void MonitorManager::slotForwardOneSecond() {
118     if (m_clipMonitor->isActive()) m_clipMonitor->slotForwardOneFrame(m_timecode.fps());
119     else m_projectMonitor->slotForwardOneFrame(m_timecode.fps());
120 }
121
122 void MonitorManager::slotStart() {
123     if (m_clipMonitor->isActive()) m_clipMonitor->slotStart();
124     else m_projectMonitor->slotStart();
125 }
126
127 void MonitorManager::slotEnd() {
128     if (m_clipMonitor->isActive()) m_clipMonitor->slotEnd();
129     else m_projectMonitor->slotEnd();
130 }
131
132 void MonitorManager::resetProfiles(Timecode tc) {
133     m_timecode = tc;
134     slotResetProfiles();
135 }
136
137 void MonitorManager::slotResetProfiles() {
138     activateMonitor("clip");
139     m_clipMonitor->resetProfile();
140     activateMonitor("project");
141     m_projectMonitor->resetProfile();
142     //m_projectMonitor->refreshMonitor(true);
143 }
144
145 #include "monitormanager.moc"