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