1 /***************************************************************************
2 titlewidget.h - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
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. *
16 ***************************************************************************/
21 #include "ui_stopmotion_ui.h"
22 #include "../blackmagic/capture.h"
27 #include <QVBoxLayout>
29 #include <abstractmonitor.h>
31 class MltDeviceCapture;
33 class VideoPreviewContainer;
35 class MyLabel : public QLabel
39 MyLabel(QWidget* parent = 0);
40 void setImage(QImage img);
43 virtual void paintEvent(QPaintEvent* event);
44 virtual void wheelEvent(QWheelEvent* event);
45 virtual void mousePressEvent(QMouseEvent*);
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);
55 /** @brief Switch to live view. */
60 class StopmotionMonitor : public AbstractMonitor
64 StopmotionMonitor(QWidget *parent);
66 AbstractRender *abstractRender();
67 const QString name() const;
68 void setRender(MltDeviceCapture *render);
71 MltDeviceCapture *m_captureDevice;
82 class StopmotionWidget : public QDialog, public Ui::Stopmotion_UI
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();
96 virtual void closeEvent(QCloseEvent* e);
99 /** @brief Current project folder (where the captured frames will be saved). */
100 KUrl m_projectFolder;
102 /** @brief Capture holder that will handle all video operation. */
103 MltDeviceCapture *m_captureDevice;
105 VideoPreviewContainer *m_videoBox;
107 //CaptureHandler* m_bmCapture;
109 /** @brief Holds the name of the current sequence.
110 * Files will be saved in project folder with name: sequence001.png */
111 QString m_sequenceName;
113 /** @brief Holds the frame number of the current sequence. */
116 QAction* m_captureAction;
118 /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
121 /** @brief Find all stopmotion sequences in current project folder. */
122 void parseExistingSequences();
124 /** @brief Select a frame in the list. */
125 void selectFrame(int ix);
127 /** @brief This widget will hold the frame preview. */
128 MyLabel* m_frame_preview;
130 /** @brief The list of files in the sequence to create thumbnails. */
131 QStringList m_filesList;
133 /** @brief Holds the state of the threaded thumbnail generation. */
134 QFuture<void> m_future;
136 /** @brief Get the frame number ix. */
137 QListWidgetItem* getFrameFromIndex(int ix);
139 /** @brief The action triggering display of last frame over current live video feed. */
140 QAction* m_showOverlay;
142 /** @brief The list of all frames path. */
143 QStringList m_animationList;
145 /** @brief Tells if we are in animation (playback) mode. */
148 /** @brief Timer for interval capture. */
149 QTimer m_intervalTimer;
151 MonitorManager *m_manager;
153 StopmotionMonitor *m_monitor;
161 /** @brief Display the live feed from capture device.
162 @param isOn enable or disable the feature */
163 void slotLive(bool isOn = true);
164 void slotStopCapture();
168 /** @brief Display the last captured frame over current live feed.
169 @param isOn enable or disable the feature */
170 void slotShowOverlay(bool isOn);
172 /** @brief Display the last captured frame over current live feed. */
173 void slotUpdateOverlay();
175 /** @brief User changed the capture name. */
176 void sequenceNameChanged(const QString& name);
178 /** @brief Grab a frame from current capture feed. */
179 void slotCaptureFrame();
181 /** @brief Display a previous frame in monitor. */
182 void slotShowFrame(const QString& path);
184 /** @brief Get full path for a frame in the sequence.
185 * @param ix the frame number.
186 * @param seqName (optional) the name of the sequence. */
187 QString getPathForFrame(int ix, QString seqName = QString());
189 /** @brief Add sequence to current project. */
190 void slotAddSequence();
192 /** @brief Display selected fram in monitor. */
193 void slotShowSelectedFrame();
195 /** @brief Start animation preview mode. */
196 void slotPlayPreview(bool animate);
198 /** @brief Simulate animation. */
201 /** @brief Seek to previous or next captured frame.
202 * @param forward set to true for next frame, false for previous one. */
203 void slotSeekFrame(bool forward);
205 /** @brief Display warning / error message from capture backend. */
206 void slotGotHDMIMessage(const QString& message);
208 /** @brief Create thumbnails for existing sequence frames. */
209 void slotCreateThumbs(QImage img, int ix);
211 /** @brief Prepare thumbnails creation. */
212 void slotPrepareThumbs();
214 /** @brief Called when user switches the video capture backend. */
215 void slotUpdateHandler();
217 /** @brief Show / hide sequence thumbnails. */
218 void slotShowThumbs(bool show);
220 /** @brief Show the config dialog */
221 void slotConfigure();
223 /** @brief Prepare to crete thumb for newly captured frame. */
224 void slotNewThumb(const QString path);
226 /** @brief Set the effect to be applied to overlay frame. */
227 void slotUpdateOverlayEffect(QAction* act);
229 /** @brief Switch between live view / currently selected frame. */
230 void slotSwitchLive();
232 /** @brief Delete current frame from disk. */
233 void slotRemoveFrame();
235 /** @brief Enable / disable frame analysis (in color scopes). */
236 void slotSwitchAnalyse(bool isOn);
238 /** @brief Send a notification a few seconds before capturing. */
239 void slotPreNotify();
242 /** @brief Ask to add sequence to current project. */
243 void addOrUpdateSequence(const QString);
245 void doCreateThumbs(QImage, int);
246 void gotFrame(QImage);