Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
project_manager.h
1// SPDX-FileCopyrightText: © 2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "gui/backend/backend/project.h"
7
8#include <QtQmlIntegration>
9
10#include "recent_projects_model.h"
11
12namespace zrythm::gui
13{
14
15class ProjectManager : public QObject
16{
17 Q_OBJECT
18 QML_ELEMENT
19 Q_PROPERTY (
20 zrythm::gui::RecentProjectsModel * recentProjects READ getRecentProjects
21 CONSTANT)
22 Q_PROPERTY (
23 Project * activeProject READ getActiveProject WRITE setActiveProject NOTIFY
24 activeProjectChanged)
25
26public:
27 ProjectManager (QObject * parent = nullptr);
28
29 using Template = fs::path;
30 using TemplateList = std::vector<Template>;
31 using ProjectLoadResult = std::variant<Project *, QString>;
32
33 static ProjectManager * get_instance ();
34
38 TemplateList get_templates () const;
39
45 Q_INVOKABLE static QString
46 getNextAvailableProjectName (const QUrl &directory, const QString &name);
47
48 Q_INVOKABLE void createNewProject (
49 const QUrl &directory,
50 const QString &name,
51 const QUrl &templateUrl = QUrl{});
52 Q_INVOKABLE void loadProject (const QString &filepath);
53
54 void add_to_recent_projects (const QString &path);
55
56 RecentProjectsModel * getRecentProjects () const;
57
58 Project * getActiveProject () const;
59 void setActiveProject (Project * project);
60
61Q_SIGNALS:
62 void projectLoaded (Project * project);
63 void projectLoadingFailed (const QString &errorMessage);
64 void activeProjectChanged (Project * project);
65
66private:
70 void init_templates ();
71
72 // void create_or_load_project (const QString &filepath, bool is_template);
73
78 void load_from_file ();
79
91 Project * create_default (
92 const fs::path &prj_dir,
93 const utils::Utf8String &name,
94 bool with_engine);
95
96private:
98 TemplateList templates_;
99
105 Template demo_template_;
106
107 RecentProjectsModel * recent_projects_model_ = nullptr;
108
114 Project * active_project_ = nullptr;
115
121 QFutureWatcher<ProjectLoadResult> project_watcher_;
122};
123
124}
Contains all of the info that will be serialized into a project file.
Definition project.h:99
TemplateList get_templates() const
Gets a copy of the list of project templates.
static Q_INVOKABLE QString getNextAvailableProjectName(const QUrl &directory, const QString &name)
Get the next available untitled project name for the given directory.
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:38