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

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

Generated by: LCOV version 2.0-1