Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
qobject_property_operator.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <stdexcept>
7
8#include "undo/undo_stack.h"
9
10#include <QtQmlIntegration/qqmlintegration.h>
11
12namespace zrythm::actions
13{
14class QObjectPropertyOperator : public QObject
15{
16 Q_OBJECT
17 Q_PROPERTY (
18 QObject * currentObject READ currentObject WRITE setCurrentObject NOTIFY
19 currentObjectChanged)
20 Q_PROPERTY (
21 zrythm::undo::UndoStack * undoStack READ undoStack WRITE setUndoStack NOTIFY
22 undoStackChanged)
23 QML_ELEMENT
24
25public:
26 explicit QObjectPropertyOperator (QObject * parent = nullptr)
27 : QObject (parent)
28 {
29 }
30
31 Q_SIGNAL void currentObjectChanged ();
32 Q_SIGNAL void undoStackChanged ();
33
34 QObject * currentObject () const { return current_object_; }
35 void setCurrentObject (QObject * object)
36 {
37 if (object == nullptr)
38 {
39 throw std::invalid_argument ("Object cannot be null");
40 }
41 if (current_object_ != object)
42 {
43 current_object_ = object;
44 Q_EMIT currentObjectChanged ();
45 }
46 }
47
48 undo::UndoStack * undoStack () const { return undo_stack_; }
49 void setUndoStack (undo::UndoStack * undoStack)
50 {
51 if (undoStack == nullptr)
52 {
53 throw std::invalid_argument ("UndoStack cannot be null");
54 }
55 if (undo_stack_ != undoStack)
56 {
57 undo_stack_ = undoStack;
58 Q_EMIT undoStackChanged ();
59 }
60 }
61
62 Q_INVOKABLE void setValue (QString propertyName, QVariant value);
63
69 Q_INVOKABLE void
70 setValueAffectingTempoMap (QString propertyName, QVariant value);
71
72private:
73 QObject * current_object_{};
74 undo::UndoStack * undo_stack_{};
75};
76}
Q_INVOKABLE void setValueAffectingTempoMap(QString propertyName, QVariant value)
Set a value that affects the tempo map.