1919#include " muse_framework_config.h"
2020#include " app_config.h"
2121
22- #ifdef MUE_ENABLE_SPLASHSCREEN
23- #include " appshell/widgets/splashscreen/splashscreen.h"
24- #else
25- namespace mu ::appshell {
26- class SplashScreen
27- {
28- public:
29- void close () {}
30- };
31- }
32- #endif
33-
3422#ifdef QT_CONCURRENT_SUPPORTED
3523#include < QThreadPool>
3624#endif
@@ -55,6 +43,45 @@ void GuiApp::addModule(muse::modularity::IModuleSetup* module)
5543 m_modules.push_back (module );
5644}
5745
46+ GuiApp::SplashConfig GuiApp::splashConfig (const CmdOptions& options) const
47+ {
48+ SplashConfig cfg;
49+ cfg.type = SplashScreen::Default;
50+
51+ if (options.startup .type .has_value ()) {
52+ if (options.startup .type .value () == " start-with-new" ) {
53+ cfg.type = SplashScreen::ForNewInstance;
54+ cfg.forNewScore = true ;
55+ } else if (options.startup .scoreUrl .has_value ()) {
56+ project::ProjectFile file { options.startup .scoreUrl .value () };
57+
58+ if (options.startup .scoreDisplayNameOverride .has_value ()) {
59+ file.displayNameOverride = options.startup .scoreDisplayNameOverride .value ();
60+ }
61+
62+ cfg.type = SplashScreen::ForNewInstance;
63+ cfg.forNewScore = false ;
64+ if (file.hasDisplayName ()) {
65+ cfg.openingFileName = file.displayName (true /* includingExtension */ );
66+ }
67+ } else {
68+ cfg.type = SplashScreen::Default;
69+ }
70+ }
71+
72+ return cfg;
73+ }
74+
75+ void GuiApp::showSplash ()
76+ {
77+ #ifdef MUE_ENABLE_SPLASHSCREEN
78+ if (splashConfig (m_options).type == SplashScreen::Default) {
79+ m_splashScreen = new SplashScreen (SplashScreen::Default);
80+ m_splashScreen->show ();
81+ }
82+ #endif
83+ }
84+
5885void GuiApp::setup ()
5986{
6087 const CmdOptions& options = m_options;
@@ -105,38 +132,6 @@ void GuiApp::setup()
105132 m->onPreInit (runMode);
106133 }
107134
108- // Process all pending events (see IpcSocket::onReadyRead())
109- // so that we can use isFirstWindow() as early as possible
110- muse::async::processMessages ();
111-
112- // ! FIXME
113- // ! The launch scenario is contextual, but there is no context here.
114- #undef MUE_ENABLE_SPLASHSCREEN
115-
116- #ifdef MUE_ENABLE_SPLASHSCREEN
117- if (multiwindowsProvider ()->isFirstWindow ()) {
118- m_splashScreen = new SplashScreen (SplashScreen::Default);
119- } else {
120- auto startupScenario = muse::modularity::ioc (iocContext ())->resolve <IStartupScenario>(" app" );
121- const project::ProjectFile& file = startupScenario->startupScoreFile ();
122- if (file.isValid ()) {
123- if (file.hasDisplayName ()) {
124- m_splashScreen = new SplashScreen (SplashScreen::ForNewInstance, false , file.displayName (true /* includingExtension */ ));
125- } else {
126- m_splashScreen = new SplashScreen (SplashScreen::ForNewInstance, false );
127- }
128- } else if (startupScenario->isStartWithNewFileAsSecondaryInstance ()) {
129- m_splashScreen = new SplashScreen (SplashScreen::ForNewInstance, true );
130- } else {
131- m_splashScreen = new SplashScreen (SplashScreen::Default);
132- }
133- }
134-
135- if (m_splashScreen) {
136- m_splashScreen->show ();
137- }
138- #endif
139-
140135 // ====================================================
141136 // Setup modules: onInit
142137 // ====================================================
@@ -177,11 +172,7 @@ void GuiApp::setup()
177172 m_delayedInitTimer.start ();
178173
179174 // ====================================================
180- // Run
181- // ====================================================
182-
183- // ====================================================
184- // Setup Qml Engine
175+ // Setup Graphics Api check
185176 // ====================================================
186177 // ! Needs to be set because we use transparent windows for PopupView.
187178 // ! Needs to be called before any QQuickWindows are shown.
@@ -266,6 +257,17 @@ size_t GuiApp::contextCount() const
266257 return m_contexts.size ();
267258}
268259
260+ void GuiApp::showContextSplash ()
261+ {
262+ #ifdef MUE_ENABLE_SPLASHSCREEN
263+ SplashConfig cfg = splashConfig (m_options);
264+ if (cfg.type == SplashScreen::ForNewInstance) {
265+ m_splashScreen = new SplashScreen (cfg.type , cfg.forNewScore , cfg.openingFileName );
266+ m_splashScreen->show ();
267+ }
268+ #endif
269+ }
270+
269271muse::modularity::ContextPtr GuiApp::setupNewContext (const StringList& args)
270272{
271273#ifndef MUSE_MODULE_MULTIWINDOWS_SINGLEPROC_MODE
@@ -397,11 +399,13 @@ muse::modularity::ContextPtr GuiApp::setupNewContext(const StringList& args)
397399 startupScenario->runOnSplashScreen ();
398400
399401 QMetaObject::invokeMethod (qApp, [this , ctxId, obj, startupScenario]() {
402+ #ifdef MUE_ENABLE_SPLASHSCREEN
400403 if (m_splashScreen) {
401404 m_splashScreen->close ();
402405 delete m_splashScreen;
403406 m_splashScreen = nullptr ;
404407 }
408+ #endif
405409
406410 // The main window must be shown at this point so KDDockWidgets can read its size correctly
407411 // and scale all sizes properly. https://github.com/musescore/MuseScore/issues/21148
0 commit comments