CuteLogger
Fast and simple logging solution for Qt based applications
producerpreviewwidget.h
1 /*
2  * Copyright (c) 2020 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef PRODUCERPREVIEWWIDGET_H
19 #define PRODUCERPREVIEWWIDGET_H
20 
21 #include "dataqueue.h"
22 
23 #include <MltProducer.h>
24 #include <QFuture>
25 #include <QPixmap>
26 #include <QWidget>
27 
28 class QLabel;
29 class ScrubBar;
30 
31 class ProducerPreviewWidget : public QWidget
32 {
33  Q_OBJECT
34 
35 public:
36  explicit ProducerPreviewWidget(double dar, int width = 320);
37  virtual ~ProducerPreviewWidget();
38 
39  void start(const Mlt::Producer &producer);
40  void stop(bool releaseProducer = true);
41  void showText(QString text);
42  void setLooping(bool enabled);
43 
44 public slots:
45  void restart();
46 
47 private slots:
48  void seeked(int);
49 
50 private:
51  void timerEvent(QTimerEvent *) override;
52  void frameGeneratorThread();
53  void generateFrame();
54 
55  QSize m_previewSize;
56  QLabel *m_imageLabel;
57  ScrubBar *m_scrubber;
58  QLabel *m_posLabel;
59  int m_seekTo;
60  int m_timerId;
61  Mlt::Producer m_producer;
62  struct QueueItem
63  {
64  QPixmap pixmap;
65  int position;
66  QString positionText;
67  };
68  DataQueue<QueueItem> m_queue;
69  QFuture<void> m_future;
70  bool m_generateFrames;
71  bool m_isLooping;
72 };
73 
74 #endif // PRODUCERPREVIEWWIDGET_H