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 : #include "instrumentsscenemodule.h"
24 :
25 : #include "modularity/ioc.h"
26 :
27 : #include "rcommand/icommandsregister.h"
28 : #include "rcommand/icommandsstate.h"
29 : #include "interactive/iinteractiveuriregister.h"
30 :
31 : #include "internal/selectinstrumentscenario.h"
32 : #include "internal/instrumentsactionscontroller.h"
33 : #include "internal/instrumentscommandsregister.h"
34 : #include "internal/instrumentscommandsstate.h"
35 :
36 : using namespace mu::instrumentsscene;
37 : using namespace muse;
38 : using namespace muse::modularity;
39 :
40 : static const std::string mname("instrumentsscene");
41 :
42 0 : std::string InstrumentsSceneModule::moduleName() const
43 : {
44 0 : return mname;
45 : }
46 :
47 0 : void InstrumentsSceneModule::resolveImports()
48 : {
49 0 : auto ir = globalIoc()->resolve<interactive::IInteractiveUriRegister>(mname);
50 0 : if (ir) {
51 0 : ir->registerQmlUri(Uri("musescore://instruments/select"), "MuseScore.InstrumentsScene", "InstrumentsDialog");
52 : }
53 :
54 0 : auto cr = globalIoc()->resolve<muse::rcommand::ICommandsRegister>(mname);
55 0 : if (cr) {
56 0 : cr->reg(std::make_shared<InstrumentsCommandsRegister>());
57 : }
58 0 : }
59 :
60 0 : IContextSetup* InstrumentsSceneModule::newContext(const muse::modularity::ContextPtr& ctx) const
61 : {
62 0 : return new InstrumentsSceneContext(ctx);
63 : }
64 :
65 : // Context
66 :
67 0 : void InstrumentsSceneContext::registerExports()
68 : {
69 0 : m_actionsController = std::make_shared<InstrumentsActionsController>(iocContext());
70 :
71 0 : ioc()->registerExport<notation::ISelectInstrumentsScenario>(mname, new SelectInstrumentsScenario(iocContext()));
72 0 : }
73 :
74 0 : void InstrumentsSceneContext::resolveImports()
75 : {
76 0 : auto cs = ioc()->resolve<muse::rcommand::ICommandsState>(mname);
77 0 : if (cs) {
78 0 : cs->reg(std::make_shared<InstrumentsCommandsState>(iocContext()));
79 : }
80 0 : }
81 :
82 0 : void InstrumentsSceneContext::onInit(const IApplication::RunMode&)
83 : {
84 0 : m_actionsController->init();
85 0 : }
|