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>
30 class MyLabel : public QLabel
34 MyLabel(QWidget* parent = 0);
35 void setImage(QImage img);
38 virtual void paintEvent(QPaintEvent* event);
39 virtual void wheelEvent(QWheelEvent* event);
40 virtual void mousePressEvent(QMouseEvent*);
46 /** @brief Seek to next or previous frame.
47 * @param forward set to true to go to next frame, fals to go to previous frame */
48 void seek(bool forward);
50 /** @brief Switch to live view. */
54 class StopmotionWidget : public QDialog , public Ui::Stopmotion_UI
60 /** @brief Build the stopmotion dialog.
61 * @param projectFolder The current project folder, where captured files will be stored.
62 * @param actions The actions for this widget that can have a keyboard shortcut.
63 * @param parent (optional) parent widget */
64 StopmotionWidget(KUrl projectFolder, QList< QAction* > actions, QWidget* parent = 0);
65 virtual ~StopmotionWidget();
68 virtual void closeEvent(QCloseEvent* e);
71 /** @brief Widget layout holding video and frame preview. */
72 QVBoxLayout* m_layout;
74 /** @brief Current project folder (where the captured frames will be saved). */
77 /** @brief Capture holder that will handle all video operation. */
78 CaptureHandler* m_bmCapture;
80 /** @brief Holds the name of the current sequence.
81 * Files will be saved in project folder with name: sequence001.png */
82 QString m_sequenceName;
84 /** @brief Holds the frame number of the current sequence. */
87 QAction* m_captureAction;
89 /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
92 /** @brief Find all stopmotion sequences in current project folder. */
93 void parseExistingSequences();
95 /** @brief Select a frame in the list. */
96 void selectFrame(int ix);
98 /** @brief This widget will hold the frame preview. */
99 MyLabel* m_frame_preview;
101 /** @brief The list of files in the sequence to create thumbnails. */
102 QStringList m_filesList;
104 /** @brief Holds the state of the threaded thumbnail generation. */
105 QFuture<void> m_future;
107 /** @brief Get the frame number ix. */
108 QListWidgetItem* getFrameFromIndex(int ix);
110 /** @brief The action triggering display of last frame over current live video feed. */
111 QAction* m_showOverlay;
113 /** @brief The list of all frames path. */
114 QStringList m_animationList;
116 /** @brief Tells if we are in animation (playback) mode. */
119 /** @brief Timer for interval capture. */
120 QTimer m_intervalTimer;
128 /** @brief Display the live feed from capture device.
129 @param isOn enable or disable the feature */
130 void slotLive(bool isOn = true);
134 /** @brief Display the last captured frame over current live feed.
135 @param isOn enable or disable the feature */
136 void slotShowOverlay(bool isOn);
138 /** @brief Display the last captured frame over current live feed. */
139 void slotUpdateOverlay();
141 /** @brief User changed the capture name. */
142 void sequenceNameChanged(const QString& name);
144 /** @brief Grab a frame from current capture feed. */
145 void slotCaptureFrame();
147 /** @brief Display a previous frame in monitor. */
148 void slotShowFrame(const QString& path);
150 /** @brief Get full path for a frame in the sequence.
151 * @param ix the frame number.
152 * @param seqName (optional) the name of the sequence. */
153 QString getPathForFrame(int ix, QString seqName = QString());
155 /** @brief Add sequence to current project. */
156 void slotAddSequence();
158 /** @brief Display selected fram in monitor. */
159 void slotShowSelectedFrame();
161 /** @brief Start animation preview mode. */
162 void slotPlayPreview(bool animate);
164 /** @brief Simulate animation. */
167 /** @brief Seek to previous or next captured frame.
168 * @param forward set to true for next frame, false for previous one. */
169 void slotSeekFrame(bool forward);
171 /** @brief Display warning / error message from capture backend. */
172 void slotGotHDMIMessage(const QString& message);
174 /** @brief Create thumbnails for existing sequence frames. */
175 void slotCreateThumbs(QImage img, int ix);
177 /** @brief Prepare thumbnails creation. */
178 void slotPrepareThumbs();
180 /** @brief Called when user switches the video capture backend. */
181 void slotUpdateHandler();
183 /** @brief Show / hide sequence thumbnails. */
184 void slotShowThumbs(bool show);
186 /** @brief Show the config dialog */
187 void slotConfigure();
189 /** @brief Prepare to crete thumb for newly captured frame. */
190 void slotNewThumb(const QString path);
192 /** @brief Set the effect to be applied to overlay frame. */
193 void slotUpdateOverlayEffect(QAction* act);
195 /** @brief Switch between live view / currently selected frame. */
196 void slotSwitchLive();
198 /** @brief Delete current frame from disk. */
199 void slotRemoveFrame();
201 /** @brief Enable / disable frame analysis (in color scopes). */
202 void slotSwitchAnalyse(bool isOn);
204 /** @brief Send a notification a few seconds before capturing. */
205 void slotPreNotify();
208 /** @brief Ask to add sequence to current project. */
209 void addOrUpdateSequence(const QString);
211 void doCreateThumbs(QImage, int);
212 void gotFrame(QImage);