]> git.sesse.net Git - kdenlive/blob - src/monitor.h
Exit fullscreen mode with Esc
[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 #ifndef MONITOR_H
21 #define MONITOR_H
22
23 #include <QLabel>
24
25 #include <KIcon>
26 #include <KAction>
27 #include <KRestrictedLine>
28 #include <QDomElement>
29
30 #include "gentime.h"
31 #include "timecodedisplay.h"
32 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
33 #include "videoglwidget.h"
34 #endif
35
36 class MonitorManager;
37 class Render;
38 class SmallRuler;
39 class DocClipBase;
40 class MonitorScene;
41 class AbstractClipItem;
42 class Transition;
43 class ClipItem;
44 class QGraphicsView;
45 class QGraphicsPixmapItem;
46
47 class Monitor;
48
49 class VideoContainer : public QFrame
50 {
51     Q_OBJECT
52 public:
53     VideoContainer(Monitor *parent = 0);
54     void switchFullScreen();
55
56 protected:
57     virtual void mouseDoubleClickEvent(QMouseEvent * event);
58     virtual void mousePressEvent(QMouseEvent * event);
59     virtual void mouseReleaseEvent(QMouseEvent *event);
60     virtual void mouseMoveEvent(QMouseEvent *event);
61     void keyPressEvent(QKeyEvent *event);
62     virtual void wheelEvent(QWheelEvent * event);
63
64 private:
65     Qt::WindowFlags m_baseFlags;
66     Monitor *m_monitor;
67 };
68
69 class MonitorRefresh : public QWidget
70 {
71     Q_OBJECT
72 public:
73     MonitorRefresh(QWidget *parent = 0);
74     void setRenderer(Render* render);
75
76 protected:
77     virtual void paintEvent(QPaintEvent *event);
78
79 private:
80     Render *m_renderer;
81
82 signals:
83     void switchFullScreen();
84     void switchPlay();
85     void mouseSeek(int, bool);
86 };
87
88 class Overlay : public QLabel
89 {
90     Q_OBJECT
91 public:
92     Overlay(QWidget* parent);
93     void setOverlayText(const QString &, bool isZone = true);
94
95 private:
96     bool m_isZone;
97 };
98
99 class Monitor : public QWidget
100 {
101     Q_OBJECT
102
103 public:
104     Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
105     virtual ~Monitor();
106     Render *render;
107     void resetProfile(const QString profile);
108     QString name() const;
109     void resetSize();
110     bool isActive() const;
111     void pause();
112     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
113     const QString sceneList();
114     DocClipBase *activeClip();
115     GenTime position();
116     void checkOverlay();
117     void updateTimecodeFormat();
118     void updateMarkers(DocClipBase *source);
119     MonitorScene *getEffectScene();
120     QWidget *container();
121
122 protected:
123     virtual void mousePressEvent(QMouseEvent * event);
124     virtual void mouseReleaseEvent(QMouseEvent * event);
125
126     /** @brief Move to another position on mouse wheel event.
127      *
128      * Moves towards the end of the clip/timeline on mouse wheel down/back, the
129      * opposite on mouse wheel up/forward.
130      * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
131     virtual void wheelEvent(QWheelEvent * event);
132     virtual void mouseMoveEvent(QMouseEvent *event);
133     virtual QStringList mimeTypes() const;
134     /*virtual void dragMoveEvent(QDragMoveEvent * event);
135     virtual Qt::DropActions supportedDropActions() const;*/
136
137     //virtual void resizeEvent(QResizeEvent * event);
138     //virtual void paintEvent(QPaintEvent * event);
139
140 private:
141     QString m_name;
142     MonitorManager *m_monitorManager;
143     DocClipBase *m_currentClip;
144     SmallRuler *m_ruler;
145     Overlay *m_overlay;
146     bool m_isActive;
147     double m_scale;
148     int m_length;
149     bool m_dragStarted;
150     MonitorRefresh *m_monitorRefresh;
151     KIcon m_playIcon;
152     KIcon m_pauseIcon;
153     TimecodeDisplay *m_timePos;
154     QAction *m_playAction;
155     /** Has to be available so we can enable and disable it. */
156     QAction *m_loopClipAction;
157     QMenu *m_contextMenu;
158     QMenu *m_configMenu;
159     QMenu *m_playMenu;
160     QMenu *m_markerMenu;
161     QPoint m_DragStartPosition;
162     MonitorScene *m_effectScene;
163     QGraphicsView *m_effectView;
164     VideoContainer *m_videoBox;
165     /** Selected clip/transition in timeline. Used for looping it. */
166     AbstractClipItem *m_selectedClip;
167     /** true if selected clip is transition, false = selected clip is clip.
168      *  Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
169     bool m_loopClipTransition;
170 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
171     VideoGLWidget *m_glWidget;
172     bool createOpenGlWidget(QWidget *parent, const QString profile);
173 #endif
174
175     GenTime getSnapForPos(bool previous);
176     Qt::WindowFlags m_baseFlags;
177
178 private slots:
179     void seekCursor(int pos);
180     void rendererStopped(int pos);
181     void slotExtractCurrentFrame();
182     void slotSetThumbFrame();
183     void slotSetSizeOneToOne();
184     void slotSetSizeOneToTwo();
185     void slotSaveZone();
186     void slotSeek();
187     void setClipZone(QPoint pos);
188     void slotSwitchMonitorInfo(bool show);
189     void slotSwitchDropFrames(bool show);
190     void slotGoToMarker(QAction *action);
191
192 public slots:
193     void slotOpenFile(const QString &);
194     void slotSetXml(DocClipBase *clip, QPoint zone = QPoint(), const int position = -1);
195     void refreshMonitor(bool visible);
196     void refreshMonitor();
197     void slotSeek(int pos);
198     void stop();
199     void start();
200     void activateMonitor();
201     void slotPlay();
202     void slotPlayZone();
203     void slotLoopZone();
204     /** @brief Loops the selected item (clip or transition). */
205     void slotLoopClip();
206     void slotForward(double speed = 0);
207     void slotRewind(double speed = 0);
208     void slotRewindOneFrame(int diff = 1);
209     void slotForwardOneFrame(int diff = 1);
210     void saveSceneList(QString path, QDomElement info = QDomElement());
211     void slotStart();
212     void slotEnd();
213     void slotSetZoneStart();
214     void slotSetZoneEnd();
215     void slotZoneStart();
216     void slotZoneEnd();
217     void slotZoneMoved(int start, int end);
218     void slotSeekToNextSnap();
219     void slotSeekToPreviousSnap();
220     void adjustRulerSize(int length);
221     void setTimePos(const QString &pos);
222     QStringList getZoneInfo() const;
223     void slotEffectScene(bool show = true);
224     bool effectSceneDisplayed();
225
226     /** @brief Sets m_selectedClip to @param item. Used for looping it. */
227     void slotSetSelectedClip(AbstractClipItem *item);
228     void slotSetSelectedClip(ClipItem *item);
229     void slotSetSelectedClip(Transition *item);
230     void slotMouseSeek(int eventDelta, bool fast);
231     void slotSwitchFullScreen();
232
233 signals:
234     void renderPosition(int);
235     void durationChanged(int);
236     void refreshClipThumbnail(const QString &);
237     void adjustMonitorSize();
238     void zoneUpdated(QPoint);
239     void saveZone(Render *, QPoint);
240     /** @brief  Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
241      *      This causes a major slowdown, so we only enable it if required */
242     void requestFrameForAnalysis(bool);
243 };
244
245 #endif