Skip to content

Commit

Permalink
Only show "Loading new file" splash screen when really doing that
Browse files Browse the repository at this point in the history
  • Loading branch information
cbjeukendrup committed Jul 5, 2023
1 parent 174b7f7 commit 7a5d587
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/appshell/internal/istartupscenario.h
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 7a5d587

Please sign in to comment.