CuteLogger
Fast and simple logging solution for Qt based applications
qmlproducer.h
1/*
2 * Copyright (c) 2016-2026 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 QMLPRODUCER_H
19#define QMLPRODUCER_H
20
21#include "shotcut_mlt_properties.h"
22
23#include <MltProducer.h>
24#include <QObject>
25#include <QRectF>
26#include <QString>
27#include <QVariant>
28
29class QmlProducer : public QObject
30{
31 Q_OBJECT
32 Q_PROPERTY(int in READ in() NOTIFY inChanged)
33 Q_PROPERTY(int out READ out() NOTIFY outChanged)
34 Q_PROPERTY(int aspectRatio READ aspectRatio() NOTIFY producerChanged)
35 Q_PROPERTY(int duration READ duration() NOTIFY durationChanged)
36 Q_PROPERTY(int length READ length() NOTIFY lengthChanged)
37 Q_PROPERTY(QString resource READ resource() NOTIFY producerChanged)
38 Q_PROPERTY(QString mlt_service READ mlt_service() NOTIFY producerChanged)
39 Q_PROPERTY(QString hash READ hash() NOTIFY producerChanged)
40 Q_PROPERTY(QString name READ name() NOTIFY producerChanged)
41 Q_PROPERTY(int fadeIn READ fadeIn NOTIFY producerChanged)
42 Q_PROPERTY(int fadeOut READ fadeOut NOTIFY producerChanged)
43 Q_PROPERTY(double speed READ speed NOTIFY producerChanged)
44 Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
45 Q_PROPERTY(double displayAspectRatio READ displayAspectRatio NOTIFY producerChanged)
46
47public:
48 explicit QmlProducer(QObject *parent = 0);
49
50 int in();
51 int out();
52 double aspectRatio();
53 int duration() { return m_producer.is_valid() ? out() - in() + 1 : 0; }
54 int length() { return m_producer.is_valid() ? m_producer.get_length() : 0; }
55 QString resource();
56 QString mlt_service()
57 {
58 return m_producer.is_valid() ? m_producer.get("mlt_service") : QString();
59 }
60 QString hash()
61 {
62 return m_producer.is_valid() ? m_producer.get(kShotcutHashProperty) : QString();
63 }
64 QString name();
65 const QVariantList *audioLevels();
66 int fadeIn();
67 int fadeOut();
68 double speed();
69 int position() const { return m_position; }
70 void setPosition(int position);
71 void seek(int position);
72 Mlt::Producer &producer() { return m_producer; }
73 Q_INVOKABLE Mlt::Producer *getMltProducer() { return &m_producer; }
74 Q_INVOKABLE void remakeAudioLevels();
75 double displayAspectRatio();
76 Q_INVOKABLE QString get(QString name, int position = -1);
77 Q_INVOKABLE double getDouble(QString name, int position = -1);
78 Q_INVOKABLE QRectF getRect(QString name, int position = -1);
79 Q_INVOKABLE bool outOfBounds();
80 Q_INVOKABLE void newGlaxnimateFile(const QString &filename);
81 Q_INVOKABLE void launchGlaxnimate(const QString &filename = QString()) const;
82
83signals:
84 void producerChanged();
85 void positionChanged(int position);
86 void seeked(int position);
87 void inChanged(int delta);
88 void outChanged(int delta);
89 void audioLevelsChanged();
90 void durationChanged();
91 void lengthChanged();
92
93public slots:
94 void setProducer(Mlt::Producer &producer);
95 void remakeAudioLevels(bool isKeyframesVisible);
96
97private:
98 Mlt::Producer m_producer;
99 int m_position;
100};
101
102#endif // QMLPRODUCER_H