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 "istartupscenario.h"
26 :
27 : #include "async/asyncable.h"
28 :
29 : #include "modularity/ioc.h"
30 : #include "interactive/iinteractive.h"
31 : #include "rcommand/icommanddispatcher.h"
32 : #include "multiwindows/imultiwindowsprovider.h"
33 : #include "iappshellconfiguration.h"
34 : #include "isessionsmanager.h"
35 : #include "project/iprojectautosaver.h"
36 : #include "audioplugins/iregisteraudiopluginsscenario.h"
37 :
38 : #include "update/iappupdatescenario.h"
39 : #include "musesounds/imusesoundscheckupdatescenario.h"
40 : #include "musesounds/imusesamplercheckstatusscenario.h"
41 :
42 : namespace mu::appshell {
43 : class StartupScenario : public IStartupScenario, public muse::Contextable, public muse::async::Asyncable
44 : {
45 : muse::GlobalInject<muse::mi::IMultiWindowsProvider> multiwindowsProvider;
46 : muse::GlobalInject<IAppShellConfiguration> configuration;
47 : muse::ContextInject<mu::musesounds::IMuseSoundsCheckUpdateScenario> museSoundsUpdateScenario = { this };
48 : muse::ContextInject<musesounds::IMuseSamplerCheckStatusScenario> museSamplerCheckStatusScenario = { this };
49 : muse::ContextInject<muse::IInteractive> interactive = { this };
50 : muse::ContextInject<muse::rcommand::ICommandDispatcher> commandDispatcher = { this };
51 : muse::ContextInject<ISessionsManager> sessionsManager = { this };
52 : muse::ContextInject<project::IProjectAutoSaver> projectAutoSaver = { this };
53 : muse::ContextInject<muse::update::IAppUpdateScenario> appUpdateScenario = { this };
54 : muse::ContextInject<muse::audioplugins::IRegisterAudioPluginsScenario> registerAudioPluginsScenario = { this };
55 :
56 : public:
57 0 : StartupScenario(const muse::modularity::ContextPtr& iocCtx)
58 0 : : muse::Contextable(iocCtx) {}
59 :
60 : void setStartupType(const std::optional<std::string>& type) override;
61 :
62 : bool isStartWithNewFileAsSecondaryInstance() const override;
63 :
64 : const project::ProjectFile& startupScoreFile() const override;
65 : void setStartupScoreFile(const std::optional<project::ProjectFile>& file) override;
66 :
67 : void runOnSplashScreen() override;
68 : void runAfterSplashScreen() override;
69 : bool startupCompleted() const override;
70 :
71 : private:
72 : void registerAudioPlugins();
73 :
74 : StartupModeType resolveStartupModeType() const;
75 :
76 : void onStartupPageOpened(StartupModeType modeType);
77 :
78 : void showStartupDialogsIfNeed(StartupModeType modeType);
79 : void checkAndShowMuseSamplerStatusIfNeed();
80 : bool shouldShowWelcomeDialog(StartupModeType modeType) const;
81 :
82 : void openScore(const project::ProjectFile& file);
83 :
84 : void restoreLastSession();
85 : void removeProjectsUnsavedChanges(const muse::io::paths_t& projectsPaths);
86 :
87 : std::string m_startupTypeStr;
88 : project::ProjectFile m_startupScoreFile;
89 : bool m_startupCompleted = false;
90 : size_t m_activeUpdateCheckCount = 0;
91 : };
92 : }
|