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 "definitions.h"
27 #include <QVBoxLayout>
29 #include <abstractmonitor.h>
31 class MltDeviceCapture;
33 class VideoPreviewContainer;
34 class MltVideoProfile;
36 class MyLabel : public QLabel
40 MyLabel(QWidget* parent = 0);
41 void setImage(QImage img);
44 virtual void paintEvent(QPaintEvent* event);
45 virtual void wheelEvent(QWheelEvent* event);
46 virtual void mousePressEvent(QMouseEvent*);
52 /** @brief Seek to next or previous frame.
53 * @param forward set to true to go to next frame, fals to go to previous frame */
54 void seek(bool forward);
56 /** @brief Switch to live view. */
61 class StopmotionMonitor : public AbstractMonitor
65 StopmotionMonitor(MonitorManager *manager, QWidget *parent);
67 AbstractRender *abstractRender();
68 Kdenlive::MONITORID id() const;
69 void setRender(MltDeviceCapture *render);
74 MltDeviceCapture *m_captureDevice;
80 void slotMouseSeek(int eventDelta, bool fast);
81 void slotSwitchFullScreen();
88 class StopmotionWidget : public QDialog, public Ui::Stopmotion_UI
94 /** @brief Build the stopmotion dialog.
95 * @param projectFolder The current project folder, where captured files will be stored.
96 * @param actions The actions for this widget that can have a keyboard shortcut.
97 * @param parent (optional) parent widget */
98 StopmotionWidget(MonitorManager *manager, KUrl projectFolder, QList< QAction* > actions, QWidget* parent = 0);
99 virtual ~StopmotionWidget();
102 virtual void closeEvent(QCloseEvent* e);
105 /** @brief Current project folder (where the captured frames will be saved). */
106 KUrl m_projectFolder;
108 /** @brief Capture holder that will handle all video operation. */
109 MltDeviceCapture *m_captureDevice;
111 VideoContainer *m_videoBox;
113 /** @brief Holds the name of the current sequence.
114 * Files will be saved in project folder with name: sequence001.png */
115 QString m_sequenceName;
117 /** @brief Holds the frame number of the current sequence. */
120 QAction* m_captureAction;
122 /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
125 /** @brief Find all stopmotion sequences in current project folder. */
126 void parseExistingSequences();
128 /** @brief Select a frame in the list. */
129 void selectFrame(int ix);
131 /** @brief This widget will hold the frame preview. */
132 MyLabel* m_frame_preview;
134 /** @brief The list of files in the sequence to create thumbnails. */
135 QStringList m_filesList;
137 /** @brief Holds the state of the threaded thumbnail generation. */
138 QFuture<void> m_future;
140 /** @brief Get the frame number ix. */
141 QListWidgetItem* getFrameFromIndex(int ix);
143 /** @brief The action triggering display of last frame over current live video feed. */
144 QAction* m_showOverlay;
146 /** @brief The list of all frames path. */
147 QStringList m_animationList;
149 /** @brief Tells if we are in animation (playback) mode. */
152 /** @brief Timer for interval capture. */
153 QTimer m_intervalTimer;
155 MonitorManager *m_manager;
157 /** @brief The monitor is used to control the v4l capture device from the monitormanager class. */
158 StopmotionMonitor *m_monitor;
160 /** @brief Create the XML playlist. */
161 const QString createProducer(MltVideoProfile profile, const QString &service, const QString &resource);
163 /** @brief A new frame arrived, reload overlay. */
164 void reloadOverlay();
166 /** @brief Holds the index of the effect to be applied to the video feed. */
171 /** @brief Display the live feed from capture device.
172 @param isOn enable or disable the feature */
173 void slotLive(bool isOn = true);
174 void slotStopCapture();
178 /** @brief Display the last captured frame over current live feed.
179 @param isOn enable or disable the feature */
180 void slotShowOverlay(bool isOn);
182 /** @brief Display the last captured frame over current live feed. */
183 void slotUpdateOverlay();
185 /** @brief User changed the capture name. */
186 void sequenceNameChanged(const QString& name);
188 /** @brief Grab a frame from current capture feed. */
189 void slotCaptureFrame();
191 /** @brief Display a previous frame in monitor. */
192 void slotShowFrame(const QString& path);
194 /** @brief Get full path for a frame in the sequence.
195 * @param ix the frame number.
196 * @param seqName (optional) the name of the sequence. */
197 QString getPathForFrame(int ix, QString seqName = QString());
199 /** @brief Add sequence to current project. */
200 void slotAddSequence();
202 /** @brief Display selected fram in monitor. */
203 void slotShowSelectedFrame();
205 /** @brief Start animation preview mode. */
206 void slotPlayPreview(bool animate);
208 /** @brief Simulate animation. */
211 /** @brief Seek to previous or next captured frame.
212 * @param forward set to true for next frame, false for previous one. */
213 void slotSeekFrame(bool forward);
215 /** @brief Display warning / error message from capture backend. */
216 void slotGotHDMIMessage(const QString& message);
218 /** @brief Create thumbnails for existing sequence frames. */
219 void slotCreateThumbs(QImage img, int ix);
221 /** @brief Prepare thumbnails creation. */
222 void slotPrepareThumbs();
224 /** @brief Called when user switches the video capture backend. */
225 void slotUpdateDeviceHandler();
227 /** @brief Show / hide sequence thumbnails. */
228 void slotShowThumbs(bool show);
230 /** @brief Show the config dialog */
231 void slotConfigure();
233 /** @brief Prepare to crete thumb for newly captured frame. */
234 void slotNewThumb(const QString &path);
236 /** @brief Set the effect to be applied to overlay frame. */
237 void slotUpdateOverlayEffect(QAction* act);
239 /** @brief Switch between live view / currently selected frame. */
240 void slotSwitchLive();
242 /** @brief Delete current frame from disk. */
243 void slotRemoveFrame();
245 /** @brief Enable / disable frame analysis (in color scopes). */
246 void slotSwitchAnalyse(bool isOn);
248 /** @brief Enable / disable horizontal mirror effect. */
249 void slotSwitchMirror(bool isOn);
251 /** @brief Send a notification a few seconds before capturing. */
252 void slotPreNotify();
255 /** @brief Ask to add sequence to current project. */
256 void addOrUpdateSequence(const QString &);
258 void doCreateThumbs(QImage, int);
259 void gotFrame(QImage);