LCOV - code coverage report
Current view: top level - src/appshell - appshellmodule.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 60 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              : 
      23              : #include "appshellmodule.h"
      24              : 
      25              : #include <QQmlEngine>
      26              : #include <string>
      27              : 
      28              : #include "modularity/ioc.h"
      29              : 
      30              : #include "interactive/iinteractiveuriregister.h"
      31              : #include "rcommand/icommandsregister.h"
      32              : #include "rcommand/icommandsstate.h"
      33              : 
      34              : #include "internal/appshellcommandscontroller.h"
      35              : #include "internal/appshellconfiguration.h"
      36              : #include "internal/appshellstate.h"
      37              : #include "internal/startupscenario.h"
      38              : #include "internal/sessionsmanager.h"
      39              : #include "internal/appshellcommandsregister.h"
      40              : #include "internal/appshellcommandsstate.h"
      41              : #include "internal/shortcutresolver.h"
      42              : #include "internal/extensioncontextresolver.h"
      43              : 
      44              : #ifdef Q_OS_MAC
      45              : #include "internal/platform/macos/macosappmenumodelhook.h"
      46              : #else
      47              : #include "internal/iappmenumodelhook.h"
      48              : #endif
      49              : 
      50              : using namespace mu::appshell;
      51              : using namespace muse;
      52              : using namespace muse::modularity;
      53              : using namespace muse::dock;
      54              : using namespace muse::shortcuts;
      55              : using namespace muse::extensions;
      56              : 
      57              : static const std::string mname("appshell");
      58              : 
      59            0 : std::string AppShellModule::moduleName() const
      60              : {
      61            0 :     return mname;
      62              : }
      63              : 
      64            0 : void AppShellModule::registerExports()
      65              : {
      66            0 :     m_appShellConfiguration = std::make_shared<AppShellConfiguration>(globalCtx());
      67              : 
      68            0 :     globalIoc()->registerExport<IAppShellConfiguration>(moduleName(), m_appShellConfiguration);
      69            0 : }
      70              : 
      71            0 : void AppShellModule::resolveImports()
      72              : {
      73            0 :     auto ir = globalIoc()->resolve<muse::interactive::IInteractiveUriRegister>(mname);
      74            0 :     if (ir) {
      75            0 :         ir->registerPageUri(Uri("musescore://home"));
      76            0 :         ir->registerPageUri(Uri("musescore://notation"));
      77            0 :         ir->registerPageUri(Uri("musescore://notation/review"));
      78            0 :         ir->registerPageUri(Uri("musescore://sequencer"));
      79            0 :         ir->registerPageUri(Uri("musescore://publish"));
      80            0 :         ir->registerPageUri(Uri("musescore://devtools"));
      81              : 
      82            0 :         ir->registerQmlUri(Uri("musescore://about/musescore"), "MuseScore.AppShell", "AboutDialog");
      83            0 :         ir->registerQmlUri(Uri("musescore://about/musicxml"), "MuseScore.AppShell", "AboutMusicXMLDialog");
      84            0 :         ir->registerQmlUri(Uri("musescore://welcomedialog"), "MuseScore.AppShell", "WelcomeDialog");
      85            0 :         ir->registerQmlUri(Uri("musescore://firstLaunchSetup"), "MuseScore.AppShell", "FirstLaunchSetupDialog");
      86              :     }
      87              : 
      88            0 :     auto cr = globalIoc()->resolve<muse::rcommand::ICommandsRegister>(mname);
      89            0 :     if (cr) {
      90            0 :         cr->reg(std::make_shared<AppshellCommandsRegister>());
      91              :     }
      92            0 : }
      93              : 
      94            0 : void AppShellModule::onInit(const IApplication::RunMode&)
      95              : {
      96            0 :     m_appShellConfiguration->init();
      97            0 : }
      98              : 
      99            0 : void AppShellModule::onAllInited(const IApplication::RunMode&)
     100              : {
     101              :     //! NOTE: process QEvent::FileOpen as early as possible if it was postponed
     102              : #ifdef Q_OS_MACOS
     103              :     qApp->processEvents();
     104              : #endif
     105            0 : }
     106              : 
     107              : // Context
     108            0 : muse::modularity::IContextSetup* AppShellModule::newContext(const muse::modularity::ContextPtr& ctx) const
     109              : {
     110            0 :     return new AppShellContext(ctx);
     111              : }
     112              : 
     113            0 : void AppShellContext::registerExports()
     114              : {
     115            0 :     m_appshellState = std::make_shared<AppShellState>(iocContext());
     116            0 :     m_commandsController = std::make_shared<AppshellCommandsController>(iocContext());
     117            0 :     m_sessionsManager = std::make_shared<SessionsManager>(iocContext());
     118            0 :     m_extensionContextResolver = std::make_shared<ExtensionContextResolver>(iocContext());
     119              : 
     120            0 :     ioc()->registerExport<IAppShellState>(mname, m_appshellState);
     121            0 :     ioc()->registerExport<IStartupScenario>(mname, new StartupScenario(iocContext()));
     122            0 :     ioc()->registerExport<ISessionsManager>(mname, m_sessionsManager);
     123            0 :     ioc()->registerExport<IAppshellCommandsController>(mname, m_commandsController);
     124            0 :     ioc()->registerExport<IShortcutsResolver>(mname, new ShortcutResolver(iocContext()));
     125            0 :     ioc()->registerExport<IExtensionContextResolver>(mname, m_extensionContextResolver);
     126              : 
     127              : #ifdef Q_OS_MAC
     128              :     ioc()->registerExport<IAppMenuModelHook>(mname, std::make_shared<MacOSAppMenuModelHook>());
     129              : #else
     130            0 :     ioc()->registerExport<IAppMenuModelHook>(mname, std::make_shared<AppMenuModelHookStub>());
     131              : #endif
     132            0 : }
     133              : 
     134            0 : void AppShellContext::resolveImports()
     135              : {
     136            0 :     auto cs = ioc()->resolve<muse::rcommand::ICommandsState>(mname);
     137            0 :     if (cs) {
     138            0 :         cs->reg(std::make_shared<AppshellCommandsState>(iocContext()));
     139              :     }
     140            0 : }
     141              : 
     142            0 : void AppShellContext::onPreInit(const muse::IApplication::RunMode&)
     143              : {
     144            0 :     m_commandsController->preInit();
     145            0 : }
     146              : 
     147            0 : void AppShellContext::onInit(const muse::IApplication::RunMode& mode)
     148              : {
     149            0 :     m_sessionsManager->init();
     150              : 
     151            0 :     if (mode != IApplication::RunMode::GuiApp) {
     152            0 :         return;
     153              :     }
     154              : 
     155            0 :     m_commandsController->init();
     156            0 :     m_extensionContextResolver->init();
     157              : }
     158              : 
     159            0 : void AppShellContext::onDeinit()
     160              : {
     161            0 :     m_sessionsManager->deinit();
     162            0 : }
        

Generated by: LCOV version 2.0-1