Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions src/framework/update/internal/updatescenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,30 +216,27 @@ void UpdateScenario::downloadRelease()
processUpdateResult(rv.ret.code());
return;
}

closeAppAndStartInstallation(rv.val.toString());
askToCloseAndCompleteInstall(rv.val.toString());
}

void UpdateScenario::closeAppAndStartInstallation(const muse::io::path_t& installerPath)
void UpdateScenario::askToCloseAndCompleteInstall(const muse::io::path_t& installerPath)
{
std::string info = muse::trc("update", "MuseScore Studio needs to close to complete the installation. "
"If you have any unsaved changes, you will be prompted to save them before MuseScore Studio closes.");
int closeBtn = int(IInteractive::Button::CustomButton) + 1;
auto promise = interactive()->info("", info,
{ interactive()->buttonData(IInteractive::Button::Cancel),
IInteractive::ButtonData(closeBtn, muse::trc("update", "Close"), true) },
closeBtn);
promise.onResolve(this, [this, installerPath](const IInteractive::Result& res) {
if (res.isButton(IInteractive::Button::Cancel)) {
return;
}
const std::string info = muse::trc("update", "MuseScore Studio needs to close to complete the installation. "
"If you have any unsaved changes, you will be prompted to save them before MuseScore Studio closes.");
const int closeBtn = int(IInteractive::Button::CustomButton) + 1;
const IInteractive::Result res = interactive()->infoSync("", info,
{ interactive()->buttonData(IInteractive::Button::Cancel),
IInteractive::ButtonData(closeBtn, muse::trc("update", "Close"), true) },
closeBtn);
if (res.isButton(IInteractive::Button::Cancel)) {
return;
}

if (multiInstancesProvider()->instances().size() != 1) {
multiInstancesProvider()->quitAllAndRunInstallation(installerPath);
}
if (multiInstancesProvider()->instances().size() != 1) {
multiInstancesProvider()->quitAllAndRunInstallation(installerPath);
}

dispatcher()->dispatch("quit", ActionData::make_arg2<bool, std::string>(false, installerPath.toStdString()));
});
dispatcher()->dispatch("quit", ActionData::make_arg2<bool, std::string>(false, installerPath.toStdString()));
}

bool UpdateScenario::shouldIgnoreUpdate(const ReleaseInfo& info) const
Expand Down
2 changes: 1 addition & 1 deletion src/framework/update/internal/updatescenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class UpdateScenario : public IUpdateScenario, public Injectable, public async::
void showServerErrorMsg();

void downloadRelease();
void closeAppAndStartInstallation(const io::path_t& installerPath);
void askToCloseAndCompleteInstall(const io::path_t& installerPath);

bool shouldIgnoreUpdate(const ReleaseInfo& info) const;

Expand Down
Loading