]> git.sesse.net Git - kdenlive/blob - src/stopmotion/stopmotion.h
Stopmotion widget: Improved webcam support, taken from the fswebcam project
[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 #include "../blackmagic/capture.h"
23
24 #include <KUrl>
25 #include <QLabel>
26 #include <QFuture>
27 #include <QVBoxLayout>
28
29 class MyLabel : public QLabel
30 {
31     Q_OBJECT
32 public:
33     MyLabel(QWidget *parent = 0);
34     void setImage(QImage img);
35
36 protected:
37     virtual void paintEvent(QPaintEvent * event);
38     virtual void wheelEvent(QWheelEvent * event);
39     virtual void mousePressEvent(QMouseEvent *);
40
41 private:
42     QImage m_img;
43
44 signals:
45     /** @brief Seek to next or previous frame.
46      *  @param forward set to true to go to next frame, fals to go to previous frame */
47     void seek(bool forward);
48
49     /** @brief Switch to live view. */
50     void switchToLive();
51 };
52
53 class StopmotionWidget : public QDialog , public Ui::Stopmotion_UI
54 {
55     Q_OBJECT
56
57 public:
58
59     /** @brief Build the stopmotion dialog.
60      * @param projectFolder The current project folder, where captured files will be stored.
61      * @param actions The actions for this widget that can have a keyboard shortcut.
62      * @param parent (optional) parent widget */
63     StopmotionWidget(KUrl projectFolder, const QList< QAction * > actions, QWidget *parent = 0);
64     virtual ~StopmotionWidget();
65
66 protected:
67     virtual void closeEvent(QCloseEvent *e);
68
69 private:
70     /** @brief Widget layout holding video and frame preview. */
71     QVBoxLayout *m_layout;
72
73     /** @brief Current project folder (where the captured frames will be saved). */
74     KUrl m_projectFolder;
75
76     /** @brief Capture holder that will handle all video operation. */
77     CaptureHandler *m_bmCapture;
78
79     /** @brief Holds the name of the current sequence.
80      * Files will be saved in project folder with name: sequence001.png */
81     QString m_sequenceName;
82
83     /** @brief Holds the frame number of the current sequence. */
84     int m_sequenceFrame;
85
86     QAction *m_captureAction;
87
88     /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
89     int m_animatedIndex;
90
91     /** @brief Find all stopmotion sequences in current project folder. */
92     void parseExistingSequences();
93
94     /** @brief Select a frame in the list. */
95     void selectFrame(int ix);
96
97     /** @brief This widget will hold the frame preview. */
98     MyLabel *m_frame_preview;
99
100     /** @brief The list of files in the sequence to create thumbnails. */
101     QStringList m_filesList;
102
103     /** @brief Holds the state of the threaded thumbnail generation. */
104     QFuture<void> m_future;
105
106     /** @brief Get the frame number ix. */
107     QListWidgetItem *getFrameFromIndex(int ix);
108
109     /** @brief The action triggering interval capture. */
110     QAction *m_intervalCapture;
111
112     /** @brief The action triggering display of last frame over current live video feed. */
113     QAction *m_showOverlay;
114
115     /** @brief The list of all frames path. */
116     QStringList m_animationList;
117
118
119 #ifdef QIMAGEBLITZ
120     int m_effectIndex;
121 #endif
122
123 public slots:
124     /** @brief Display the live feed from capture device.
125      @param isOn enable or disable the feature */
126     void slotLive(bool isOn);
127
128 private slots:
129
130     /** @brief Display the last captured frame over current live feed.
131      @param isOn enable or disable the feature */
132     void slotShowOverlay(bool isOn);
133
134     /** @brief Display the last captured frame over current live feed. */
135     void slotUpdateOverlay();
136
137     /** @brief User changed the capture name. */
138     void sequenceNameChanged(const QString &name);
139
140     /** @brief Grab a frame from current capture feed. */
141     void slotCaptureFrame();
142
143     /** @brief Display a previous frame in monitor. */
144     void slotShowFrame(const QString &path);
145
146     /** @brief Get full path for a frame in the sequence.
147      *  @param ix the frame number.
148      *  @param seqName (optional) the name of the sequence. */
149     QString getPathForFrame(int ix, QString seqName = QString());
150
151     /** @brief Add sequence to current project. */
152     void slotAddSequence();
153
154     /** @brief Display selected fram in monitor. */
155     void slotShowSelectedFrame();
156
157     /** @brief Start animation preview mode. */
158     void slotPlayPreview(bool animate);
159
160     /** @brief Simulate animation. */
161     void slotAnimate();
162
163     /** @brief Seek to previous or next captured frame.
164      *  @param forward set to true for next frame, false for previous one. */
165     void slotSeekFrame(bool forward);
166
167     /** @brief Display warning / error message from capture backend. */
168     void slotGotHDMIMessage(const QString &message);
169
170     /** @brief Create thumbnails for existing sequence frames. */
171     void slotCreateThumbs(QImage img, int ix);
172
173     /** @brief Prepare thumbnails creation. */
174     void slotPrepareThumbs();
175
176     /** @brief Called when user switches the video capture backend. */
177     void slotUpdateHandler();
178
179     /** @brief Show / hide sequence thumbnails. */
180     void slotShowThumbs(bool show);
181
182     /** @brief Capture one frame every interval time. */
183     void slotIntervalCapture(bool capture);
184
185     /** @brief Set the interval between each capture (in seconds). */
186     void slotSetCaptureInterval();
187
188     /** @brief Prepare to crete thumb for newly captured frame. */
189     void slotNewThumb(const QString path);
190
191     /** @brief Set the effect to be applied to overlay frame. */
192     void slotUpdateOverlayEffect(QAction *act);
193
194     /** @brief Switch between live view / currently selected frame. */
195     void slotSwitchLive();
196
197     /** @brief Delete current frame from disk. */
198     void slotRemoveFrame();
199
200 signals:
201     /** @brief Ask to add sequence to current project. */
202     void addOrUpdateSequence(const QString);
203
204     void doCreateThumbs(QImage, int);
205 };
206
207 #endif