Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
chord_preset.h
1// SPDX-FileCopyrightText: © 2022, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __SETTINGS_CHORD_PRESET_H__
5#define __SETTINGS_CHORD_PRESET_H__
6
7#include "zrythm-config.h"
8
9#include "dsp/chord_descriptor.h"
10#include "structure/arrangement/chord_editor.h"
11#include "utils/types.h"
12
13#include <QtQmlIntegration>
14
15class ChordPresetPack;
16
22
26class ChordPreset : public QObject
27{
28 Q_OBJECT
29 Q_PROPERTY (QString name READ getName WRITE setName NOTIFY nameChanged)
30 QML_ELEMENT
31
32public:
33 using NameT = QString;
34 ChordPreset (QObject * parent = nullptr);
35 ChordPreset (const NameT &name, QObject * parent = nullptr);
36
37 // =================================================================
38 // QML Interface
39 // =================================================================
40
41 NameT getName () const;
42 void setName (const NameT &name);
43 Q_SIGNAL void nameChanged (const NameT &name);
44
45 // =================================================================
46
50 utils::Utf8String get_info_text () const;
51
52 // GMenuModel * generate_context_menu () const;
53
54 friend void init_from (
55 ChordPreset &obj,
56 const ChordPreset &other,
57 utils::ObjectCloneType clone_type);
58
59private:
60 static constexpr std::string_view kNameKey = "name";
61 static constexpr std::string_view kDescriptorsKey = "descriptors";
62 friend void to_json (nlohmann::json &j, const ChordPreset &preset)
63 {
64 j[kNameKey] = preset.name_;
65 j[kDescriptorsKey] = preset.descr_;
66 }
67 friend void from_json (const nlohmann::json &j, ChordPreset &preset)
68 {
69 j.at (kNameKey).get_to (preset.name_);
70 j.at (kDescriptorsKey).get_to (preset.descr_);
71 }
72
73public:
75 NameT name_;
76
78 std::vector<dsp::ChordDescriptor> descr_;
79
82};
83
84inline bool
85operator== (const ChordPreset &lhs, const ChordPreset &rhs)
86{
87 return lhs.name_ == rhs.name_ && lhs.descr_ == rhs.descr_;
88}
89
93
94#endif
Chord preset pack.
A preset of chord descriptors.
ChordPresetPack * pack_
Pointer to owner pack.
std::vector< dsp::ChordDescriptor > descr_
Chord descriptors.
NameT name_
Preset name.
utils::Utf8String get_info_text() const
Gets informational text.