]> git.sesse.net Git - kdenlive/blob - src/monitor.h
- Fix split audio with locked audio tracks
[kdenlive] / src / monitor.h
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 #ifndef MONITOR_H
22 #define MONITOR_H
23
24 #include <QLabel>
25
26 #include <KIcon>
27 #include <KAction>
28 #include <KRestrictedLine>
29 #include <QDomElement>
30
31 #include "gentime.h"
32 #include "ui_monitor_ui.h"
33 #include "timecodedisplay.h"
34 #ifdef Q_WS_MAC
35 #include "videoglwidget.h"
36 #endif
37
38 class MonitorManager;
39 class Render;
40 class SmallRuler;
41 class DocClipBase;
42
43 class MonitorRefresh : public QWidget
44 {
45     Q_OBJECT
46 public:
47     MonitorRefresh(QWidget* parent);
48     virtual void paintEvent(QPaintEvent * event);
49     void setRenderer(Render* render);
50
51 private:
52     Render *m_renderer;
53 };
54
55 class Overlay : public QLabel
56 {
57     Q_OBJECT
58 public:
59     Overlay(QWidget* parent);
60     void setOverlayText(const QString &, bool isZone = true);
61
62 private:
63     bool m_isZone;
64 };
65
66 class Monitor : public QWidget
67 {
68     Q_OBJECT
69
70 public:
71     Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
72     virtual ~Monitor();
73     Render *render;
74     void resetProfile(const QString profile);
75     QString name() const;
76     void resetSize();
77     bool isActive() const;
78     void pause();
79     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL);
80     const QString sceneList();
81     DocClipBase *activeClip();
82     GenTime position();
83     void checkOverlay();
84     void updateTimecodeFormat();
85     void updateMarkers(DocClipBase *source);
86
87 protected:
88     virtual void mousePressEvent(QMouseEvent * event);
89     virtual void mouseReleaseEvent(QMouseEvent * event);
90
91     /** @brief Move to another position on mouse wheel event.
92      *
93      * Moves towards the end of the clip/timeline on mouse wheel down/back, the
94      * opposite on mouse wheel up/forward.
95      * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
96     virtual void wheelEvent(QWheelEvent * event);
97     virtual void mouseMoveEvent(QMouseEvent *event);
98     virtual QStringList mimeTypes() const;
99     /*virtual void dragMoveEvent(QDragMoveEvent * event);
100     virtual Qt::DropActions supportedDropActions() const;*/
101
102     //virtual void resizeEvent(QResizeEvent * event);
103     //virtual void paintEvent(QPaintEvent * event);
104
105 private:
106     Ui::Monitor_UI m_ui;
107     QString m_name;
108     MonitorManager *m_monitorManager;
109     DocClipBase *m_currentClip;
110     SmallRuler *m_ruler;
111     Overlay *m_overlay;
112     bool m_isActive;
113     double m_scale;
114     int m_length;
115     bool m_dragStarted;
116     MonitorRefresh *m_monitorRefresh;
117     KIcon m_playIcon;
118     KIcon m_pauseIcon;
119     TimecodeDisplay *m_timePos;
120     QAction *m_playAction;
121     QMenu *m_contextMenu;
122     QMenu *m_configMenu;
123     QMenu *m_playMenu;
124     QMenu *m_markerMenu;
125     QPoint m_DragStartPosition;
126 #ifdef Q_WS_MAC
127     VideoGLWidget *m_glWidget;
128 #endif
129     GenTime getSnapForPos(bool previous);
130
131 private slots:
132     void seekCursor(int pos);
133     void rendererStopped(int pos);
134     void slotExtractCurrentFrame();
135     void slotSetThumbFrame();
136     void slotSetSizeOneToOne();
137     void slotSetSizeOneToTwo();
138     void slotSaveZone();
139     void slotSeek();
140     void setClipZone(QPoint pos);
141     void slotSwitchMonitorInfo(bool show);
142     void slotSwitchDropFrames(bool show);
143     void slotGoToMarker(QAction *action);
144
145 public slots:
146     void slotOpenFile(const QString &);
147     void slotSetXml(DocClipBase *clip, QPoint zone = QPoint(), const int position = -1);
148     void initMonitor();
149     void refreshMonitor(bool visible = true);
150     void slotSeek(int pos);
151     void stop();
152     void start();
153     void activateMonitor();
154     void slotPlay();
155     void slotPlayZone();
156     void slotLoopZone();
157     void slotForward(double speed = 0);
158     void slotRewind(double speed = 0);
159     void slotRewindOneFrame(int diff = 1);
160     void slotForwardOneFrame(int diff = 1);
161     void saveSceneList(QString path, QDomElement info = QDomElement());
162     void slotStart();
163     void slotEnd();
164     void slotSetZoneStart();
165     void slotSetZoneEnd();
166     void slotZoneStart();
167     void slotZoneEnd();
168     void slotZoneMoved(int start, int end);
169     void slotSeekToNextSnap();
170     void slotSeekToPreviousSnap();
171     void adjustRulerSize(int length);
172     void setTimePos(const QString &pos);
173     QStringList getZoneInfo() const;
174
175 signals:
176     void renderPosition(int);
177     void durationChanged(int);
178     void refreshClipThumbnail(const QString &);
179     void adjustMonitorSize();
180     void zoneUpdated(QPoint);
181     void saveZone(Render *, QPoint);
182 };
183
184 #endif