Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
add_plugin_command.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <utility>
7
8#include "plugins/plugin_group.h"
9
10#include <QUndoCommand>
11
12namespace zrythm::commands
13{
14
15class AddPluginCommand : public QUndoCommand
16{
17public:
18 static constexpr auto CommandId = 1763165707;
19
20 AddPluginCommand (
21 plugins::PluginGroup &plugin_group,
22 plugins::PluginUuidReference plugin_ref,
23 std::optional<int> index = std::nullopt)
24 : QUndoCommand (QObject::tr ("Add Plugin")), plugin_group_ (plugin_group),
25 plugin_ref_ (std::move (plugin_ref)), index_ (index)
26 {
27 }
28
29 int id () const override { return CommandId; }
30
31 void undo () override { plugin_group_.remove_plugin (plugin_ref_.id ()); }
32
33 void redo () override
34 {
35 if (index_.has_value ())
36 {
37 plugin_group_.insert_plugin (plugin_ref_, index_.value ());
38 }
39 else
40 {
41 plugin_group_.append_plugin (plugin_ref_);
42 }
43 }
44
45private:
46 plugins::PluginGroup &plugin_group_;
47 plugins::PluginUuidReference plugin_ref_;
48 std::optional<int> index_;
49};
50
51} // namespace zrythm::commands
A flexible container for plugins and nested plugin groups.