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