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