LCOV - code coverage report
Current view: top level - src/project - projectmodule.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 88 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 "projectmodule.h"
      23              : 
      24              : #include "modularity/ioc.h"
      25              : #include "global/api/ifilesystemapirestriction.h"
      26              : 
      27              : #include "internal/projectcreator.h"
      28              : #include "internal/projectautosaver.h"
      29              : #include "internal/projectactionscontroller.h"
      30              : #include "internal/engravingpluginapihelper.h"
      31              : #include "internal/projectconfiguration.h"
      32              : #include "internal/openprojectscenario.h"
      33              : #include "internal/saveprojectscenario.h"
      34              : #include "internal/closeprojectscenario.h"
      35              : #include "internal/exportprojectscenario.h"
      36              : #include "internal/mscmetareader.h"
      37              : #include "internal/templatesrepository.h"
      38              : #include "internal/projectmigrator.h"
      39              : #include "internal/projectautosaver.h"
      40              : #include "internal/convertfiletoscoreservice.h"
      41              : #include "internal/convertfiletoscorescenario.h"
      42              : #include "internal/deletecloudscorescenario.h"
      43              : #include "internal/projectsession.h"
      44              : #include "internal/notationreadersregister.h"
      45              : #include "internal/notationwritersregister.h"
      46              : #include "internal/projectcommandsregister.h"
      47              : #include "internal/projectcommandsstate.h"
      48              : 
      49              : #ifdef Q_OS_MAC
      50              : #include "internal/platform/macos/macosrecentfilescontroller.h"
      51              : #elif defined (Q_OS_WIN)
      52              : #include "internal/platform/windows/windowsrecentfilescontroller.h"
      53              : #else
      54              : #include "internal/recentfilescontroller.h"
      55              : #endif
      56              : 
      57              : #include "rcommand/icommandsstate.h"
      58              : #include "interactive/iinteractiveuriregister.h"
      59              : 
      60              : using namespace mu::project;
      61              : using namespace muse;
      62              : using namespace muse::modularity;
      63              : 
      64              : static const std::string mname("project");
      65              : 
      66            0 : std::string ProjectModule::moduleName() const
      67              : {
      68            0 :     return mname;
      69              : }
      70              : 
      71            0 : void ProjectModule::registerExports()
      72              : {
      73            0 :     m_configuration = std::make_shared<ProjectConfiguration>(globalCtx());
      74              : 
      75            0 :     globalIoc()->registerExport<IProjectConfiguration>(mname, m_configuration);
      76            0 :     globalIoc()->registerExport<IProjectCreator>(mname, new ProjectCreator());
      77            0 :     globalIoc()->registerExport<IMscMetaReader>(mname, new MscMetaReader());
      78              : 
      79            0 :     globalIoc()->registerExport<INotationReadersRegister>(mname, new NotationReadersRegister());
      80            0 :     globalIoc()->registerExport<INotationWritersRegister>(mname, new NotationWritersRegister());
      81            0 : }
      82              : 
      83            0 : void ProjectModule::resolveImports()
      84              : {
      85            0 :     auto ir = globalIoc()->resolve<muse::interactive::IInteractiveUriRegister>(mname);
      86            0 :     if (ir) {
      87            0 :         ir->registerQmlUri(Uri("musescore://project/newscore"), "MuseScore.Project", "NewScoreDialog");
      88            0 :         ir->registerQmlUri(Uri("musescore://project/asksavelocationtype"), "MuseScore.Project", "AskSaveLocationTypeDialog");
      89            0 :         ir->registerQmlUri(Uri("musescore://project/savetocloud"), "MuseScore.Project", "SaveToCloudDialog");
      90            0 :         ir->registerQmlUri(Uri("musescore://project/alsoshareaudiocom"), "MuseScore.Project", "AlsoShareAudioComDialog");
      91            0 :         ir->registerQmlUri(Uri("musescore://project/export"), "MuseScore.Project", "ExportDialog");
      92            0 :         ir->registerQmlUri(Uri("musescore://project/migration"), "MuseScore.Project", "MigrationDialog");
      93            0 :         ir->registerQmlUri(Uri("musescore://project/properties"), "MuseScore.Project", "ProjectPropertiesDialog");
      94            0 :         ir->registerQmlUri(Uri("musescore://project/upload/progress"), "MuseScore.Project", "UploadProgressDialog");
      95            0 :         ir->registerQmlUri(Uri("musescore://project/upload/success"), "MuseScore.Project", "ProjectUploadedDialog");
      96            0 :         ir->registerQmlUri(Uri("musescore://project/audiogenerationsettings"), "MuseScore.Project", "AudioGenerationSettingsDialog");
      97            0 :         ir->registerQmlUri(Uri("musescore://project/convert/selectfiles"), "MuseScore.Project", "ConvertFileToScoreDialog");
      98            0 :         ir->registerQmlUri(Uri("musescore://project/convert/processing"), "MuseScore.Project", "ConvertFileProcessingDialog");
      99            0 :         ir->registerQmlUri(Uri("musescore://project/deletecloudscore"), "MuseScore.Project", "DeleteCloudScoreDialog");
     100              :     }
     101              : 
     102            0 :     auto cr = globalIoc()->resolve<muse::rcommand::ICommandsRegister>(mname);
     103            0 :     if (cr) {
     104            0 :         cr->reg(std::make_shared<ProjectCommandsRegister>());
     105              :     }
     106            0 : }
     107              : 
     108            0 : void ProjectModule::registerApi()
     109              : {
     110            0 :     auto fsRestriction = globalIoc()->resolve<muse::api::IFileSystemApiRestriction>(moduleName());
     111            0 :     if (fsRestriction) {
     112            0 :         fsRestriction->addAllowedPathBase("userProjectsPath", m_configuration->userProjectsPath());
     113            0 :         fsRestriction->addAllowedPathBase("userTemplatesPath", m_configuration->userTemplatesPath());
     114            0 :         m_configuration->userProjectsPathChanged().onReceive(this, [fsRestriction](const muse::io::path_t& path) {
     115            0 :             fsRestriction->addAllowedPathBase("userProjectsPath", path);
     116            0 :         });
     117            0 :         m_configuration->userTemplatesPathChanged().onReceive(this, [fsRestriction](const muse::io::path_t& path) {
     118            0 :             fsRestriction->addAllowedPathBase("userTemplatesPath", path);
     119            0 :         });
     120              :     }
     121            0 : }
     122              : 
     123            0 : void ProjectModule::onInit(const IApplication::RunMode& mode)
     124              : {
     125            0 :     if (IApplication::RunMode::GuiApp != mode) {
     126            0 :         return;
     127              :     }
     128              : 
     129            0 :     m_configuration->init();
     130              : }
     131              : 
     132            0 : IContextSetup* ProjectModule::newContext(const muse::modularity::ContextPtr& ctx) const
     133              : {
     134            0 :     return new ProjectContext(ctx);
     135              : }
     136              : 
     137            0 : void ProjectContext::registerExports()
     138              : {
     139            0 :     m_actionsController = std::make_shared<ProjectActionsController>(iocContext());
     140            0 :     m_projectAutoSaver = std::make_shared<ProjectAutoSaver>(iocContext());
     141            0 :     m_engravingPluginAPIHelper = std::make_shared<EngravingPluginAPIHelper>(iocContext());
     142            0 :     m_convertFileToScoreService = std::make_shared<ConvertFileToScoreService>(iocContext());
     143            0 :     m_convertFileToScoreScenario = std::make_shared<ConvertFileToScoreScenario>(iocContext());
     144              : 
     145              : #ifdef Q_OS_MAC
     146              :     m_recentFilesController = std::make_shared<MacOSRecentFilesController>();
     147              : #elif defined(Q_OS_WIN)
     148              :     m_recentFilesController = std::make_shared<WindowsRecentFilesController>();
     149              : #else
     150            0 :     m_recentFilesController = std::make_shared<RecentFilesController>();
     151              : #endif
     152              : 
     153            0 :     ioc()->registerExport<IProjectCommandsController>(mname, m_actionsController);
     154            0 :     ioc()->registerExport<mi::IProjectProvider>(mname, m_actionsController);
     155            0 :     ioc()->registerExport<IOpenProjectScenario>(mname, new OpenProjectScenario(iocContext()));
     156            0 :     ioc()->registerExport<ISaveProjectScenario>(mname, new SaveProjectScenario(iocContext()));
     157            0 :     ioc()->registerExport<ICloseProjectScenario>(mname, new CloseProjectScenario(iocContext()));
     158            0 :     ioc()->registerExport<IExportProjectScenario>(mname, new ExportProjectScenario(iocContext()));
     159            0 :     ioc()->registerExport<IRecentFilesController>(mname, m_recentFilesController);
     160            0 :     ioc()->registerExport<ITemplatesRepository>(mname, new TemplatesRepository());
     161            0 :     ioc()->registerExport<IProjectMigrator>(mname, new ProjectMigrator(iocContext()));
     162            0 :     ioc()->registerExport<IProjectAutoSaver>(mname, m_projectAutoSaver);
     163            0 :     ioc()->registerExport<mu::engraving::IEngravingPluginAPIHelper>(mname, m_engravingPluginAPIHelper);
     164            0 :     ioc()->registerExport<IConvertFileToScoreService>(mname, m_convertFileToScoreService);
     165            0 :     ioc()->registerExport<IConvertFileToScoreScenario>(mname, m_convertFileToScoreScenario);
     166            0 :     ioc()->registerExport<IDeleteCloudScoreScenario>(mname, new DeleteCloudScoreScenario(iocContext()));
     167            0 :     ioc()->registerExport<IProjectSession>(mname, new ProjectSession());
     168            0 : }
     169              : 
     170            0 : void ProjectContext::resolveImports()
     171              : {
     172            0 :     auto cs = ioc()->resolve<muse::rcommand::ICommandsState>(mname);
     173            0 :     if (cs) {
     174            0 :         cs->reg(std::make_shared<ProjectCommandsState>(iocContext()));
     175              :     }
     176            0 : }
     177              : 
     178            0 : void ProjectContext::onInit(const IApplication::RunMode& mode)
     179              : {
     180            0 :     if (IApplication::RunMode::GuiApp != mode) {
     181            0 :         return;
     182              :     }
     183              : 
     184            0 :     m_actionsController->init();
     185            0 :     m_recentFilesController->init();
     186            0 :     m_projectAutoSaver->init();
     187            0 :     m_convertFileToScoreService->init();
     188            0 :     m_convertFileToScoreScenario->init();
     189              : }
     190              : 
     191            0 : void ProjectContext::onAllInited(const IApplication::RunMode& mode)
     192              : {
     193            0 :     if (IApplication::RunMode::GuiApp != mode) {
     194            0 :         return;
     195              :     }
     196              : 
     197              :     //! NOTE: resuming polling can show dialogs (errors, review prompts), so it must wait
     198              :     //! until the main window is up rather than running during onInit()
     199            0 :     m_convertFileToScoreService->resumeConvert();
     200              : }
        

Generated by: LCOV version 2.0-1