Merge pull request #15895 from cbjeukendrup/ask_on_quit

Fix asking about saving score when receiving Quit event
This commit is contained in:
Casper Jeukendrup 2023-01-16 13:42:33 +01:00 committed by GitHub
commit fa229d3f61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 23 deletions

View file

@ -127,9 +127,10 @@ void ApplicationActionController::onDropEvent(QDropEvent* event)
bool ApplicationActionController::eventFilter(QObject* watched, QEvent* event)
{
if (event->type() == QEvent::Close && watched == mainWindow()->qWindow()) {
quit(false);
event->ignore();
if ((event->type() == QEvent::Close && watched == mainWindow()->qWindow())
|| event->type() == QEvent::Quit) {
bool accepted = quit(false);
event->setAccepted(accepted);
return true;
}
@ -159,27 +160,30 @@ mu::ValCh<bool> ApplicationActionController::isFullScreen() const
return result;
}
void ApplicationActionController::quit(bool isAllInstances, const io::path_t& installerPath)
bool ApplicationActionController::quit(bool isAllInstances, const io::path_t& installerPath)
{
if (projectFilesController()->closeOpenedProject()) {
if (isAllInstances) {
multiInstancesProvider()->quitForAll();
}
if (multiInstancesProvider()->instances().size() == 1 && !installerPath.empty()) {
#if defined(Q_OS_LINUX)
interactive()->revealInFileBrowser(installerPath);
#else
interactive()->openUrl(QUrl::fromLocalFile(installerPath.toQString()));
#endif
}
if (multiInstancesProvider()->instances().size() > 1) {
multiInstancesProvider()->notifyAboutInstanceWasQuited();
}
QCoreApplication::quit();
if (!projectFilesController()->closeOpenedProject()) {
return false;
}
if (isAllInstances) {
multiInstancesProvider()->quitForAll();
}
if (multiInstancesProvider()->instances().size() == 1 && !installerPath.empty()) {
#if defined(Q_OS_LINUX)
interactive()->revealInFileBrowser(installerPath);
#else
interactive()->openUrl(QUrl::fromLocalFile(installerPath.toQString()));
#endif
}
if (multiInstancesProvider()->instances().size() > 1) {
multiInstancesProvider()->notifyAboutInstanceWasQuited();
}
QCoreApplication::quit();
return true;
}
void ApplicationActionController::restart()

View file

@ -72,7 +72,7 @@ private:
void setupConnections();
void quit(bool isAllInstances, const io::path_t& installerPath = io::path_t());
bool quit(bool isAllInstances, const io::path_t& installerPath = io::path_t());
void restart();
void toggleFullScreen();