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