CuteLogger
Fast and simple logging solution for Qt based applications
qmlfilter.h
1 /*
2  * Copyright (c) 2013-2015 Meltytech, LLC
3  * Author: Dan Dennedy <dan@dennedy.org>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef FILTER_H
20 #define FILTER_H
21 
22 #include <QObject>
23 #include <QString>
24 #include <QVariant>
25 #include <QRectF>
26 #include <MltFilter.h>
27 #include "qmlmetadata.h"
28 
29 class AbstractJob;
30 
31 class QmlFilter : public QObject
32 {
33  Q_OBJECT
34  Q_PROPERTY(bool isNew READ isNew)
35  Q_PROPERTY(QString path READ path)
36  Q_PROPERTY(QStringList presets READ presets NOTIFY presetsChanged)
37  Q_PROPERTY(int producerIn READ producerIn)
38  Q_PROPERTY(int producerOut READ producerOut)
39  Q_PROPERTY(double producerAspect READ producerAspect)
40 
41 public:
42  explicit QmlFilter(Mlt::Filter* mltFilter, const QmlMetadata* metadata, QObject *parent = 0);
43  ~QmlFilter();
44 
45  bool isNew() const { return m_isNew; }
46  void setIsNew(bool isNew) { m_isNew = isNew; };
47 
48  Q_INVOKABLE QString get(QString name);
49  Q_INVOKABLE double getDouble(QString name);
50  Q_INVOKABLE QRectF getRect(QString name);
51  Q_INVOKABLE void set(QString name, QString value);
52  Q_INVOKABLE void set(QString name, double value);
53  Q_INVOKABLE void set(QString name, int value);
54  Q_INVOKABLE void set(QString name, double x, double y, double width, double height, double opacity = 1.0);
55  QString path() const { return m_path; }
56  Q_INVOKABLE void loadPresets();
57  QStringList presets() const { return m_presets; }
59  Q_INVOKABLE int savePreset(const QStringList& propertyNames, const QString& name = QString());
60  Q_INVOKABLE void deletePreset(const QString& name);
61  Q_INVOKABLE void analyze(bool isAudio = false);
62  Q_INVOKABLE static int framesFromTime(const QString& time);
63  Q_INVOKABLE static QString timeFromFrames(int frames);
64  Q_INVOKABLE void getHash();
65  int producerIn() const;
66  int producerOut() const;
67  double producerAspect() const;
68 
69 public slots:
70  void preset(const QString& name);
71 
72 signals:
73  void presetsChanged();
74  void analyzeFinished(bool isSuccess);
75  void changed();
76 
77 private:
78  const QmlMetadata* m_metadata;
79  Mlt::Filter* m_filter;
80  QString m_path;
81  bool m_isNew;
82  QStringList m_presets;
83 
84  QString objectNameOrService();
85 };
86 
87 class AnalyzeDelegate : public QObject
88 {
89  Q_OBJECT
90 public:
91  explicit AnalyzeDelegate(Mlt::Filter *filter);
92 
93 public slots:
94  void onAnalyzeFinished(AbstractJob *job, bool isSuccess);
95 
96 private:
97  Mlt::Filter m_filter;
98 };
99 
100 #endif // FILTER_H