Loading...
Searching...
No Matches
score-plugin-clap/Clap/ApplicationPlugin.hpp
1#pragma once
2#include <score/plugins/application/GUIApplicationPlugin.hpp>
3#include <score/serialization/DataStreamFwd.hpp>
4
5#include <QObject>
6#include <QtCore/qglobal.h>
7
8#include <score_plugin_clap_export.h>
9
10#include <memory>
11#include <vector>
12#include <verdigris>
13
14namespace Library
15{
16class ProcessesItemModel;
17}
18namespace Media
19{
20class PluginScanner;
21}
22
23class QTimer;
24class QJsonObject;
25
26namespace Clap
27{
29{
30 QString path;
31 QString id;
32 QString name;
33 QString vendor;
34 QString version;
35 QString url;
36 QString manual_url;
37 QString support_url;
38 QString description;
39
40 QList<QString> features;
41 bool valid{};
42};
43
46SCORE_PLUGIN_CLAP_EXPORT
47std::vector<PluginInfo> parseClapReply(const QString& path, const QJsonObject& obj);
48
53SCORE_PLUGIN_CLAP_EXPORT
54QString resolveClapEntry(const QString& path);
55
56class SCORE_PLUGIN_CLAP_EXPORT ApplicationPlugin
57 : public QObject
59{
60 W_OBJECT(ApplicationPlugin)
61
62public:
65
66 void initialize() override;
67
68 const std::vector<PluginInfo>& plugins() const noexcept { return m_plugins; }
69
70 void rescanPlugins();
72 void forceRescan();
73
74public:
75 void pluginsChanged() E_SIGNAL(SCORE_PLUGIN_CLAP_EXPORT, pluginsChanged);
76
77private:
78 void onScanned(const QString& path, const QJsonObject& obj);
79 void onScanFailed(const QString& path, const QString& reason);
80 void removeEntriesForPath(const QString& path);
81 void persistCache();
82 void schedulePersist();
83
84#if QT_CONFIG(process)
85 std::unique_ptr<Media::PluginScanner> m_scanner;
86#endif
87 QTimer* m_persistTimer{};
88 bool m_scanRan{};
89
90 std::vector<PluginInfo> m_plugins;
91};
92}
93
94Q_DECLARE_METATYPE(Clap::PluginInfo)
95Q_DECLARE_METATYPE(std::vector<Clap::PluginInfo>)
96// Declared here, not only defined in ApplicationPlugin.cpp: QMetaType picks up
97// the stream operators in the translation unit that instantiates it, so a
98// QVariant of these types made anywhere else could not be saved to QSettings.
99SCORE_SERIALIZE_DATASTREAM_DECLARE(SCORE_PLUGIN_CLAP_EXPORT, Clap::PluginInfo)
100SCORE_SERIALIZE_DATASTREAM_DECLARE(SCORE_PLUGIN_CLAP_EXPORT, std::vector<Clap::PluginInfo>)
Definition score-plugin-clap/Clap/ApplicationPlugin.hpp:59
Used to extend the software with application-wide data.
Definition GUIApplicationPlugin.hpp:97
Definition score-plugin-clap/Clap/ApplicationPlugin.hpp:29
Specializes ApplicationContext with the QMainWindow.
Definition GUIApplicationContext.hpp:15