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 : #include "drawmodule.h"
23 :
24 : #include "global/modularity/ioc.h"
25 :
26 : #ifndef DRAW_NO_INTERNAL
27 : #ifndef NO_QT_SUPPORT
28 : #include "internal/qfontprovider.h"
29 : #include "internal/qimageprovider.h"
30 : #else
31 : #include "internal/fontprovider.h"
32 : #include "internal/fontsengine.h"
33 : #endif
34 :
35 : #include "internal/fontsdatabase.h"
36 : #endif
37 :
38 : #include "muse_framework_config.h"
39 :
40 : using namespace muse::draw;
41 : using namespace muse::modularity;
42 :
43 48 : std::string DrawModule::moduleName() const
44 : {
45 96 : return "draw";
46 : }
47 :
48 16 : void DrawModule::registerExports()
49 : {
50 : #ifndef DRAW_NO_INTERNAL
51 :
52 : #ifndef NO_QT_SUPPORT
53 16 : globalIoc()->registerExport<draw::IImageProvider>(moduleName(), std::make_shared<QImageProvider>());
54 16 : globalIoc()->registerExport<draw::IFontProvider>(moduleName(), std::make_shared<QFontProvider>());
55 : #else
56 : m_fontsEngine = std::make_shared<FontsEngine>(globalCtx());
57 : globalIoc()->registerExport<draw::IFontProvider>(moduleName(), std::make_shared<FontProvider>(globalCtx()));
58 : globalIoc()->registerExport<draw::IFontsEngine>(moduleName(), m_fontsEngine);
59 : #endif
60 16 : globalIoc()->registerExport<draw::IFontsDatabase>(moduleName(), std::make_shared<FontsDatabase>());
61 :
62 : #endif // DRAW_NO_INTERNAL
63 16 : }
64 :
65 16 : void DrawModule::onInit(const IApplication::RunMode&)
66 : {
67 : #if !defined(DRAW_NO_INTERNAL) && defined(NO_QT_SUPPORT)
68 : m_fontsEngine->init();
69 : #endif // DRAW_NO_INTERNAL
70 16 : }
|