CuteLogger
Fast and simple logging solution for Qt based applications
filtercontroller.h
1/*
2 * Copyright (c) 2014-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 FILTERCONTROLLER_H
19#define FILTERCONTROLLER_H
20
21#include "addonqmlgenerator.h"
22#include "models/addonservicemodel.h"
23#include "models/attachedfiltersmodel.h"
24#include "models/metadatamodel.h"
25#include "models/motiontrackermodel.h"
26#include "qmltypes/qmlfilter.h"
27#include "qmltypes/qmlmetadata.h"
28
29#include <QFuture>
30#include <QObject>
31#include <QScopedPointer>
32#include <QTemporaryDir>
33
34class QTimerEvent;
35
36class FilterController : public QObject
37{
38 Q_OBJECT
39
40public:
41 explicit FilterController(QObject *parent = 0);
42 ~FilterController();
43 MetadataModel *metadataModel();
44 AddOnServiceModel *addOnServiceModel() { return &m_addOnServiceModel; }
45 MotionTrackerModel *motionTrackerModel() { return &m_motionTrackerModel; }
46 AttachedFiltersModel *attachedModel();
47
48 QmlMetadata *metadata(const QString &id);
49 QmlMetadata *metadataForService(Mlt::Service *service);
50 QmlFilter *currentFilter() const { return m_currentFilter.data(); }
51 bool isOutputTrackSelected() const;
52 void onUndoOrRedo(Mlt::Service &service);
53 int currentIndex() const { return m_currentFilterIndex; }
54 void addOrEditFilter(Mlt::Filter *filter, const QStringList &key_properties);
55 void setTrackTransitionService(const QString &service);
56
57protected:
58 void timerEvent(QTimerEvent *);
59
60signals:
61 void currentFilterChanged(QmlFilter *filter, QmlMetadata *meta, int index);
62 void statusChanged(QString);
63 void filterChanged(Mlt::Service *);
64 void undoOrRedo();
65
66public slots:
67 void setProducer(Mlt::Producer *producer = 0);
68 void setCurrentFilter(int attachedIndex);
69 void onFadeInChanged();
70 void onFadeOutChanged();
71 void onGainChanged();
72 void onServiceInChanged(int delta, Mlt::Service *service = 0);
73 void onServiceOutChanged(int delta, Mlt::Service *service = 0);
74 void removeCurrent();
75 void onProducerChanged();
76 void pauseUndoTracking();
77 void resumeUndoTracking();
78
79private slots:
80 void handleAddOnServicesChanged();
81 void handleAttachedModelChange();
82 void handleAttachedModelAboutToReset();
83 void addMetadata(QmlMetadata *);
84 void handleAttachedRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
85 void handleAttachedRowsRemoved(const QModelIndex &parent, int first, int last);
86 void handleAttachedRowsInserted(const QModelIndex &parent, int first, int last);
87 void handleAttachDuplicateFailed(int index);
88 void onQmlFilterChanged(const QString &name);
89
90private:
91 bool ensureAddOnTempDir();
92 bool ensureAddOnFilterQml(QmlMetadata *meta);
93 void loadAddOnFilterMetadata(Mlt::Properties *mltFilters);
94 void loadFilterSets();
95 void loadFilterMetadata();
96
97 QFuture<void> m_future;
98 QScopedPointer<QmlFilter> m_currentFilter;
99 Mlt::Service m_mltService;
100 QTemporaryDir *m_addOnTempDir = nullptr;
101 QHash<QString, AddOnFilterDescriptor> m_addOnDescriptors;
102 AddOnQmlGenerator m_addOnQmlGenerator;
103 MetadataModel m_metadataModel;
104 AddOnServiceModel m_addOnServiceModel;
105 MotionTrackerModel m_motionTrackerModel;
106 AttachedFiltersModel m_attachedModel;
107 int m_currentFilterIndex;
108};
109
110#endif // FILTERCONTROLLER_H