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 class MyLabel : public QLabel
33 MyLabel(QWidget *parent = 0);
34 void setImage(QImage img);
37 virtual void paintEvent(QPaintEvent * event);
38 virtual void wheelEvent(QWheelEvent * event);
44 /** @brief Seek to next or previous frame.
45 * @param forward set to true to go to next frame, fals to go to previous frame */
46 void seek(bool forward);
49 class StopmotionWidget : public QDialog , public Ui::Stopmotion_UI
55 /** @brief Build the stopmotion dialog.
56 * @param projectFolder The current project folder, where captured files will be stored.
57 * @param parent (optional) parent widget */
58 StopmotionWidget(KUrl projectFolder, QWidget *parent = 0);
59 virtual ~StopmotionWidget();
62 virtual void closeEvent(QCloseEvent *e);
65 /** @brief Widget layout holding video and frame preview. */
66 QVBoxLayout *m_layout;
68 /** @brief Current project folder (where the captured frames will be saved). */
71 /** @brief Capture holder that will handle all video operation. */
72 CaptureHandler *m_bmCapture;
74 /** @brief Holds the name of the current sequence.
75 * Files will be saved in project folder with name: sequence001.png */
76 QString m_sequenceName;
78 /** @brief Holds the frame number of the current sequence. */
81 QAction *m_captureAction;
83 /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
86 /** @brief Find all stopmotion sequences in current project folder. */
87 void parseExistingSequences();
89 /** @brief Select a frame in the list. */
90 void selectFrame(int ix);
92 /** @brief This widget will hold the frame preview. */
93 MyLabel *m_frame_preview;
95 /** @brief The list of files in the sequence to create thumbnails. */
96 QStringList m_filesList;
98 /** @brief Holds the state of the threaded thumbnail generation. */
99 QFuture<void> m_future;
101 /** @brief Get the frame number ix. */
102 QListWidgetItem *getFrameFromIndex(int ix);
104 /** @brief The action triggering interval capture. */
105 QAction *m_intervalCapture;
107 /** @brief The action triggering display of last frame over current live video feed. */
108 QAction *m_showOverlay;
115 /** @brief Display the live feed from capture device.
116 @param isOn enable or disable the feature */
117 void slotLive(bool isOn);
119 /** @brief Display the last captured frame over current live feed.
120 @param isOn enable or disable the feature */
121 void slotShowOverlay(bool isOn);
123 /** @brief Display the last captured frame over current live feed. */
124 void slotUpdateOverlay();
126 /** @brief User changed the capture name. */
127 void sequenceNameChanged(const QString &name);
129 /** @brief Grab a frame from current capture feed. */
130 void slotCaptureFrame();
132 /** @brief Display a previous frame in monitor. */
133 void slotShowFrame(int);
135 /** @brief Get full path for a frame in the sequence.
136 * @param ix the frame number.
137 * @param seqName (optional) the name of the sequence. */
138 QString getPathForFrame(int ix, QString seqName = QString());
140 /** @brief Add sequence to current project. */
141 void slotAddSequence();
143 /** @brief Display selected fram in monitor. */
144 void slotShowSelectedFrame();
146 /** @brief Start animation preview mode. */
147 void slotPlayPreview();
149 /** @brief Simulate animation. */
152 /** @brief Seek to previous or next captured frame.
153 * @param forward set to true for next frame, false for previous one. */
154 void slotSeekFrame(bool forward);
156 /** @brief Display warning / error message from capture backend. */
157 void slotGotHDMIMessage(const QString &message);
159 /** @brief Create thumbnails for existing sequence frames. */
160 void slotCreateThumbs(QImage img, int ix);
162 /** @brief Prepare thumbnails creation. */
163 void slotPrepareThumbs();
165 /** @brief Called when user switches the video capture backend. */
166 void slotUpdateHandler();
168 /** @brief Show / hide sequence thumbnails. */
169 void slotShowThumbs(bool show);
171 /** @brief Capture one frame every interval time. */
172 void slotIntervalCapture(bool capture);
174 /** @brief Set the interval between each capture (in seconds). */
175 void slotSetCaptureInterval();
177 /** @brief Prepare to crete thumb for newly captured frame. */
178 void slotNewThumb(const QString path);
180 /** @brief Set the effect to be applied to overlay frame. */
181 void slotUpdateOverlayEffect(QAction *act);
184 /** @brief Ask to add sequence to current project. */
185 void addOrUpdateSequence(const QString);
187 void doCreateThumbs(QImage, int);