Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
chord_preset.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 <span>
7
8#include "dsp/chord_descriptor.h"
9#include "utils/icloneable.h"
10#include "utils/qt.h"
11
12#include <QtQmlIntegration/qqmlintegration.h>
13
20class ChordPreset : public QObject
21{
22 Q_OBJECT
23 Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged)
24 Q_PROPERTY (
25 QString category READ category WRITE setCategory NOTIFY categoryChanged)
26 Q_PROPERTY (bool isBuiltin READ isBuiltin CONSTANT FINAL)
27 QML_ELEMENT
28
29public:
30 ChordPreset (QObject * parent = nullptr);
31 ChordPreset (const QString &name, QObject * parent = nullptr);
32 ChordPreset (
33 const QString &name,
34 const QString &category,
35 bool is_builtin,
36 QObject * parent = nullptr);
37
38 // =================================================================
39 // QML Interface
40 // =================================================================
41
42 QString name () const;
43 void setName (const QString &name);
44 Q_SIGNAL void nameChanged (const QString &name);
45
46 QString category () const;
47 void setCategory (const QString &category);
48 Q_SIGNAL void categoryChanged (const QString &category);
49
50 bool isBuiltin () const { return is_builtin_; }
51
55 Q_INVOKABLE QString infoText () const;
56
57 // =================================================================
58 // Descriptor access
59 // =================================================================
60
61 std::span<const zrythm::utils::QObjectUniquePtr<zrythm::dsp::ChordDescriptor>>
62 descriptors () const
63 {
64 return descr_;
65 }
66
67 void addDescriptor (
69
70 friend bool operator== (const ChordPreset &lhs, const ChordPreset &rhs);
71
72 friend void init_from (
73 ChordPreset &obj,
74 const ChordPreset &other,
76
77private:
78 static constexpr std::string_view kNameKey = "name";
79 static constexpr std::string_view kDescriptorsKey = "descriptors";
80 static constexpr std::string_view kCategoryKey = "category";
81 friend void to_json (nlohmann::json &j, const ChordPreset &preset);
82 friend void from_json (const nlohmann::json &j, ChordPreset &preset);
83
85 QString name_;
86
88 QString category_;
89
91 bool is_builtin_ = false;
92
94 std::vector<zrythm::utils::QObjectUniquePtr<zrythm::dsp::ChordDescriptor>>
95 descr_;
96};
A named collection of chord descriptors, optionally grouped by category.
Q_INVOKABLE QString infoText() const
Informational text describing the preset's chords.
A unique pointer for QObject objects that also works with QObject-based ownership.
Definition qt.h:36