Loading...
Searching...
No Matches
Preset.hpp
1#pragma once
2#include <Process/ProcessMetadata.hpp>
3
4#include <optional>
5#include <verdigris>
6namespace Process
7{
8class ProcessFactoryList;
9
11{
13 QString effect;
14 friend bool
15 operator==(const ProcessIdentifier& lhs, const ProcessIdentifier& rhs) noexcept
16 {
17 return lhs.key == rhs.key && lhs.effect == rhs.effect;
18 }
19 friend bool
20 operator!=(const ProcessIdentifier& lhs, const ProcessIdentifier& rhs) noexcept
21 {
22 return !(lhs == rhs);
23 }
24 friend bool
25 operator<(const ProcessIdentifier& lhs, const ProcessIdentifier& rhs) noexcept
26 {
27 return lhs.key < rhs.key || (lhs.key == rhs.key && lhs.effect < rhs.effect);
28 }
29};
30
31struct SCORE_LIB_PROCESS_EXPORT Preset
32{
33 QString name;
35 QByteArray data;
36
37 // Optional hierarchical category used to group presets into submenus.
38 // Empty means "root"; "Foo/Bar/Baz" nests the preset under Foo > Bar > Baz.
39 QString category;
40
41 // Optional text shown as the preset's tooltip.
42 QString description;
43
44 // The file the library read it from or saved it to; empty for a preset in
45 // no file (a plug-in's own, one being dragged). Not part of its contents:
46 // neither saved nor compared.
47 QString path;
48
49 static std::shared_ptr<Process::Preset>
50 fromJson(const Process::ProcessFactoryList& procs, const QByteArray& obj) noexcept;
51
55 static std::shared_ptr<Process::Preset>
56 fromFile(const Process::ProcessFactoryList& procs, const QString& file) noexcept;
57
58 QByteArray toJson() const noexcept;
59
60 friend bool operator==(const Preset& lhs, const Preset& rhs) noexcept
61 {
62 return lhs.name == rhs.name && lhs.key == rhs.key && lhs.data == rhs.data
63 && lhs.category == rhs.category && lhs.description == rhs.description;
64 }
65 friend bool operator!=(const Preset& lhs, const Preset& rhs) noexcept
66 {
67 return !(lhs == rhs);
68 }
69 friend bool operator<(const Preset& lhs, const Preset& rhs) noexcept
70 {
71 return lhs.key < rhs.key;
72 }
73};
74}
75
76Q_DECLARE_METATYPE(Process::Preset)
77W_REGISTER_ARGTYPE(Process::Preset)
78Q_DECLARE_METATYPE(std::optional<Process::Preset>)
79W_REGISTER_ARGTYPE(std::optional<Process::Preset>)
Definition ProcessList.hpp:10
Definition UuidKey.hpp:345
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Definition Preset.hpp:32
Definition Preset.hpp:11