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 <widgets/abstractmonitor.h>
31 class MltDeviceCapture;
33 class MltVideoProfile;
35 class MyLabel : public QLabel
39 explicit MyLabel(QWidget* parent = 0);
40 void setImage(const QImage &img);
43 void paintEvent(QPaintEvent* event);
44 void wheelEvent(QWheelEvent* event);
45 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(MonitorManager *manager, QWidget *parent);
66 AbstractRender *abstractRender();
67 Kdenlive::MonitorId id() const;
68 void setRender(MltDeviceCapture *render);
71 MltDeviceCapture *m_captureDevice;
77 void slotMouseSeek(int eventDelta, bool fast);
78 void slotSwitchFullScreen();
85 class StopmotionWidget : public QDialog, public Ui::Stopmotion_UI
91 /** @brief Build the stopmotion dialog.
92 * @param projectFolder The current project folder, where captured files will be stored.
93 * @param actions The actions for this widget that can have a keyboard shortcut.
94 * @param parent (optional) parent widget */
95 StopmotionWidget(MonitorManager *manager, const KUrl &projectFolder, const QList< QAction* > &actions, QWidget* parent = 0);
96 virtual ~StopmotionWidget();
99 virtual void closeEvent(QCloseEvent* e);
102 /** @brief Current project folder (where the captured frames will be saved). */
103 KUrl m_projectFolder;
105 /** @brief Capture holder that will handle all video operation. */
106 MltDeviceCapture *m_captureDevice;
108 /** @brief Holds the name of the current sequence.
109 * Files will be saved in project folder with name: sequence001.png */
110 QString m_sequenceName;
112 /** @brief Holds the frame number of the current sequence. */
115 QAction* m_captureAction;
117 /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
120 /** @brief Find all stopmotion sequences in current project folder. */
121 void parseExistingSequences();
123 /** @brief Select a frame in the list. */
124 void selectFrame(int ix);
126 /** @brief This widget will hold the frame preview. */
127 MyLabel* m_frame_preview;
129 /** @brief The list of files in the sequence to create thumbnails. */
130 QStringList m_filesList;
132 /** @brief Holds the state of the threaded thumbnail generation. */
133 QFuture<void> m_future;
135 /** @brief Get the frame number ix. */
136 QListWidgetItem* getFrameFromIndex(int ix);
138 /** @brief The action triggering display of last frame over current live video feed. */
139 QAction* m_showOverlay;
141 /** @brief The list of all frames path. */
142 QStringList m_animationList;
144 /** @brief Tells if we are in animation (playback) mode. */
147 /** @brief Timer for interval capture. */
148 QTimer m_intervalTimer;
150 MonitorManager *m_manager;
152 /** @brief The monitor is used to control the v4l capture device from the monitormanager class. */
153 StopmotionMonitor *m_monitor;
155 /** @brief Create the XML playlist. */
156 const QString createProducer(const MltVideoProfile &profile, const QString &service, const QString &resource);
158 /** @brief A new frame arrived, reload overlay. */
159 void reloadOverlay();
161 /** @brief Holds the index of the effect to be applied to the video feed. */
166 /** @brief Display the live feed from capture device.
167 @param isOn enable or disable the feature */
168 void slotLive(bool isOn = true);
169 void slotStopCapture();
173 /** @brief Display the last captured frame over current live feed.
174 @param isOn enable or disable the feature */
175 void slotShowOverlay(bool isOn);
177 /** @brief Display the last captured frame over current live feed. */
178 void slotUpdateOverlay();
180 /** @brief User changed the capture name. */
181 void sequenceNameChanged(const QString& name);
183 /** @brief Grab a frame from current capture feed. */
184 void slotCaptureFrame();
186 /** @brief Display a previous frame in monitor. */
187 void slotShowFrame(const QString& path);
189 /** @brief Get full path for a frame in the sequence.
190 * @param ix the frame number.
191 * @param seqName (optional) the name of the sequence. */
192 QString getPathForFrame(int ix, QString seqName = QString());
194 /** @brief Add sequence to current project. */
195 void slotAddSequence();
197 /** @brief Display selected fram in monitor. */
198 void slotShowSelectedFrame();
200 /** @brief Start animation preview mode. */
201 void slotPlayPreview(bool animate);
203 /** @brief Simulate animation. */
206 /** @brief Seek to previous or next captured frame.
207 * @param forward set to true for next frame, false for previous one. */
208 void slotSeekFrame(bool forward);
210 /** @brief Display warning / error message from capture backend. */
211 void slotGotHDMIMessage(const QString& message);
213 /** @brief Create thumbnails for existing sequence frames. */
214 void slotCreateThumbs(const QImage &img, int ix);
216 /** @brief Prepare thumbnails creation. */
217 void slotPrepareThumbs();
219 /** @brief Called when user switches the video capture backend. */
220 void slotUpdateDeviceHandler();
222 /** @brief Show / hide sequence thumbnails. */
223 void slotShowThumbs(bool show);
225 /** @brief Show the config dialog */
226 void slotConfigure();
228 /** @brief Prepare to crete thumb for newly captured frame. */
229 void slotNewThumb(const QString &path);
231 /** @brief Set the effect to be applied to overlay frame. */
232 void slotUpdateOverlayEffect(QAction* act);
234 /** @brief Switch between live view / currently selected frame. */
235 void slotSwitchLive();
237 /** @brief Delete current frame from disk. */
238 void slotRemoveFrame();
240 /** @brief Enable / disable frame analysis (in color scopes). */
241 void slotSwitchAnalyse(bool isOn);
243 /** @brief Enable / disable horizontal mirror effect. */
244 void slotSwitchMirror(bool isOn);
246 /** @brief Send a notification a few seconds before capturing. */
247 void slotPreNotify();
250 /** @brief Ask to add sequence to current project. */
251 void addOrUpdateSequence(const QString &);
253 void doCreateThumbs(const QImage&, int);
254 void gotFrame(const QImage&);