forked from musescore/MuseScore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontextmodule.cpp
More file actions
81 lines (68 loc) · 2.45 KB
/
Copy pathcontextmodule.cpp
File metadata and controls
81 lines (68 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore Limited and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "contextmodule.h"
#include "modularity/ioc.h"
#include "internal/globalcontext.h"
#include "internal/uicontextresolver.h"
#include "internal/extensioncontextresolver.h"
#include "shortcutcontext.h"
#include "muse_framework_config.h"
#ifdef MUSE_MODULE_SHORTCUTS_V2
#include "internal/shortcutresolver.h"
#endif
using namespace mu::context;
using namespace muse::modularity;
using namespace muse::shortcuts;
static const std::string mname("context");
std::string ContextModule::moduleName() const
{
return mname;
}
IContextSetup* ContextModule::newContext(const muse::modularity::ContextPtr& ctx) const
{
return new ContextModuleContext(ctx);
}
void ContextModuleContext::registerExports()
{
m_globalContext = std::make_shared<GlobalContext>();
m_uicontextResolver = std::make_shared<UiContextResolver>(iocContext());
m_extensionContextResolver = std::make_shared<ExtensionContextResolver>(iocContext());
ioc()->registerExport<IGlobalContext>(mname, m_globalContext);
ioc()->registerExport<IUiContextResolver>(mname, m_uicontextResolver);
ioc()->registerExport<muse::extensions::IExtensionContextResolver>(mname, m_extensionContextResolver);
ioc()->registerExport<IShortcutContextPriority>(mname, new ShortcutContextPriority());
#ifdef MUSE_MODULE_SHORTCUTS_V2
ioc()->registerExport<IShortcutsResolver>(mname, new ShortcutResolver(iocContext()));
#endif
}
void ContextModuleContext::onInit(const muse::IApplication::RunMode& mode)
{
if (mode != muse::IApplication::RunMode::GuiApp) {
return;
}
m_uicontextResolver->init();
m_extensionContextResolver->init();
}
void ContextModuleContext::onDeinit()
{
m_globalContext->setCurrentProject(nullptr);
}