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