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) 2026 MuseScore Limited
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 : #include "interactivemodule.h"
24 :
25 : #include "global/modularity/ioc.h"
26 : #include "muse_framework_config.h"
27 : #include "global/api/iapiregister.h"
28 :
29 : #include "internal/interactive.h"
30 : #include "internal/interactiveuriregister.h"
31 : #include "internal/platforminteractive.h"
32 : #include "types/uri.h"
33 :
34 : #ifdef Q_OS_WASM
35 : #include "internal/platform/web/webinteractive.h"
36 : #endif
37 :
38 : #include "api/interactiveapi.h"
39 :
40 : #include "dev/testdialog.h"
41 :
42 : using namespace muse::interactive;
43 : using namespace muse::modularity;
44 :
45 : static const std::string mname("interactive");
46 :
47 0 : std::string InteractiveModule::moduleName() const
48 : {
49 0 : return mname;
50 : }
51 :
52 0 : void InteractiveModule::registerExports()
53 : {
54 0 : globalIoc()->registerExport<IInteractiveUriRegister>(mname, new InteractiveUriRegister());
55 0 : globalIoc()->registerExport<IPlatformInteractive>(mname, new PlatformInteractive());
56 0 : }
57 :
58 0 : void InteractiveModule::registerApi()
59 : {
60 : using namespace muse::api;
61 :
62 0 : auto api = globalIoc()->resolve<IApiRegister>(mname);
63 0 : if (api) {
64 0 : api->regApiCreator(mname, "MuseApi.Interactive", new ApiCreator<InteractiveApi>());
65 :
66 0 : api->regGlobalEnum(mname, QMetaEnum::fromType<InteractiveApi::ButtonCode>());
67 : }
68 0 : }
69 :
70 0 : void InteractiveModule::resolveImports()
71 : {
72 0 : auto ir = globalIoc()->resolve<IInteractiveUriRegister>(mname);
73 0 : if (ir) {
74 0 : ir->registerQmlUri(Uri("muse://interactive/standard"), "Muse.Interactive", "StandardDialog");
75 0 : ir->registerQmlUri(Uri("muse://interactive/error"), "Muse.Interactive", "ErrorDetailsView");
76 0 : ir->registerQmlUri(Uri("muse://interactive/progress"), "Muse.Interactive", "ProgressDialog");
77 0 : ir->registerQmlUri(Uri("muse://interactive/selectfile"), "Muse.Interactive", "FileDialog");
78 0 : ir->registerQmlUri(Uri("muse://interactive/selectdir"), "Muse.Interactive", "FolderDialog");
79 :
80 0 : ir->registerQmlUri(Uri("muse://devtools/interactive/sample"), "Muse.Interactive", "SampleDialog");
81 0 : ir->registerWidgetUri<TestDialog>(Uri("muse://devtools/interactive/testdialog"));
82 : }
83 0 : }
84 :
85 0 : IContextSetup* InteractiveModule::newContext(const ContextPtr& ctx) const
86 : {
87 0 : return new InteractiveContext(ctx);
88 : }
89 :
90 0 : void InteractiveContext::registerExports()
91 : {
92 0 : auto interactive = std::make_shared<Interactive>(iocContext());
93 : #ifdef Q_OS_WASM
94 : ioc()->registerExport<IInteractive>(mname, new WebInteractive(interactive));
95 : #else
96 0 : ioc()->registerExport<IInteractive>(mname, interactive);
97 : #endif
98 :
99 0 : ioc()->registerExport<IInteractiveProvider>(mname, interactive);
100 0 : }
|