LCOV - code coverage report
Current view: top level - src/app/internal - guiapp.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 79 0
Test Date: 2026-11-19 04:14:36

            Line data    Source code
       1              : #include "guiapp.h"
       2              : 
       3              : #include <QCoreApplication>
       4              : 
       5              : #include "modularity/ioc.h"
       6              : #include "appshell/internal/istartupscenario.h"
       7              : 
       8              : #include "muse_framework_config.h"
       9              : #include "app_config.h"
      10              : 
      11              : #ifdef MUE_ENABLE_CONSOLEAPP
      12              : #include "commandlineparser.h"
      13              : #endif
      14              : 
      15              : #include "log.h"
      16              : 
      17              : using namespace muse;
      18              : using namespace mu;
      19              : using namespace mu::app;
      20              : using namespace mu::appshell;
      21              : 
      22            0 : MuseScoreGuiApp::MuseScoreGuiApp(const std::shared_ptr<MuseScoreCmdOptions>& options)
      23            0 :     : muse::ui::GuiApplication(options)
      24              : {
      25            0 : }
      26              : 
      27            0 : MuseScoreGuiApp::SplashConfig MuseScoreGuiApp::splashConfig(const std::shared_ptr<CmdOptions>& opt) const
      28              : {
      29            0 :     std::shared_ptr<MuseScoreCmdOptions> options = std::dynamic_pointer_cast<MuseScoreCmdOptions>(opt);
      30            0 :     IF_ASSERT_FAILED(options) {
      31            0 :         return SplashConfig();
      32              :     }
      33              : 
      34            0 :     SplashConfig cfg;
      35            0 :     cfg.type = SplashScreen::Default;
      36              : 
      37            0 :     if (options->startup.type.has_value()) {
      38            0 :         if (options->startup.type.value() == "start-with-new") {
      39            0 :             cfg.type = SplashScreen::ForNewInstance;
      40            0 :             cfg.forNewScore = true;
      41              :         }
      42            0 :     } else if (options->startup.scoreUrl.has_value()) {
      43            0 :         project::ProjectFile file { options->startup.scoreUrl.value() };
      44              : 
      45            0 :         if (options->startup.scoreDisplayNameOverride.has_value()) {
      46            0 :             file.displayNameOverride = options->startup.scoreDisplayNameOverride.value();
      47              :         }
      48              : 
      49            0 :         cfg.type = SplashScreen::ForNewInstance;
      50            0 :         cfg.forNewScore = false;
      51            0 :         if (file.hasDisplayName()) {
      52            0 :             cfg.openingFileName = file.displayName(true /* includingExtension */);
      53              :         }
      54            0 :     }
      55              : 
      56            0 :     return cfg;
      57            0 : }
      58              : 
      59            0 : void MuseScoreGuiApp::showSplash()
      60              : {
      61              : #ifdef MUE_ENABLE_SPLASHSCREEN
      62              :     SplashConfig cfg = splashConfig(m_appOptions);
      63              :     if (cfg.type == SplashScreen::Default) {
      64              :         m_splashScreen = new SplashScreen(SplashScreen::Default);
      65              :         m_splashScreen->show();
      66              :     }
      67              : #endif
      68            0 : }
      69              : 
      70            0 : void MuseScoreGuiApp::showContextSplash(const muse::modularity::ContextPtr& ctxId)
      71              : {
      72              :  #ifdef MUE_ENABLE_SPLASHSCREEN
      73              :     SplashConfig cfg = splashConfig(contextData(ctxId).options);
      74              :     if (cfg.type == SplashScreen::ForNewInstance) {
      75              :         m_splashScreen = new SplashScreen(cfg.type, cfg.forNewScore, cfg.openingFileName);
      76              :         m_splashScreen->show();
      77              :     }
      78              : #endif
      79            0 : }
      80              : 
      81            0 : std::shared_ptr<muse::CmdOptions> MuseScoreGuiApp::makeContextOptions(const muse::StringList& args) const
      82              : {
      83              : #ifdef MUE_ENABLE_CONSOLEAPP
      84            0 :     if (args.size() > 0) {
      85            0 :         std::vector<std::string> args_ = args.toStdStringList();
      86            0 :         args_.insert(args_.begin(), "dummy/path/to/app.exe");  // for compatibility
      87            0 :         const int argc = static_cast<int>(args_.size());
      88            0 :         std::vector<char*> argv(argc + 1, nullptr);
      89            0 :         for (int i = 0; i < argc; ++i) {
      90            0 :             argv[i] = args_[i].data();
      91              :         }
      92            0 :         argv[argc] = nullptr;
      93              : 
      94            0 :         CommandLineParser commandLineParser;
      95            0 :         commandLineParser.init();
      96            0 :         commandLineParser.parse(argc, argv.data());
      97            0 :         return commandLineParser.options();
      98            0 :     }
      99              : #else
     100              :     UNUSED(args);
     101              : #endif
     102              : 
     103            0 :     return m_appOptions;
     104              : }
     105              : 
     106            0 : QString MuseScoreGuiApp::mainWindowQmlPath(const QString& platform) const
     107              : {
     108            0 :     return QString(":/qt/qml/MuseScore/AppShell/platform/%1/Main.qml").arg(platform);
     109              : }
     110              : 
     111            0 : void MuseScoreGuiApp::doStartupScenario(const muse::modularity::ContextPtr& ctxId)
     112              : {
     113            0 :     auto startupScenario = muse::modularity::ioc(ctxId)->resolve<IStartupScenario>("app");
     114              : 
     115              :     //! NOTE Apply startup options
     116            0 :     const std::shared_ptr<MuseScoreCmdOptions> options = std::dynamic_pointer_cast<MuseScoreCmdOptions>(contextData(ctxId).options);
     117            0 :     IF_ASSERT_FAILED(options) {
     118            0 :         return;
     119              :     }
     120              : 
     121            0 :     startupScenario->setStartupType(options->startup.type);
     122              : 
     123            0 :     if (options->startup.scoreUrl.has_value()) {
     124            0 :         project::ProjectFile file = { options->startup.scoreUrl.value() };
     125              : 
     126            0 :         if (options->startup.scoreDisplayNameOverride.has_value()) {
     127            0 :             file.displayNameOverride = options->startup.scoreDisplayNameOverride.value();
     128              :         }
     129              : 
     130            0 :         startupScenario->setStartupScoreFile(file);
     131            0 :     }
     132              : 
     133              : #ifdef MUSE_MODULE_TESTFLOW
     134              :     //! NOTE Nobody answers dialogs during a test case run, they are skipped from the startup
     135              :     if (options->testflow.has_value()) {
     136              :         testflowCmdRunner()->prepare(ctxId, options->testflow.value());
     137              :     }
     138              : #endif
     139              : 
     140            0 :     startupScenario->runOnSplashScreen();
     141              : 
     142            0 :     QMetaObject::invokeMethod(qApp, [this, ctxId, startupScenario, options]() {
     143              : #ifdef MUE_ENABLE_SPLASHSCREEN
     144              :         if (m_splashScreen) {
     145              :             m_splashScreen->close();
     146              :             delete m_splashScreen;
     147              :             m_splashScreen = nullptr;
     148              :         }
     149              : #endif
     150              : 
     151            0 :         muse::async::Promise<muse::Ret> startup = startupScenario->runAfterSplashScreen();
     152              : 
     153              : #ifdef MUSE_MODULE_TESTFLOW
     154              :         //! NOTE Run the test case requested from the command line when the startup page is opened
     155              :         if (options->testflow.has_value()) {
     156              :             startup.onResolve(this, [this, ctxId](const muse::Ret&) {
     157              :                 testflowCmdRunner()->run(ctxId);
     158              :             });
     159              :         }
     160              : #endif
     161            0 :     }, Qt::QueuedConnection);
     162            0 : }
     163              : 
     164            0 : void MuseScoreGuiApp::applyCommandLineOptions(const std::shared_ptr<CmdOptions>& opt)
     165              : {
     166            0 :     GuiApplication::applyCommandLineOptions(opt);
     167              : 
     168            0 :     std::shared_ptr<MuseScoreCmdOptions> options = std::dynamic_pointer_cast<MuseScoreCmdOptions>(opt);
     169            0 :     IF_ASSERT_FAILED(options) {
     170            0 :         return;
     171              :     }
     172              : 
     173            0 :     if (options->network.offline) {
     174            0 :         networkConfiguration()->setOffline(options->network.offline.value());
     175              :     }
     176              : 
     177            0 :     if (options->audio.outputDisabled) {
     178            0 :         audioConfiguration()->setOutputDisabled(options->audio.outputDisabled.value());
     179              :     }
     180              : 
     181            0 :     if (options->app.revertToFactorySettings) {
     182            0 :         appshellConfiguration()->revertToFactorySettings(options->app.revertToFactorySettings.value());
     183              :     }
     184              : 
     185            0 :     if (guitarProConfiguration()) {
     186            0 :         if (options->guitarPro.experimental) {
     187            0 :             guitarProConfiguration()->setExperimental(true);
     188              :         }
     189              : 
     190            0 :         if (options->guitarPro.linkedTabStaffCreated) {
     191            0 :             guitarProConfiguration()->setLinkedTabStaffCreated(true);
     192              :         }
     193              :     }
     194            0 : }
        

Generated by: LCOV version 2.0-1