Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-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 <QtGlobal>
26 :
27 : #include "modularity/imodulesetup.h"
28 :
29 : namespace muse::api {
30 : class ThemeApi;
31 : }
32 :
33 : namespace muse::ui {
34 : class UiConfiguration;
35 : class WidgetStyle;
36 :
37 : #ifdef Q_OS_MAC
38 : class MacOSPlatformTheme;
39 : #elif defined(Q_OS_WIN)
40 : class WindowsPlatformTheme;
41 : #elif defined(Q_OS_LINUX)
42 : class LinuxPlatformTheme;
43 : #else
44 : class StubPlatformTheme;
45 : #endif
46 :
47 : class UiModule : public modularity::IModuleSetup
48 : {
49 : public:
50 : std::string moduleName() const override;
51 :
52 : void registerExports() override;
53 : void resolveImports() override;
54 : void registerApi() override;
55 : void onPreInit(const IApplication::RunMode& mode) override;
56 : void onInit(const IApplication::RunMode& mode) override;
57 : void onAllInited(const IApplication::RunMode& mode) override;
58 : void onDeinit() override;
59 :
60 : modularity::IContextSetup* newContext(const muse::modularity::ContextPtr& ctx) const override;
61 :
62 : private:
63 : std::shared_ptr<UiConfiguration> m_configuration;
64 : std::shared_ptr<api::ThemeApi> m_theme;
65 : WidgetStyle* m_widgetStyle = nullptr; // becomes owned by QApplication
66 :
67 : #ifdef Q_OS_MAC
68 : std::shared_ptr<MacOSPlatformTheme> m_platformTheme;
69 : #elif defined(Q_OS_WIN)
70 : std::shared_ptr<WindowsPlatformTheme> m_platformTheme;
71 : #elif defined(Q_OS_LINUX)
72 : std::shared_ptr<LinuxPlatformTheme> m_platformTheme;
73 : #else
74 : std::shared_ptr<StubPlatformTheme> m_platformTheme;
75 : #endif
76 : };
77 :
78 : class UiState;
79 : class UiEngine;
80 : class UiActionsRegister;
81 : class NavigationController;
82 : class NavigationUiActions;
83 : class WindowsController;
84 : class UiModuleContext : public modularity::IContextSetup
85 : {
86 : public:
87 :
88 0 : UiModuleContext(const modularity::ContextPtr& ctx)
89 0 : : modularity::IContextSetup(ctx) {}
90 :
91 : void registerExports() override;
92 : void resolveImports() override;
93 : void onInit(const IApplication::RunMode& mode) override;
94 : void onAllInited(const IApplication::RunMode& mode) override;
95 :
96 : private:
97 : std::shared_ptr<UiState> m_uistate;
98 : std::shared_ptr<UiEngine> m_uiengine;
99 : std::shared_ptr<UiActionsRegister> m_uiactionsRegister;
100 : std::shared_ptr<NavigationController> m_keyNavigationController;
101 : std::shared_ptr<WindowsController> m_windowsController;
102 : };
103 : }
|