mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-21 09:52:16 -07:00
Close the TabGames when closing the TabSupervisor
This ensures that we go through the same code path (in terms of Qt events) when closing the whole supervisor as when closing a single tab. Also, use the `close` event instead of the `hide` event to detect when we are closing a game. Fixes #5697
This commit is contained in:
parent
c99afe7956
commit
34a855f947
5 changed files with 44 additions and 27 deletions
|
|
@ -232,22 +232,36 @@ void TabSupervisor::refreshShortcuts()
|
|||
aTabLog->setShortcuts(shortcuts.getShortcut("Tabs/aTabLog"));
|
||||
}
|
||||
|
||||
bool TabSupervisor::closeRequest()
|
||||
void TabSupervisor::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (getGameCount()) {
|
||||
if (QMessageBox::question(this, tr("Are you sure?"),
|
||||
tr("There are still open games. Are you sure you want to quit?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
|
||||
return false;
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (AbstractTabDeckEditor *tab : deckEditorTabs) {
|
||||
if (!tab->confirmClose())
|
||||
return false;
|
||||
if (!tab->confirmClose()) {
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
// Close the game tabs in order to make sure they store their layout.
|
||||
QSet<int> gameTabsToRemove;
|
||||
for (auto [tabId, tab] : gameTabs.asKeyValueRange()) {
|
||||
if (tab->close()) {
|
||||
gameTabsToRemove.insert(tabId);
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto tabId : gameTabsToRemove) {
|
||||
gameTabs.remove(tabId);
|
||||
}
|
||||
}
|
||||
|
||||
AbstractClient *TabSupervisor::getClient() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue