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 "async/asyncable.h"
26 :
27 : #include "modularity/ioc.h"
28 : #include "global/iglobalconfiguration.h"
29 : #include "global/iapplication.h"
30 : #include "global/io/ifilesystem.h"
31 : #include "multiwindows/imultiwindowsprovider.h"
32 : #include "ui/iuiconfiguration.h"
33 : #include "project/iprojectconfiguration.h"
34 : #include "notation/inotationconfiguration.h"
35 : #include "playback/iplaybackconfiguration.h"
36 : #include "languages/ilanguagesconfiguration.h"
37 : #include "update/iupdateconfiguration.h"
38 :
39 : #include "iappshellconfiguration.h"
40 :
41 : namespace mu::appshell {
42 : class AppShellConfiguration : public IAppShellConfiguration, public muse::Contextable, public muse::async::Asyncable
43 : {
44 : muse::GlobalInject<muse::IGlobalConfiguration> globalConfiguration;
45 : muse::GlobalInject<muse::io::IFileSystem> fileSystem;
46 : muse::GlobalInject<muse::mi::IMultiWindowsProvider> multiwindowsProvider;
47 : muse::GlobalInject<muse::ui::IUiConfiguration> uiConfiguration;
48 : muse::GlobalInject<project::IProjectConfiguration> projectConfiguration;
49 : muse::GlobalInject<notation::INotationConfiguration> notationConfiguration;
50 : muse::GlobalInject<playback::IPlaybackConfiguration> playbackConfiguration;
51 : muse::GlobalInject<muse::languages::ILanguagesConfiguration> languagesConfiguration;
52 : muse::GlobalInject<muse::IApplication> application;
53 : muse::GlobalInject<muse::update::IUpdateConfiguration> updateConfiguration;
54 :
55 : public:
56 0 : AppShellConfiguration(const muse::modularity::ContextPtr& iocCtx)
57 0 : : muse::Contextable(iocCtx) {}
58 :
59 : void init();
60 :
61 : bool hasCompletedFirstLaunchSetup() const override;
62 : void setHasCompletedFirstLaunchSetup(bool has) override;
63 :
64 : bool welcomeDialogShowOnStartup() const override;
65 : void setWelcomeDialogShowOnStartup(bool show) override;
66 : muse::async::Notification welcomeDialogShowOnStartupChanged() const override;
67 :
68 : std::string welcomeDialogLastShownVersion() const override;
69 : void setWelcomeDialogLastShownVersion(const std::string& version) override;
70 :
71 : int welcomeDialogLastShownIndex() const override;
72 : void setWelcomeDialogLastShownIndex(int index) override;
73 :
74 : StartupModeType startupModeType() const override;
75 : void setStartupModeType(StartupModeType type) override;
76 : muse::async::Notification startupModeTypeChanged() const override;
77 :
78 : muse::io::path_t startupScorePath() const override;
79 : void setStartupScorePath(const muse::io::path_t& scorePath) override;
80 : muse::async::Notification startupScorePathChanged() const override;
81 :
82 : std::string handbookUrl() const override;
83 : std::string askForHelpUrl() const override;
84 : std::string accessibilityStatementUrl() const override;
85 : std::string museScoreUrl() const override;
86 : std::string museScoreForumUrl() const override;
87 : std::string museScoreContributionUrl() const override;
88 : std::string museHubFreeMuseSoundsUrl() const override;
89 : std::string musicXMLLicenseUrl() const override;
90 : std::string musicXMLLicenseDeedUrl() const override;
91 :
92 : std::string museScoreVersion() const override;
93 : std::string museScoreRevision() const override;
94 :
95 : bool needShowSplashScreen() const override;
96 : void setNeedShowSplashScreen(bool show) override;
97 :
98 : const QString& preferencesDialogLastOpenedPageId() const override;
99 : void setPreferencesDialogLastOpenedPageId(const QString& lastOpenedPageId) override;
100 :
101 : void startEditSettings() override;
102 : void applySettings() override;
103 : void rollbackSettings() override;
104 :
105 : void revertToFactorySettings(bool keepDefaultSettings = false, bool notifyAboutChanges = true,
106 : bool notifyOtherInstances = true) const override;
107 :
108 : muse::io::paths_t sessionProjectsPaths() const override;
109 : muse::Ret setSessionProjectsPaths(const muse::io::paths_t& paths) override;
110 :
111 : private:
112 : std::string utmParameters(const std::string& utmMedium) const;
113 :
114 : std::string currentLanguageCode() const;
115 :
116 : muse::io::path_t sessionDataPath() const;
117 : muse::io::path_t sessionFilePath() const;
118 :
119 : muse::RetVal<muse::ByteArray> readSessionState() const;
120 : muse::Ret writeSessionState(const QByteArray& data);
121 :
122 : muse::io::paths_t parseSessionProjectsPaths(const QByteArray& json) const;
123 :
124 : QString m_preferencesDialogCurrentPageId;
125 :
126 : muse::async::Notification m_welcomeDialogShowOnStartupChanged;
127 :
128 : muse::async::Notification m_startupModeTypeChanged;
129 : muse::async::Notification m_startupScorePathChanged;
130 : };
131 : }
|