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