Skip to content

Commit

Permalink
fix musescore#9966: added closing of the app window after closing the…
Browse files Browse the repository at this point in the history
… current project if there are other instances of the app
  • Loading branch information
RomanPudashkin committed Dec 12, 2021
1 parent 4a1219b commit 7736e49
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/project/internal/projectactionscontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ void ProjectActionsController::init()

dispatcher()->reg(this, "file-open", this, &ProjectActionsController::openProject);
dispatcher()->reg(this, "file-new", this, &ProjectActionsController::newProject);
dispatcher()->reg(this, "file-close", [this]() { closeOpenedProject(); });

dispatcher()->reg(this, "file-close", [this]() {
bool quitApp = multiInstancesProvider()->instances().size() > 1;
closeOpenedProject(quitApp);
});

dispatcher()->reg(this, "file-save", [this]() { saveProject(); });
dispatcher()->reg(this, "file-save-as", this, &ProjectActionsController::saveProjectAs);
Expand Down Expand Up @@ -260,7 +264,7 @@ void ProjectActionsController::newProject()
}
}

bool ProjectActionsController::closeOpenedProject()
bool ProjectActionsController::closeOpenedProject(bool quitApp)
{
INotationProjectPtr project = currentNotationProject();
if (!project) {
Expand All @@ -287,6 +291,10 @@ bool ProjectActionsController::closeOpenedProject()

if (result) {
globalContext()->setCurrentProject(nullptr);

if (quitApp) {
dispatcher()->dispatch("quit", actions::ActionData::make_arg1<bool>(false));
}
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion src/project/internal/projectactionscontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ProjectActionsController : public IProjectFilesController, public QObject,
void init();

Ret openProject(const io::path& projectPath) override;
bool closeOpenedProject() override;
bool closeOpenedProject(bool quitApp = false) override;
bool isProjectOpened(const io::path& scorePath) const override;
bool isAnyProjectOpened() const override;
bool saveProject(const io::path& path = io::path()) override;
Expand Down
2 changes: 1 addition & 1 deletion src/project/iprojectfilescontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class IProjectFilesController : MODULE_EXPORT_INTERFACE
virtual ~IProjectFilesController() = default;

virtual Ret openProject(const io::path& path) = 0;
virtual bool closeOpenedProject() = 0;
virtual bool closeOpenedProject(bool quitApp = false) = 0;
virtual bool isProjectOpened(const io::path& path) const = 0;
virtual bool isAnyProjectOpened() const = 0;
virtual bool saveProject(const io::path& path = io::path()) = 0;
Expand Down

0 comments on commit 7736e49

Please sign in to comment.