Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #pragma once
24 :
25 : #include <QObject>
26 : #include <QString>
27 :
28 : #include "iprojectcommandscontroller.h"
29 :
30 : #include "modularity/ioc.h"
31 : #include "interactive/iinteractive.h"
32 : #include "project/iprojectsession.h"
33 : #include "rcommand/commandtypes.h"
34 : #include "rcommand/icommanddispatcher.h"
35 : #include "rcommand/commandable.h"
36 : #include "rcommand/icommanddispatcher.h"
37 : #include "multiwindows/imultiwindowsprovider.h"
38 : #include "multiwindows/iprojectprovider.h"
39 : #include "print/iprintprovider.h"
40 : #include "icloseprojectscenario.h"
41 : #include "iopenprojectscenario.h"
42 : #include "isaveprojectscenario.h"
43 : #include "iconvertfiletoscorescenario.h"
44 :
45 : #include "async/asyncable.h"
46 :
47 : #include "irecentfilescontroller.h"
48 :
49 : namespace mu::project {
50 : class ProjectActionsController : public IProjectCommandsController, public muse::mi::IProjectProvider, public muse::Contextable,
51 : public muse::async::Asyncable, public muse::rcommand::Commandable
52 : {
53 : public:
54 : muse::GlobalInject<muse::mi::IMultiWindowsProvider> multiwindowsProvider;
55 : muse::ContextInject<IRecentFilesController> recentFilesController = { this };
56 : muse::ContextInject<IOpenProjectScenario> openProjectScenario = { this };
57 : muse::ContextInject<ISaveProjectScenario> saveProjectScenario = { this };
58 : muse::ContextInject<ICloseProjectScenario> closeProjectScenario = { this };
59 : muse::ContextInject<IConvertFileToScoreScenario> convertFileToScoreScenario = { this };
60 : muse::ContextInject<muse::rcommand::ICommandDispatcher> commandDispatcher = { this };
61 : muse::ContextInject<muse::IInteractive> interactive = { this };
62 : muse::ContextInject<project::IProjectSession> projectSession = { this };
63 : muse::ContextInject<print::IPrintProvider> printProvider = { this };
64 :
65 0 : ProjectActionsController(const muse::modularity::ContextPtr& iocCtx)
66 0 : : muse::Contextable(iocCtx) {}
67 :
68 : void init();
69 :
70 : // IProjectCommandsController
71 : bool hasProject() const override;
72 : muse::async::Notification hasProjectChanged() const override;
73 : bool needSave() const override;
74 : muse::async::Notification needSaveChanged() const override;
75 : bool isBusy(BusyStatus status) const override;
76 : muse::async::Notification busyChanged() const override;
77 : bool hasSelection() const override;
78 : muse::async::Notification hasSelectionChanged() const override;
79 : // --------
80 :
81 : // mi::IProjectProvider
82 : bool isProjectOpened(const muse::io::path_t& scorePath) const override;
83 : bool isAnyProjectOpened() const override;
84 :
85 : private:
86 : void setupConnections();
87 :
88 : project::INotationProjectPtr currentNotationProject() const;
89 : notation::IMasterNotationPtr currentMasterNotation() const;
90 : notation::INotationPtr currentNotation() const;
91 : notation::INotationInteractionPtr currentInteraction() const;
92 : notation::INotationSelectionPtr currentNotationSelection() const;
93 :
94 : muse::Ret newProject();
95 :
96 : muse::Ret openProject(const muse::rcommand::Params& params);
97 : muse::Ret openProject(const muse::io::path_t& path, const QString& displayNameOverride = QString());
98 :
99 : muse::Ret openPageIfNeed(muse::Uri pageUri);
100 :
101 : muse::Ret closeProject();
102 : muse::Ret runAsync(muse::async::Promise<muse::Ret> flow);
103 :
104 : muse::async::Promise<muse::Ret> saveProject(SaveMode saveMode, SaveLocationType saveLocationType = SaveLocationType::Undefined,
105 : bool force = false);
106 : muse::async::Promise<muse::Ret> publish();
107 : muse::async::Promise<muse::Ret> sharedAudio();
108 : muse::async::Promise<muse::Ret> saveProjectAt(const muse::rcommand::Params& params);
109 :
110 : muse::Ret convertFileToScore();
111 :
112 : muse::Ret clearRecentScores();
113 :
114 : muse::Ret continueLastSession();
115 :
116 : muse::Ret openProjectProperties();
117 :
118 : muse::Ret exportScore();
119 : muse::Ret printScore();
120 :
121 : void setBusy(BusyStatus status, bool isBusy);
122 :
123 : std::set<BusyStatus> m_busyStatuses;
124 : muse::async::Notification m_busyChanged;
125 :
126 : muse::async::Notification m_needSaveChanged;
127 : muse::async::Notification m_hasSelectionChanged;
128 : };
129 : }
|