Skip to content

Commit

Permalink
Merge pull request musescore#18130 from cbjeukendrup/splash_new
Browse files Browse the repository at this point in the history
Only show "Loading new file" splash screen when really doing that
  • Loading branch information
RomanPudashkin committed Jul 5, 2023
2 parents 11b188e + 400415f commit eaf847f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/app.cpp
Expand Up @@ -169,10 +169,16 @@ int App::run(int argc, char** argv)
if (multiInstancesProvider()->isMainInstance()) {
splashScreen = new SplashScreen(SplashScreen::Default);
} else {
QString fileName = startupScenario()->startupScoreFile().displayName(true /* includingExtension */);
splashScreen = new SplashScreen(SplashScreen::ForNewInstance, fileName);
project::ProjectFile file = startupScenario()->startupScoreFile();
if (file.isValid()) {
splashScreen = new SplashScreen(SplashScreen::ForNewInstance, file.displayName(true /* includingExtension */));
} else if (startupScenario()->isStartWithNewFileAsSecondaryInstance()) {
splashScreen = new SplashScreen(SplashScreen::ForNewInstance);
}
}
}

if (splashScreen) {
splashScreen->show();
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/appshell/internal/istartupscenario.h
Expand Up @@ -36,6 +36,8 @@ class IStartupScenario : MODULE_EXPORT_INTERFACE

virtual void setStartupType(const std::optional<std::string>& type) = 0;

virtual bool isStartWithNewFileAsSecondaryInstance() const = 0;

virtual const project::ProjectFile& startupScoreFile() const = 0;
virtual void setStartupScoreFile(const std::optional<project::ProjectFile>& file) = 0;

Expand Down
13 changes: 13 additions & 0 deletions src/appshell/internal/startupscenario.cpp
Expand Up @@ -60,6 +60,19 @@ void StartupScenario::setStartupType(const std::optional<std::string>& 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;
Expand Down
2 changes: 2 additions & 0 deletions src/appshell/internal/startupscenario.h
Expand Up @@ -48,6 +48,8 @@ class StartupScenario : public IStartupScenario, public async::Asyncable

void setStartupType(const std::optional<std::string>& type) override;

bool isStartWithNewFileAsSecondaryInstance() const override;

const project::ProjectFile& startupScoreFile() const override;
void setStartupScoreFile(const std::optional<project::ProjectFile>& file) override;

Expand Down

0 comments on commit eaf847f

Please sign in to comment.