Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm_application.h
1// SPDX-FileCopyrightText: © 2019-2025 Alexandros Theodotou <alex@zrythm.org>
2/* SPDX-License-Identifier: LicenseRef-ZrythmLicense */
3
4#pragma once
5
6#include "dsp/juce_hardware_audio_interface.h"
7#include "engine/session/control_room.h"
8#include "engine/session/midi_mapping.h"
9#include "gui/backend/alert_manager.h"
10#include "gui/backend/backend/theme_manager.h"
11#include "gui/backend/device_manager.h"
12#include "gui/backend/file_system_model.h"
13#include "gui/backend/plugin_manager.h"
14#include "gui/backend/project_manager.h"
15#include "gui/backend/translation_manager.h"
16#include "utils/app_settings.h"
17#include "utils/directory_manager.h"
18#include "utils/qt.h"
19
20#include <QApplication>
21#include <QCommandLineParser>
22#include <QLocalSocket>
23#include <QProcess>
24#include <QQmlApplicationEngine>
25#include <QTranslator>
26
27namespace backward
28{
29class SignalHandling;
30}
31
32namespace zrythm::gui
33{
34
35class ZrythmApplication final : public QApplication
36{
37 Q_OBJECT
38 Q_PROPERTY (
39 zrythm::gui::ThemeManager * themeManager READ themeManager CONSTANT FINAL)
40 Q_PROPERTY (
41 zrythm::utils::AppSettings * appSettings READ appSettings CONSTANT FINAL)
42 Q_PROPERTY (
43 zrythm::gui::ProjectManager * projectManager READ projectManager CONSTANT
44 FINAL)
45 Q_PROPERTY (
47 pluginManager CONSTANT FINAL)
48 Q_PROPERTY (
49 zrythm::gui::AlertManager * alertManager READ alertManager CONSTANT FINAL)
50 Q_PROPERTY (
51 zrythm::gui::TranslationManager * translationManager READ translationManager
52 CONSTANT FINAL)
53 Q_PROPERTY (
54 zrythm::gui::backend::DeviceManager * deviceManager READ deviceManager
55 CONSTANT FINAL)
56 Q_PROPERTY (
57 zrythm::gui::FileSystemModel * fileSystemModel READ fileSystemModel CONSTANT
58 FINAL)
59 Q_PROPERTY (
60 zrythm::engine::session::ControlRoom * controlRoom READ controlRoom CONSTANT
61 FINAL)
62 QML_ELEMENT
63 QML_UNCREATABLE ("")
64
65public:
66 ZrythmApplication (int &argc, char ** argv);
67 ~ZrythmApplication () override;
68 Z_DISABLE_COPY_MOVE (ZrythmApplication)
69
70 void setup_ui ();
71 void setup_ipc ();
72 void launch_engine_process ();
73
74 zrythm::gui::ThemeManager * themeManager () const
75 {
76 return theme_manager_.get ();
77 }
78 zrythm::utils::AppSettings * appSettings () const
79 {
80 return app_settings_.get ();
81 }
82 zrythm::gui::ProjectManager * projectManager () const
83 {
84 return project_manager_.get ();
85 }
86 old_dsp::plugins::PluginManager * pluginManager () const
87 {
88 return plugin_manager_.get ();
89 }
90 zrythm::gui::AlertManager * alertManager () const
91 {
92 return alert_manager_.get ();
93 }
94 zrythm::gui::TranslationManager * translationManager () const
95 {
96 return translation_manager_.get ();
97 }
98 zrythm::gui::backend::DeviceManager * deviceManager () const
99 {
100 return device_manager_.get ();
101 }
102 zrythm::gui::FileSystemModel * fileSystemModel () const
103 {
104 return file_system_model_.get ();
105 }
106
107 engine::session::ControlRoom * controlRoom () const
108 {
109 return control_room_.get ();
110 }
111
112 DirectoryManager &get_directory_manager () const { return *dir_manager_; }
113
114 QQmlApplicationEngine * get_qml_engine () const { return qml_engine_; }
115
116 std::shared_ptr<gui::backend::DeviceManager> get_device_manager () const
117 {
118 return device_manager_;
119 }
120
121 dsp::IHardwareAudioInterface &hw_audio_interface () const
122 {
123 return *hw_audio_interface_;
124 }
125
126private:
127 void setup_command_line_options ();
128
129 void post_exec_initialization ();
130
131 void setup_device_manager ();
132
133 void setup_control_room ();
134
135private Q_SLOTS:
136 void onEngineOutput ();
137 void onAboutToQuit ();
138
139public:
140 QCommandLineParser cmd_line_parser_;
141
142private:
143 std::unique_ptr<backward::SignalHandling> signal_handling_;
144 std::unique_ptr<juce::ScopedJuceInitialiser_GUI>
145 juce_message_handler_initializer_;
146
148
152 QLocalSocket * socket_ = nullptr;
153
154 std::unique_ptr<DirectoryManager> dir_manager_;
161
166 plugin_manager_;
167
171 QProcess * engine_process_ = nullptr;
172
180 utils::QObjectUniquePtr<QTimer> juce_dispatch_timer_;
181
182 QQmlApplicationEngine * qml_engine_ = nullptr;
183
184 QTranslator * translator_ = nullptr;
185
186 std::shared_ptr<gui::backend::DeviceManager> device_manager_;
187
193 std::unique_ptr<dsp::IHardwareAudioInterface> hw_audio_interface_;
194
196 std::unique_ptr<engine::session::MidiMappings> midi_mappings_;
197};
198
199} // namespace zrythm::gui
This can just be created on the stack as needed since it uses globally available information.
Abstraction for hardware audio interface.
Abstraction to control the signal coming in from Master and going out into the speakers.
This doesn't work - see https://forum.qt.io/topic/124965/how-to-define-a-property-of-type-palette/8.
Wrapper over juce::AudioDeviceManager that exposes changes as signals.
The PluginManager is responsible for scanning and keeping track of available Plugin's.
A unique pointer for QObject objects that also works with QObject-based ownership.
Definition qt.h:38