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