Loading...
Searching...
No Matches
score-plugin-faust/Faust/Library.hpp
1#pragma once
2#include <Process/Drop/ProcessDropHandler.hpp>
3
4#include <Library/LibraryInterface.hpp>
5#include <Library/LibrarySettings.hpp>
6#include <Library/ProcessesItemModel.hpp>
7
8#include <score/application/ApplicationServices.hpp>
9
10#include <QFile>
11#include <QGuiApplication>
12#include <QTimer>
13
14#include <Faust/Descriptor.hpp>
15#include <Faust/EffectModel.hpp>
16namespace Faust
17{
18class LibraryHandler final
19 : public QObject
21{
22 SCORE_CONCRETE("e274ee7b-9142-43a0-9d77-9286a63af4d9")
23
24 score::TaskPool& pool = score::TaskPool::instance();
25
26 QSet<QString> acceptedFiles() const noexcept override { return {"dsp"}; }
27
28 Library::Subcategories categories;
29
31 override
32 {
33 // TODO relaunch whenever library path changes...
34 const auto& key = FaustEffectFactory{}.concreteKey();
35 QModelIndex node = model.find(key);
36 if(node == QModelIndex{})
37 return;
38
39 categories.init(node, ctx);
40 }
41
42 void addPath(std::string_view path) override
43 {
44 score::PathInfo file{path};
45 if(file.fileName != "layout.dsp")
46 registerDSP(std::string(path));
47 }
48
49 void registerDSP(std::string path)
50 {
51 pool.post([this, path = std::move(path)] {
53 score::PathInfo file{path};
54 pdata.prettyName = QString::fromUtf8(
55 file.completeBaseName.data(), file.completeBaseName.size());
57 pdata.customData = QString::fromUtf8(
58 file.absoluteFilePath.data(), file.absoluteFilePath.size());
59 pdata.author = "Faust standard library";
60
61 auto desc = initDescriptor(pdata.customData);
62 if(!desc.prettyName.isEmpty())
63 pdata.prettyName = desc.prettyName;
64
65 if(!desc.author.isEmpty())
66 pdata.author = desc.author;
67 else if(!desc.copyright.isEmpty())
68 pdata.author = desc.copyright;
69
70 if(!desc.description.isEmpty())
71 pdata.description = desc.description;
72 if(!desc.version.isEmpty())
73 {
74 pdata.description += "\n";
75 pdata.description += desc.version;
76 }
77 if(!desc.license.isEmpty())
78 {
79 pdata.description += "\n";
80 pdata.description += desc.license;
81 }
82
83 QMetaObject::invokeMethod(
84 qApp, [this, path = std::move(path), pdata = std::move(pdata)]() mutable {
85 score::PathInfo file{path};
86 categories.add(file, std::move(pdata));
87 }, Qt::QueuedConnection);
88 });
89 }
90};
91
93{
94 SCORE_CONCRETE("1e83a000-5aca-4427-8de5-1dc7a390e201")
95
96 QSet<QString> fileExtensions() const noexcept override { return {"dsp"}; }
97
98 void dropPath(
99 std::vector<ProcessDrop>& vec, const score::FilePath& filename,
100 const score::DocumentContext& ctx) const noexcept override
101 {
104
105 // TODO use faust-provided name
106 p.creation.prettyName = filename.basename;
107 p.creation.customData = filename.relative;
108
109 vec.push_back(std::move(p));
110 }
111};
112
113}
Definition score-plugin-faust/Faust/Library.hpp:93
Definition score-plugin-faust/Faust/Library.hpp:21
Definition LibraryInterface.hpp:22
Definition ProcessesItemModel.hpp:45
Definition EffectFactory.hpp:14
Definition ProcessDropHandler.hpp:25
Definition ThreadPool.hpp:33
Definition ProcessesItemModel.hpp:32
Definition ProcessesItemModel.hpp:86
Static metadata implementation.
Definition lib/score/tools/Metadata.hpp:36
Definition ProcessDropHandler.hpp:29
Definition DocumentContext.hpp:18
Definition FilePath.hpp:25
Specializes ApplicationContext with the QMainWindow.
Definition GUIApplicationContext.hpp:15
Definition lib/score/tools/File.hpp:20