CuteLogger
Fast and simple logging solution for Qt based applications
qmlmetadata.h
1 /*
2  * Copyright (c) 2013-2021 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 QMLMETADATA_H
19 #define QMLMETADATA_H
20 
21 #include <QObject>
22 #include <QString>
23 #include <QDir>
24 #include <QUrl>
25 #include <QQmlListProperty>
26 
27 class QmlKeyframesParameter : public QObject
28 {
29  Q_OBJECT
30  Q_ENUMS(RangeType)
31  Q_PROPERTY(RangeType rangeType MEMBER m_rangeType NOTIFY changed)
32  Q_PROPERTY(QString name MEMBER m_name NOTIFY changed)
33  Q_PROPERTY(QString property MEMBER m_property NOTIFY changed)
34  Q_PROPERTY(QStringList gangedProperties MEMBER m_gangedProperties NOTIFY changed)
35  Q_PROPERTY(bool isCurve MEMBER m_isCurve NOTIFY changed)
36  Q_PROPERTY(double minimum MEMBER m_minimum NOTIFY changed)
37  Q_PROPERTY(double maximum MEMBER m_maximum NOTIFY changed)
38  Q_PROPERTY(QString units MEMBER m_units NOTIFY changed)
39  Q_PROPERTY(bool isRectangle MEMBER m_isRectangle NOTIFY changed)
40 
41 public:
42  enum RangeType {
43  MinMax,
44  ClipLength,
45  };
46  explicit QmlKeyframesParameter(QObject* parent = 0);
47 
48  QString name() const { return m_name; }
49  QString property() const { return m_property; }
50  QStringList gangedProperties() const { return m_gangedProperties; }
51  bool isCurve() const { return m_isCurve; }
52  double minimum() const { return m_minimum; }
53  double maximum() const { return m_maximum; }
54  QString units() const { return m_units; }
55  bool isRectangle() const { return m_isRectangle; }
56  RangeType rangeType() const { return m_rangeType; }
57 
58 signals:
59  void changed();
60 
61 private:
62  QString m_name;
63  QString m_property;
64  QStringList m_gangedProperties;
65  bool m_isCurve;
66  double m_minimum;
67  double m_maximum;
68  QString m_units;
69  bool m_isRectangle;
70  RangeType m_rangeType;
71 };
72 
73 class QmlKeyframesMetadata : public QObject
74 {
75  Q_OBJECT
76  Q_PROPERTY(bool allowTrim MEMBER m_allowTrim NOTIFY changed)
77  Q_PROPERTY(bool allowAnimateIn MEMBER m_allowAnimateIn NOTIFY changed)
78  Q_PROPERTY(bool allowAnimateOut MEMBER m_allowAnimateOut NOTIFY changed)
79  Q_PROPERTY(QQmlListProperty<QmlKeyframesParameter> parameters READ parameters NOTIFY changed)
81  Q_PROPERTY(QList<QString> simpleProperties MEMBER m_simpleProperties NOTIFY changed)
82  Q_PROPERTY(QString minimumVersion MEMBER m_minimumVersion NOTIFY changed)
83  Q_PROPERTY(bool enabled MEMBER m_enabled NOTIFY changed)
84  Q_PROPERTY(bool allowSmooth MEMBER m_allowSmooth NOTIFY changed)
85 
86 public:
87  explicit QmlKeyframesMetadata(QObject *parent = 0);
88 
89  bool allowTrim() const { return m_allowTrim; }
90  bool allowAnimateIn() const { return m_allowAnimateIn; }
91  bool allowAnimateOut() const { return m_allowAnimateOut; }
92  QList<QString> simpleProperties() const { return m_simpleProperties; }
93 
94  QQmlListProperty<QmlKeyframesParameter> parameters() { return QQmlListProperty<QmlKeyframesParameter>(this, m_parameters); }
95  int parameterCount() const { return m_parameters.count(); }
96  QmlKeyframesParameter *parameter(int index) const { return m_parameters[index]; }
97  void checkVersion(const QString& version);
98  void setDisabled();
99 
100 signals:
101  void changed();
102 
103 private:
104  bool m_allowTrim;
105  bool m_allowAnimateIn;
106  bool m_allowAnimateOut;
107  QList<QmlKeyframesParameter *> m_parameters;
108  QList<QString> m_simpleProperties;
109  QString m_minimumVersion;
110  bool m_enabled;
111  bool m_allowSmooth;
112 };
113 
114 
115 class QmlMetadata : public QObject
116 {
117  Q_OBJECT
118  Q_ENUMS(PluginType)
119  Q_PROPERTY(PluginType type READ type WRITE setType)
120  Q_PROPERTY(QString name READ name WRITE setName NOTIFY changed)
121  Q_PROPERTY(QString mlt_service READ mlt_service WRITE set_mlt_service)
122  Q_PROPERTY(bool needsGPU READ needsGPU WRITE setNeedsGPU NOTIFY changed)
123  Q_PROPERTY(QString qml READ qmlFileName WRITE setQmlFileName)
124  Q_PROPERTY(QString vui READ vuiFileName WRITE setVuiFileName)
125  Q_PROPERTY(QUrl qmlFilePath READ qmlFilePath )
126  Q_PROPERTY(QUrl vuiFilePath READ vuiFilePath )
127  Q_PROPERTY(bool isAudio READ isAudio WRITE setIsAudio NOTIFY changed)
128  Q_PROPERTY(bool isHidden READ isHidden WRITE setIsHidden NOTIFY changed)
129  Q_PROPERTY(bool isFavorite READ isFavorite WRITE setIsFavorite NOTIFY changed)
130  Q_PROPERTY(QString gpuAlt READ gpuAlt WRITE setGpuAlt NOTIFY changed)
131  Q_PROPERTY(bool allowMultiple READ allowMultiple WRITE setAllowMultiple)
132  Q_PROPERTY(bool isClipOnly READ isClipOnly WRITE setIsClipOnly)
133  Q_PROPERTY(bool isGpuCompatible READ isGpuCompatible() WRITE setIsGpuCompatible)
134  Q_PROPERTY(QmlKeyframesMetadata* keyframes READ keyframes NOTIFY changed)
135  Q_PROPERTY(bool isDeprecated READ isDeprecated WRITE setIsDeprecated)
136  Q_PROPERTY(QString minimumVersion MEMBER m_minimumVersion NOTIFY changed)
137 
138 public:
139  enum PluginType {
140  Filter,
141  Producer,
142  Transition,
143  Link,
144  };
145  unsigned filterMask;
146 
147  explicit QmlMetadata(QObject *parent = 0);
148  void loadSettings();
149 
150  PluginType type() const { return m_type; }
151  void setType(PluginType);
152  QString name() const { return m_name; }
153  void setName(const QString&);
154  QString mlt_service() const { return m_mlt_service; }
155  void set_mlt_service(const QString&);
156  QString uniqueId() const;
157  bool needsGPU() const { return m_needsGPU; }
158  void setNeedsGPU(bool);
159  QString qmlFileName() const { return m_qmlFileName; }
160  void setQmlFileName(const QString&);
161  QString vuiFileName() const { return m_vuiFileName; }
162  void setVuiFileName(const QString&);
163  QDir path() const { return m_path; }
164  void setPath(const QDir& path);
165  QUrl qmlFilePath() const;
166  QUrl vuiFilePath() const;
167  bool isAudio() const { return m_isAudio; }
168  void setIsAudio(bool isAudio);
169  bool isHidden() const { return m_isHidden; }
170  void setIsHidden(bool isHidden);
171  bool isFavorite() const { return m_isFavorite; }
172  void setIsFavorite(bool isFavorite);
173  QString gpuAlt() const { return m_gpuAlt; }
174  void setGpuAlt(const QString&);
175  bool allowMultiple() const { return m_allowMultiple; }
176  void setAllowMultiple(bool allowMultiple);
177  bool isClipOnly() const { return m_isClipOnly; }
178  void setIsClipOnly(bool isClipOnly);
179  bool isGpuCompatible() const { return m_isGpuCompatible; }
180  void setIsGpuCompatible(bool isCompatible) { m_isGpuCompatible = isCompatible; }
181  QmlKeyframesMetadata* keyframes() { return &m_keyframes; }
182  const QmlKeyframesMetadata* keyframes() const { return &m_keyframes; }
183  bool isDeprecated() const { return m_isDeprecated; }
184  void setIsDeprecated(bool deprecated) { m_isDeprecated = deprecated; }
185  bool isMltVersion(const QString& version);
186 
187 signals:
188  void changed();
189 
190 private:
191  PluginType m_type;
192  QString m_name;
193  QString m_mlt_service;
194  bool m_needsGPU;
195  QString m_qmlFileName;
196  QString m_vuiFileName;
197  QDir m_path;
198  bool m_isAudio;
199  bool m_isHidden;
200  bool m_isFavorite;
201  QString m_gpuAlt;
202  bool m_allowMultiple;
203  bool m_isClipOnly;
204  bool m_isGpuCompatible;
205  QmlKeyframesMetadata m_keyframes;
206  bool m_isDeprecated;
207  QString m_minimumVersion;
208 };
209 
210 #endif // QMLMETADATA_H