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