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