Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
chord_preset_pack.h
1// SPDX-FileCopyrightText: © 2022, 2024-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "gui/backend/backend/settings/chord_preset.h"
7#include "utils/icloneable.h"
8
12class ChordPresetPack : public QObject
13{
14 Q_OBJECT
15 Q_PROPERTY (QString name READ getName WRITE setName NOTIFY nameChanged)
16 QML_ELEMENT
17
18public:
19 using NameT = QString;
20 ChordPresetPack (QObject * parent = nullptr);
21 ChordPresetPack (
22 const NameT &name,
23 bool is_standard,
24 QObject * parent = nullptr);
25
26 // ====================================================================
27 // QML Interface
28 // ====================================================================
29
30 QString getName () const { return name_; }
31 void setName (const QString &name);
32 Q_SIGNAL void nameChanged (const QString &name);
33
34 // ============================================================================
35
36 std::string get_document_type () const { return "Zrythm Chord Preset Pack"; }
37 int get_format_major_version () const { return 2; }
38 int get_format_minor_version () const { return 0; }
39
40 friend void init_from (
41 ChordPresetPack &obj,
42 const ChordPresetPack &other,
44
45 bool contains_name (const NameT &name) const;
46
47 bool contains_preset (const ChordPreset &pset) const;
48
49 void add_preset (const ChordPreset &pset);
50
51 void delete_preset (const ChordPreset &pset);
52
53 int get_preset_index (const ChordPreset &pset) const;
54
55 // GMenuModel * generate_context_menu () const;
56
57private:
58 static constexpr std::string_view kNameKey = "name";
59 static constexpr std::string_view kPresetsKey = "presets";
60 static constexpr std::string_view kIsStandardKey = "isStandard";
61 friend void to_json (nlohmann::json &j, const ChordPresetPack &pack);
62 friend void from_json (const nlohmann::json &j, ChordPresetPack &pack);
63
64public:
66 NameT name_;
67
69 std::vector<ChordPreset *> presets_;
70
72 bool is_standard_ = false;
73};
74
75inline bool
76operator== (const ChordPresetPack &lhs, const ChordPresetPack &rhs)
77{
78 return lhs.name_ == rhs.name_ && lhs.presets_ == rhs.presets_
79 && lhs.is_standard_ == rhs.is_standard_;
80}
Chord preset pack.
NameT name_
Pack name.
std::vector< ChordPreset * > presets_
Presets.
bool is_standard_
Whether this is a standard preset pack (not user-defined).
A preset of chord descriptors.