LCOV - code coverage report
Current view: top level - muse/framework/multiwindows - multiwindowsmodule.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 32 0
Test Date: 2026-11-05 04:07:02

            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              : 
      23              : #include "multiwindowsmodule.h"
      24              : 
      25              : #include "internal/multiwindowscommandscontroller.h"
      26              : #include "internal/multiwindowscommandsregister.h"
      27              : #include "internal/multiwindowscommandsstate.h"
      28              : 
      29              : #include "modularity/ioc.h"
      30              : #include "interactive/iinteractiveuriregister.h"
      31              : #include "rcommand/icommandsregister.h"
      32              : #include "rcommand/icommandsstate.h"
      33              : 
      34              : #include "muse_framework_config.h"
      35              : 
      36              : #ifdef MUSE_MODULE_MULTIWINDOWS_SINGLEPROC_MODE
      37              : #include "internal/singleprocess/singleprocessprovider.h"
      38              : #else
      39              : #include "internal/multiprocess/multiprocessprovider.h"
      40              : #endif
      41              : 
      42              : using namespace muse::mi;
      43              : using namespace muse::modularity;
      44              : 
      45              : static const std::string mname("multiwindows");
      46              : 
      47            0 : std::string MultiWindowsModule::moduleName() const
      48              : {
      49            0 :     return mname;
      50              : }
      51              : 
      52            0 : void MultiWindowsModule::registerExports()
      53              : {
      54              : #ifdef MUSE_MODULE_MULTIWINDOWS_SINGLEPROC_MODE
      55            0 :     m_windowsProvider = std::make_shared<SingleProcessProvider>();
      56              : #else
      57              :     m_windowsProvider = std::make_shared<MultiProcessProvider>();
      58              :     globalIoc()->registerExport<IMultiProcessProvider>(mname, m_windowsProvider);
      59              : #endif
      60              : 
      61            0 :     globalIoc()->registerExport<IMultiWindowsProvider>(mname, m_windowsProvider);
      62            0 : }
      63              : 
      64            0 : void MultiWindowsModule::resolveImports()
      65              : {
      66            0 :     auto ir = globalIoc()->resolve<muse::interactive::IInteractiveUriRegister>(mname);
      67            0 :     if (ir) {
      68            0 :         ir->registerQmlUri(Uri("muse://devtools/multiwindows/info"), "Muse.MultiWindows", "MultiInstancesDevDialog");
      69              :     }
      70              : 
      71            0 :     auto cr = globalIoc()->resolve<muse::rcommand::ICommandsRegister>(mname);
      72            0 :     if (cr) {
      73            0 :         cr->reg(std::make_shared<MultiWindowsCommandsRegister>());
      74              :     }
      75            0 : }
      76              : 
      77            0 : void MultiWindowsModule::onPreInit(const IApplication::RunMode& mode)
      78              : {
      79            0 :     if (mode != IApplication::RunMode::GuiApp) {
      80            0 :         return;
      81              :     }
      82              : 
      83            0 :     m_windowsProvider->initOnGlobal();
      84              : }
      85              : 
      86            0 : IContextSetup* MultiWindowsModule::newContext(const muse::modularity::ContextPtr& ctx) const
      87              : {
      88            0 :     return new MultiWindowsContext(ctx);
      89              : }
      90              : 
      91            0 : void MultiWindowsContext::registerExports()
      92              : {
      93            0 :     m_commandsController = std::make_shared<MultiWindowsCommandsController>(iocContext());
      94            0 : }
      95              : 
      96            0 : void MultiWindowsContext::resolveImports()
      97              : {
      98            0 :     auto cs = ioc()->resolve<muse::rcommand::ICommandsState>(mname);
      99            0 :     if (cs) {
     100            0 :         cs->reg(std::make_shared<MultiWindowsCommandsState>(iocContext()));
     101              :     }
     102            0 : }
     103              : 
     104            0 : void MultiWindowsContext::onInit(const IApplication::RunMode& mode)
     105              : {
     106            0 :     if (mode != IApplication::RunMode::GuiApp) {
     107            0 :         return;
     108              :     }
     109              : 
     110              : #ifndef MUSE_MODULE_MULTIWINDOWS_SINGLEPROC_MODE
     111              :     //! NOTE The MultiProcessProvider itself must be global.
     112              :     //! But it formally uses contextual services
     113              :     //! But in this case we always have one context
     114              :     //! We need to think about how to do this better.
     115              :     auto windowsProvider = modularity::globalIoc()->resolve<IMultiWindowsProvider>(mname);
     116              :     if (windowsProvider) {
     117              :         auto impl = std::dynamic_pointer_cast<MultiProcessProvider>(windowsProvider);
     118              :         if (impl) {
     119              :             DO_ASSERT(impl->iocContext() == nullptr); // should be just one context
     120              :             impl->setContext(iocContext());
     121              :         }
     122              :     }
     123              : #endif
     124              : 
     125            0 :     m_commandsController->init();
     126              : }
        

Generated by: LCOV version 2.0-1