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