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) 2026 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 : #pragma once
23 :
24 : #include "../../imultiwindowsprovider.h"
25 :
26 : #include "global/modularity/ioc.h"
27 : #include "global/iapplication.h"
28 : #include "global/async/asyncable.h"
29 :
30 : //! NOTE Work in progress
31 :
32 : namespace muse::ui {
33 : class IMainWindow;
34 : }
35 :
36 : namespace muse::rcommand {
37 : class ICommandDispatcher;
38 : }
39 :
40 : namespace muse::mi {
41 : class IProjectProvider;
42 : class SingleProcessProvider : public IMultiWindowsProvider, public async::Asyncable
43 : {
44 : GlobalInject<IApplication> application;
45 :
46 : public:
47 :
48 0 : void initOnGlobal() {}
49 :
50 : // Windows info
51 : size_t windowCount() const override;
52 : bool isFirstWindow() const override;
53 :
54 : // Project opening
55 : bool isProjectAlreadyOpened(const muse::io::path_t& projectPath) const override;
56 : void activateWindowWithProject(const muse::io::path_t& projectPath) override;
57 : bool isHasWindowWithoutProject() const override;
58 : void activateWindowWithoutProject(const QStringList& args = { }) override;
59 : bool openNewWindow(const QStringList& args) override;
60 :
61 : // Settings
62 0 : bool isPreferencesAlreadyOpened() const override { return false; }
63 0 : void activateWindowWithOpenedPreferences() const override {}
64 0 : void settingsBeginTransaction() override {}
65 0 : void settingsCommitTransaction() override {}
66 0 : void settingsRollbackTransaction() override {}
67 0 : void settingsReset() override {}
68 0 : void settingsSetValue(const std::string&, const muse::Val&) override {}
69 :
70 : // Resources (files)
71 0 : bool lockResource(const std::string&) override { return false; }
72 0 : bool unlockResource(const std::string&) override { return false; }
73 0 : void notifyAboutResourceChanged(const std::string&) override { }
74 0 : muse::async::Channel<std::string> resourceChanged() override { return {}; }
75 :
76 : // Quit for all
77 0 : void notifyAboutWindowWasQuited() override {}
78 : async::Promise<Ret> quitForAll(const modularity::ContextPtr& ctx) override;
79 : void quitWindow(const modularity::ContextPtr& ctx) override;
80 0 : void quitAllAndRestartLast() override {}
81 0 : void quitAllAndRunInstallation(const muse::io::path_t&) override {}
82 :
83 : private:
84 : std::shared_ptr<IProjectProvider> projectProvider(const modularity::ContextPtr& ctx) const;
85 : std::shared_ptr<ui::IMainWindow> mainWindow(const modularity::ContextPtr& ctx) const;
86 : std::shared_ptr<rcommand::ICommandDispatcher> commandDispatcher(const modularity::ContextPtr& ctx) const;
87 :
88 : async::Promise<Ret> quitWindows(const std::vector<modularity::ContextPtr>& ctxs);
89 : };
90 : }
|