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 : #include "notationscenemodule.h"
23 :
24 : #include "modularity/ioc.h"
25 : #include "interactive/iinteractiveuriregister.h"
26 : #include "rcommand/icommandsregister.h"
27 : #include "rcommand/icommandsstate.h"
28 :
29 : #include "internal/notationsceneconfiguration.h"
30 : #include "internal/notationactioncontroller.h"
31 : #include "internal/midiinputoutputcontroller.h"
32 : #include "internal/notationcommandsregister.h"
33 : #include "internal/notationcommandsstate.h"
34 : #include "internal/notationactioncontroller.h"
35 :
36 : #include "widgets/breaksdialog.h"
37 : #include "widgets/editstaff.h"
38 : #include "widgets/editstringdata.h"
39 : #include "widgets/editstyle.h"
40 : #include "widgets/measureproperties.h"
41 : #include "widgets/pagesettings.h"
42 : #include "widgets/realizeharmonydialog.h"
43 : #include "widgets/selectdialog.h"
44 : #include "widgets/selectnotedialog.h"
45 : #include "widgets/stafftextpropertiesdialog.h"
46 : #include "widgets/transposedialog.h"
47 : #include "widgets/tupletdialog.h"
48 :
49 : using namespace mu::notation;
50 : using namespace muse;
51 : using namespace muse::modularity;
52 :
53 : static const std::string mname("notationscene");
54 :
55 0 : std::string NotationSceneModule::moduleName() const
56 : {
57 0 : return mname;
58 : }
59 :
60 0 : void NotationSceneModule::registerExports()
61 : {
62 0 : m_configuration = std::make_shared<NotationSceneConfiguration>();
63 :
64 0 : globalIoc()->registerExport<INotationSceneConfiguration>(mname, m_configuration);
65 0 : }
66 :
67 0 : void NotationSceneModule::resolveImports()
68 : {
69 0 : auto ir = globalIoc()->resolve<muse::interactive::IInteractiveUriRegister>("notationscene");
70 0 : if (ir) {
71 0 : ir->registerWidgetUri<EditStyle>(Uri("musescore://notation/style"));
72 0 : ir->registerWidgetUri<PageSettings>(Uri("musescore://notation/pagesettings"));
73 0 : ir->registerWidgetUri<MeasurePropertiesDialog>(Uri("musescore://notation/measureproperties"));
74 0 : ir->registerWidgetUri<BreaksDialog>(Uri("musescore://notation/breaks"));
75 0 : ir->registerWidgetUri<EditStaff>(Uri("musescore://notation/staffproperties"));
76 0 : ir->registerWidgetUri<EditStringData>(Uri("musescore://notation/editstrings"));
77 0 : ir->registerWidgetUri<TransposeDialog>(Uri("musescore://notation/transpose"));
78 0 : ir->registerWidgetUri<SelectNoteDialog>(Uri("musescore://notation/selectnote"));
79 0 : ir->registerWidgetUri<SelectDialog>(Uri("musescore://notation/selectelement"));
80 0 : ir->registerWidgetUri<TupletDialog>(Uri("musescore://notation/othertupletdialog"));
81 0 : ir->registerWidgetUri<StaffTextPropertiesDialog>(Uri("musescore://notation/stafftextproperties"));
82 0 : ir->registerWidgetUri<RealizeHarmonyDialog>(Uri("musescore://notation/realizechordsymbols"));
83 :
84 0 : ir->registerQmlUri(Uri("musescore://notation/parts"), "MuseScore.NotationScene", "PartsDialog");
85 0 : ir->registerQmlUri(Uri("musescore://notation/selectmeasurescount"), "MuseScore.NotationScene", "SelectMeasuresCountDialog");
86 0 : ir->registerQmlUri(Uri("musescore://notation/editgridsize"), "MuseScore.NotationScene", "EditGridSizeDialog");
87 0 : ir->registerQmlUri(Uri("musescore://notation/percussionpanelpadswap"), "MuseScore.NotationScene", "PercussionPanelPadSwapDialog");
88 0 : ir->registerQmlUri(Uri("musescore://notation/editpercussionshortcut"), "MuseScore.NotationScene", "EditPercussionShortcutDialog");
89 : }
90 :
91 0 : auto cr = globalIoc()->resolve<muse::rcommand::ICommandsRegister>(mname);
92 0 : if (cr) {
93 0 : cr->reg(std::make_shared<NotationCommandsRegister>());
94 : }
95 0 : }
96 :
97 0 : void NotationSceneModule::onInit(const IApplication::RunMode&)
98 : {
99 0 : m_configuration->init();
100 0 : }
101 :
102 0 : IContextSetup* NotationSceneModule::newContext(const muse::modularity::ContextPtr& ctx) const
103 : {
104 0 : return new NotationSceneContext(ctx);
105 : }
106 :
107 0 : void NotationSceneContext::registerExports()
108 : {
109 0 : m_actionController = std::make_shared<NotationActionController>(iocContext());
110 0 : m_midiInputOutputController = std::make_shared<MidiInputOutputController>(iocContext());
111 :
112 0 : ioc()->registerExport<INotationCommandsController>(mname, m_actionController);
113 0 : }
114 :
115 0 : void NotationSceneContext::resolveImports()
116 : {
117 0 : auto cs = ioc()->resolve<muse::rcommand::ICommandsState>(mname);
118 0 : if (cs) {
119 0 : cs->reg(std::make_shared<NotationCommandsState>(iocContext()));
120 : }
121 0 : }
122 :
123 0 : void NotationSceneContext::onInit(const IApplication::RunMode& mode)
124 : {
125 0 : m_actionController->init();
126 :
127 0 : if (mode == IApplication::RunMode::GuiApp) {
128 0 : m_midiInputOutputController->init();
129 : }
130 0 : }
|