LCOV - code coverage report
Current view: top level - src/notation - notationmodule.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 45 0
Test Date: 2026-11-05 04:07:02

            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 "notationmodule.h"
      23              : 
      24              : #include "modularity/ioc.h"
      25              : #include "project/inotationwritersregister.h"
      26              : #include "global/api/ifilesystemapirestriction.h"
      27              : 
      28              : #include "internal/notationconfiguration.h"
      29              : #include "internal/notationcontextconfiguration.h"
      30              : #include "internal/positionswriter.h"
      31              : #include "internal/mscnotationwriter.h"
      32              : #include "internal/instrumentsrepository.h"
      33              : #include "internal/engravingfontscontroller.h"
      34              : 
      35              : #include "diagnostics/idiagnosticspathsregister.h"
      36              : 
      37              : using namespace mu::notation;
      38              : using namespace muse;
      39              : using namespace muse::modularity;
      40              : 
      41              : static const std::string mname("notation");
      42              : 
      43            0 : std::string NotationModule::moduleName() const
      44              : {
      45            0 :     return mname;
      46              : }
      47              : 
      48            0 : void NotationModule::registerExports()
      49              : {
      50            0 :     m_configuration = std::make_shared<NotationConfiguration>();
      51            0 :     m_instrumentsRepository = std::make_shared<InstrumentsRepository>();
      52              : 
      53              : #ifdef MUE_BUILD_ENGRAVING_FONTSCONTROLLER
      54            0 :     m_engravingFontsController = std::make_shared<EngravingFontsController>();
      55              : #endif
      56              : 
      57            0 :     globalIoc()->registerExport<INotationConfiguration>(moduleName(), m_configuration);
      58            0 :     globalIoc()->registerExport<IInstrumentsRepository>(mname, m_instrumentsRepository);
      59            0 : }
      60              : 
      61            0 : void NotationModule::resolveImports()
      62              : {
      63            0 :     auto writers = globalIoc()->resolve<project::INotationWritersRegister>(mname);
      64            0 :     if (writers) {
      65            0 :         writers->reg({ "spos" }, std::make_shared<PositionsWriter>(PositionsWriter::ElementType::SEGMENT));
      66            0 :         writers->reg({ "mpos" }, std::make_shared<PositionsWriter>(PositionsWriter::ElementType::MEASURE));
      67            0 :         writers->reg({ "mscz" }, std::make_shared<MscNotationWriter>(engraving::MscIoMode::Zip));
      68            0 :         writers->reg({ "mscx" }, std::make_shared<MscNotationWriter>(engraving::MscIoMode::Dir));
      69              :     }
      70            0 : }
      71              : 
      72            0 : void NotationModule::registerApi()
      73              : {
      74            0 :     auto fsRestriction = globalIoc()->resolve<muse::api::IFileSystemApiRestriction>(moduleName());
      75            0 :     if (fsRestriction) {
      76            0 :         fsRestriction->addAllowedPathBase("userStylesPath", m_configuration->userStylesPath());
      77            0 :         m_configuration->userStylesPathChanged().onReceive(this, [fsRestriction](const muse::io::path_t& path) {
      78            0 :             fsRestriction->addAllowedPathBase("userStylesPath", path);
      79            0 :         });
      80              :     }
      81            0 : }
      82              : 
      83            0 : void NotationModule::onInit(const IApplication::RunMode&)
      84              : {
      85            0 :     m_configuration->init();
      86            0 :     m_instrumentsRepository->init();
      87              : 
      88              : #ifdef MUE_BUILD_ENGRAVING_FONTSCONTROLLER
      89            0 :     m_engravingFontsController->init();
      90              : #endif
      91              : 
      92            0 :     bool isVertical = m_configuration->canvasOrientation().val == muse::Orientation::Vertical;
      93            0 :     mu::engraving::MScore::setVerticalOrientation(isVertical);
      94              : 
      95            0 :     auto pr = globalIoc()->resolve<diagnostics::IDiagnosticsPathsRegister>(mname);
      96            0 :     if (pr) {
      97            0 :         pr->reg("instruments", m_configuration->instrumentsXmlPath());
      98            0 :         pr->reg("score orders", m_configuration->scoreOrdersXmlPath());
      99              : 
     100            0 :         muse::io::path_t userInstrumentsPath = m_configuration->userInstrumentsFolder();
     101            0 :         if (!userInstrumentsPath.empty()) {
     102            0 :             pr->reg("user instruments folder", userInstrumentsPath);
     103              :         }
     104            0 :     }
     105            0 : }
     106              : 
     107            0 : IContextSetup* NotationModule::newContext(const ContextPtr& ctx) const
     108              : {
     109            0 :     return new NotationContext(ctx);
     110              : }
     111              : 
     112            0 : void NotationContext::registerExports()
     113              : {
     114            0 :     ioc()->registerExport<INotationContextConfiguration>(mname, new NotationContextConfiguration(iocContext()));
     115            0 : }
        

Generated by: LCOV version 2.0-1