]> git.sesse.net Git - kdenlive/blob - src/stopmotion/stopmotion.h
Missing files from scope manager merge
[kdenlive] / src / stopmotion / stopmotion.h
1 /***************************************************************************
2                           titlewidget.h  -  description
3                              -------------------
4     begin                : Feb 28 2008
5     copyright            : (C) 2008 by Marco Gittler
6     email                : g.marco@freenet.de
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #ifndef STOPMOTION_H
19 #define STOPMOTION_H
20
21 #include "ui_stopmotion_ui.h"
22
23 #include <KUrl>
24 #include <QLabel>
25 #include <QFuture>
26 #include <QVBoxLayout>
27 #include <QTimer>
28 #include <abstractmonitor.h>
29
30 class MltDeviceCapture;
31 class MonitorManager;
32 class VideoPreviewContainer;
33 class MltVideoProfile;
34
35 class MyLabel : public QLabel
36 {
37     Q_OBJECT
38 public:
39     MyLabel(QWidget* parent = 0);
40     void setImage(QImage img);
41
42 protected:
43     virtual void paintEvent(QPaintEvent* event);
44     virtual void wheelEvent(QWheelEvent* event);
45     virtual void mousePressEvent(QMouseEvent*);
46
47 private:
48     QImage m_img;
49
50 signals:
51     /** @brief Seek to next or previous frame.
52      *  @param forward set to true to go to next frame, fals to go to previous frame */
53     void seek(bool forward);
54
55     /** @brief Switch to live view. */
56     void switchToLive();
57 };
58
59
60 class StopmotionMonitor : public AbstractMonitor
61 {
62     Q_OBJECT
63 public:
64     StopmotionMonitor(QWidget *parent);
65     ~StopmotionMonitor();
66     AbstractRender *abstractRender();
67     const QString name() const;
68     void setRender(MltDeviceCapture *render);
69
70 private:
71     MltDeviceCapture *m_captureDevice;
72
73 public slots:
74     virtual void stop();
75     virtual void start();
76
77 signals:
78     void stopCapture();
79 };
80
81
82 class StopmotionWidget : public QDialog, public Ui::Stopmotion_UI
83 {
84     Q_OBJECT
85
86 public:
87
88     /** @brief Build the stopmotion dialog.
89      * @param projectFolder The current project folder, where captured files will be stored.
90      * @param actions The actions for this widget that can have a keyboard shortcut.
91      * @param parent (optional) parent widget */
92     StopmotionWidget(MonitorManager *manager, KUrl projectFolder, QList< QAction* > actions, QWidget* parent = 0);
93     virtual ~StopmotionWidget();
94
95 protected:
96     virtual void closeEvent(QCloseEvent* e);
97
98 private:
99     /** @brief Current project folder (where the captured frames will be saved). */
100     KUrl m_projectFolder;
101
102     /** @brief Capture holder that will handle all video operation. */
103     MltDeviceCapture *m_captureDevice;
104
105     VideoPreviewContainer *m_videoBox;
106
107     /** @brief Holds the name of the current sequence.
108      * Files will be saved in project folder with name: sequence001.png */
109     QString m_sequenceName;
110
111     /** @brief Holds the frame number of the current sequence. */
112     int m_sequenceFrame;
113
114     QAction* m_captureAction;
115
116     /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
117     int m_animatedIndex;
118
119     /** @brief Find all stopmotion sequences in current project folder. */
120     void parseExistingSequences();
121
122     /** @brief Select a frame in the list. */
123     void selectFrame(int ix);
124
125     /** @brief This widget will hold the frame preview. */
126     MyLabel* m_frame_preview;
127
128     /** @brief The list of files in the sequence to create thumbnails. */
129     QStringList m_filesList;
130
131     /** @brief Holds the state of the threaded thumbnail generation. */
132     QFuture<void> m_future;
133
134     /** @brief Get the frame number ix. */
135     QListWidgetItem* getFrameFromIndex(int ix);
136
137     /** @brief The action triggering display of last frame over current live video feed. */
138     QAction* m_showOverlay;
139
140     /** @brief The list of all frames path. */
141     QStringList m_animationList;
142     
143     /** @brief Tells if we are in animation (playback) mode. */
144     bool m_animate;
145     
146     /** @brief Timer for interval capture. */
147     QTimer m_intervalTimer;
148
149     MonitorManager *m_manager;
150
151     /** @brief The monitor is used to control the v4l capture device from the monitormanager class. */
152     StopmotionMonitor *m_monitor;
153
154     /** @brief Create the XML playlist. */
155     const QString createProducer(MltVideoProfile profile, const QString &service, const QString &resource);
156
157     /** @brief A new frame arrived, reload overlay. */
158     void reloadOverlay();
159
160     /** @brief Holds the index of the effect to be applied to the video feed. */
161     int m_effectIndex;
162
163
164 public slots:
165     /** @brief Display the live feed from capture device.
166      @param isOn enable or disable the feature */
167     void slotLive(bool isOn = true);
168     void slotStopCapture();
169
170 private slots:
171
172     /** @brief Display the last captured frame over current live feed.
173      @param isOn enable or disable the feature */
174     void slotShowOverlay(bool isOn);
175
176     /** @brief Display the last captured frame over current live feed. */
177     void slotUpdateOverlay();
178
179     /** @brief User changed the capture name. */
180     void sequenceNameChanged(const QString& name);
181
182     /** @brief Grab a frame from current capture feed. */
183     void slotCaptureFrame();
184
185     /** @brief Display a previous frame in monitor. */
186     void slotShowFrame(const QString& path);
187
188     /** @brief Get full path for a frame in the sequence.
189      *  @param ix the frame number.
190      *  @param seqName (optional) the name of the sequence. */
191     QString getPathForFrame(int ix, QString seqName = QString());
192
193     /** @brief Add sequence to current project. */
194     void slotAddSequence();
195
196     /** @brief Display selected fram in monitor. */
197     void slotShowSelectedFrame();
198
199     /** @brief Start animation preview mode. */
200     void slotPlayPreview(bool animate);
201
202     /** @brief Simulate animation. */
203     void slotAnimate();
204
205     /** @brief Seek to previous or next captured frame.
206      *  @param forward set to true for next frame, false for previous one. */
207     void slotSeekFrame(bool forward);
208
209     /** @brief Display warning / error message from capture backend. */
210     void slotGotHDMIMessage(const QString& message);
211
212     /** @brief Create thumbnails for existing sequence frames. */
213     void slotCreateThumbs(QImage img, int ix);
214
215     /** @brief Prepare thumbnails creation. */
216     void slotPrepareThumbs();
217
218     /** @brief Called when user switches the video capture backend. */
219     void slotUpdateDeviceHandler();
220
221     /** @brief Show / hide sequence thumbnails. */
222     void slotShowThumbs(bool show);
223
224     /** @brief Show the config dialog */
225     void slotConfigure();
226
227     /** @brief Prepare to crete thumb for newly captured frame. */
228     void slotNewThumb(const QString &path);
229
230     /** @brief Set the effect to be applied to overlay frame. */
231     void slotUpdateOverlayEffect(QAction* act);
232
233     /** @brief Switch between live view / currently selected frame. */
234     void slotSwitchLive();
235
236     /** @brief Delete current frame from disk. */
237     void slotRemoveFrame();
238     
239     /** @brief Enable / disable frame analysis (in color scopes). */
240     void slotSwitchAnalyse(bool isOn);
241
242     /** @brief Enable / disable horizontal mirror effect. */
243     void slotSwitchMirror(bool isOn);
244     
245     /** @brief Send a notification a few seconds before capturing. */
246     void slotPreNotify();
247
248 signals:
249     /** @brief Ask to add sequence to current project. */
250     void addOrUpdateSequence(const QString &);
251
252     void doCreateThumbs(QImage, int);
253     void gotFrame(QImage);
254 };
255
256 #endif