From 7a5d5879bf191279ea52a12dc61a6ce54dac335d Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Thu, 22 Jun 2023 22:44:28 +0200 Subject: [PATCH 1/2] Only show "Loading new file" splash screen when really doing that --- src/app/app.cpp | 18 +++++++++++++----- src/appshell/internal/istartupscenario.h | 2 ++ src/appshell/internal/startupscenario.cpp | 13 +++++++++++++ src/appshell/internal/startupscenario.h | 2 ++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/app/app.cpp b/src/app/app.cpp index 03fd38b9f7a1..cd35647abdef 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -166,13 +166,21 @@ int App::run(int argc, char** argv) #ifdef MUE_BUILD_APPSHELL_MODULE SplashScreen* splashScreen = nullptr; if (runMode == framework::IApplication::RunMode::GuiApp) { - if (multiInstancesProvider()->isMainInstance()) { - splashScreen = new SplashScreen(SplashScreen::Default); - } else { - QString fileName = startupScenario()->startupScoreFile().displayName(true /* includingExtension */); - splashScreen = new SplashScreen(SplashScreen::ForNewInstance, fileName); + SplashScreen::SplashScreenType type = SplashScreen::Default; + QString fileName; + + if (!multiInstancesProvider()->isMainInstance()) { + project::ProjectFile file = startupScenario()->startupScoreFile(); + + if (file.isValid()) { + type = SplashScreen::ForNewInstance; + fileName = file.displayName(true /* includingExtension */); + } else if (startupScenario()->isStartWithNewFileAsSecondaryInstance()) { + type = SplashScreen::ForNewInstance; + } } + splashScreen = new SplashScreen(type, fileName); splashScreen->show(); } #endif diff --git a/src/appshell/internal/istartupscenario.h b/src/appshell/internal/istartupscenario.h index 4d8741417dd4..6f67fab2868c 100644 --- a/src/appshell/internal/istartupscenario.h +++ b/src/appshell/internal/istartupscenario.h @@ -36,6 +36,8 @@ class IStartupScenario : MODULE_EXPORT_INTERFACE virtual void setStartupType(const std::optional& type) = 0; + virtual bool isStartWithNewFileAsSecondaryInstance() const = 0; + virtual const project::ProjectFile& startupScoreFile() const = 0; virtual void setStartupScoreFile(const std::optional& file) = 0; diff --git a/src/appshell/internal/startupscenario.cpp b/src/appshell/internal/startupscenario.cpp index 73d61395ab48..6f3e3c375841 100644 --- a/src/appshell/internal/startupscenario.cpp +++ b/src/appshell/internal/startupscenario.cpp @@ -60,6 +60,19 @@ void StartupScenario::setStartupType(const std::optional& type) m_startupTypeStr = type ? type.value() : ""; } +bool StartupScenario::isStartWithNewFileAsSecondaryInstance() const +{ + if (m_startupScoreFile.isValid()) { + return false; + } + + if (!m_startupTypeStr.empty()) { + return modeTypeTromString(m_startupTypeStr) == StartupModeType::StartWithNewScore; + } + + return false; +} + const mu::project::ProjectFile& StartupScenario::startupScoreFile() const { return m_startupScoreFile; diff --git a/src/appshell/internal/startupscenario.h b/src/appshell/internal/startupscenario.h index 0e5713363b46..35047c66149a 100644 --- a/src/appshell/internal/startupscenario.h +++ b/src/appshell/internal/startupscenario.h @@ -48,6 +48,8 @@ class StartupScenario : public IStartupScenario, public async::Asyncable void setStartupType(const std::optional& type) override; + bool isStartWithNewFileAsSecondaryInstance() const override; + const project::ProjectFile& startupScoreFile() const override; void setStartupScoreFile(const std::optional& file) override; From 400415f5a9786c35340906b0e815447870df3bb4 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Tue, 27 Jun 2023 19:58:17 +0200 Subject: [PATCH 2/2] Don't show splash screen at all when launching a second instance manually --- src/app/app.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/app/app.cpp b/src/app/app.cpp index cd35647abdef..22250697be8a 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -166,21 +166,19 @@ int App::run(int argc, char** argv) #ifdef MUE_BUILD_APPSHELL_MODULE SplashScreen* splashScreen = nullptr; if (runMode == framework::IApplication::RunMode::GuiApp) { - SplashScreen::SplashScreenType type = SplashScreen::Default; - QString fileName; - - if (!multiInstancesProvider()->isMainInstance()) { + if (multiInstancesProvider()->isMainInstance()) { + splashScreen = new SplashScreen(SplashScreen::Default); + } else { project::ProjectFile file = startupScenario()->startupScoreFile(); - if (file.isValid()) { - type = SplashScreen::ForNewInstance; - fileName = file.displayName(true /* includingExtension */); + splashScreen = new SplashScreen(SplashScreen::ForNewInstance, file.displayName(true /* includingExtension */)); } else if (startupScenario()->isStartWithNewFileAsSecondaryInstance()) { - type = SplashScreen::ForNewInstance; + splashScreen = new SplashScreen(SplashScreen::ForNewInstance); } } + } - splashScreen = new SplashScreen(type, fileName); + if (splashScreen) { splashScreen->show(); } #endif