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"
26 #include <QVBoxLayout>
28 #include <abstractmonitor.h>
30 class MltDeviceCapture;
32 class VideoPreviewContainer;
33 class MltVideoProfile;
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 /** @brief Holds the name of the current sequence.
108 * Files will be saved in project folder with name: sequence001.png */
109 QString m_sequenceName;
111 /** @brief Holds the frame number of the current sequence. */
114 QAction* m_captureAction;
116 /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
119 /** @brief Find all stopmotion sequences in current project folder. */
120 void parseExistingSequences();
122 /** @brief Select a frame in the list. */
123 void selectFrame(int ix);
125 /** @brief This widget will hold the frame preview. */
126 MyLabel* m_frame_preview;
128 /** @brief The list of files in the sequence to create thumbnails. */
129 QStringList m_filesList;
131 /** @brief Holds the state of the threaded thumbnail generation. */
132 QFuture<void> m_future;
134 /** @brief Get the frame number ix. */
135 QListWidgetItem* getFrameFromIndex(int ix);
137 /** @brief The action triggering display of last frame over current live video feed. */
138 QAction* m_showOverlay;
140 /** @brief The list of all frames path. */
141 QStringList m_animationList;
143 /** @brief Tells if we are in animation (playback) mode. */
146 /** @brief Timer for interval capture. */
147 QTimer m_intervalTimer;
149 MonitorManager *m_manager;
151 /** @brief The monitor is used to control the v4l capture device from the monitormanager class. */
152 StopmotionMonitor *m_monitor;
154 /** @brief Create the XML playlist. */
155 const QString createProducer(MltVideoProfile profile, const QString &service, const QString &resource);
157 /** @brief A new frame arrived, reload overlay. */
158 void reloadOverlay();
160 /** @brief Holds the index of the effect to be applied to the video feed. */
165 /** @brief Display the live feed from capture device.
166 @param isOn enable or disable the feature */
167 void slotLive(bool isOn = true);
168 void slotStopCapture();
172 /** @brief Display the last captured frame over current live feed.
173 @param isOn enable or disable the feature */
174 void slotShowOverlay(bool isOn);
176 /** @brief Display the last captured frame over current live feed. */
177 void slotUpdateOverlay();
179 /** @brief User changed the capture name. */
180 void sequenceNameChanged(const QString& name);
182 /** @brief Grab a frame from current capture feed. */
183 void slotCaptureFrame();
185 /** @brief Display a previous frame in monitor. */
186 void slotShowFrame(const QString& path);
188 /** @brief Get full path for a frame in the sequence.
189 * @param ix the frame number.
190 * @param seqName (optional) the name of the sequence. */
191 QString getPathForFrame(int ix, QString seqName = QString());
193 /** @brief Add sequence to current project. */
194 void slotAddSequence();
196 /** @brief Display selected fram in monitor. */
197 void slotShowSelectedFrame();
199 /** @brief Start animation preview mode. */
200 void slotPlayPreview(bool animate);
202 /** @brief Simulate animation. */
205 /** @brief Seek to previous or next captured frame.
206 * @param forward set to true for next frame, false for previous one. */
207 void slotSeekFrame(bool forward);
209 /** @brief Display warning / error message from capture backend. */
210 void slotGotHDMIMessage(const QString& message);
212 /** @brief Create thumbnails for existing sequence frames. */
213 void slotCreateThumbs(QImage img, int ix);
215 /** @brief Prepare thumbnails creation. */
216 void slotPrepareThumbs();
218 /** @brief Called when user switches the video capture backend. */
219 void slotUpdateDeviceHandler();
221 /** @brief Show / hide sequence thumbnails. */
222 void slotShowThumbs(bool show);
224 /** @brief Show the config dialog */
225 void slotConfigure();
227 /** @brief Prepare to crete thumb for newly captured frame. */
228 void slotNewThumb(const QString &path);
230 /** @brief Set the effect to be applied to overlay frame. */
231 void slotUpdateOverlayEffect(QAction* act);
233 /** @brief Switch between live view / currently selected frame. */
234 void slotSwitchLive();
236 /** @brief Delete current frame from disk. */
237 void slotRemoveFrame();
239 /** @brief Enable / disable frame analysis (in color scopes). */
240 void slotSwitchAnalyse(bool isOn);
242 /** @brief Enable / disable horizontal mirror effect. */
243 void slotSwitchMirror(bool isOn);
245 /** @brief Send a notification a few seconds before capturing. */
246 void slotPreNotify();
249 /** @brief Ask to add sequence to current project. */
250 void addOrUpdateSequence(const QString &);
252 void doCreateThumbs(QImage, int);
253 void gotFrame(QImage);