mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Close the TabGames when closing the TabSupervisor (#5735)
* Close the `TabGame`s 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 * Compat with old Qt versions * Old Qt, reloaded * Review: use hideEvent and call super
This commit is contained in:
parent
57a8960841
commit
37382dea44
5 changed files with 47 additions and 27 deletions
|
|
@ -119,7 +119,6 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
|||
refreshShortcuts();
|
||||
messageLog->logReplayStarted(gameInfo.game_id());
|
||||
|
||||
this->installEventFilter(this);
|
||||
QTimer::singleShot(0, this, SLOT(loadLayout()));
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +163,6 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
|
|||
for (int i = gameInfo.game_types_size() - 1; i >= 0; i--)
|
||||
gameTypes.append(roomGameTypes.find(gameInfo.game_types(i)).value());
|
||||
|
||||
this->installEventFilter(this);
|
||||
QTimer::singleShot(0, this, SLOT(loadLayout()));
|
||||
}
|
||||
|
||||
|
|
@ -1753,6 +1751,27 @@ void TabGame::createMessageDock(bool bReplay)
|
|||
connect(messageLayoutDock, SIGNAL(topLevelChanged(bool)), this, SLOT(dockTopLevelChanged(bool)));
|
||||
}
|
||||
|
||||
void TabGame::hideEvent(QHideEvent *event)
|
||||
{
|
||||
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
||||
if (replay) {
|
||||
layouts.setReplayPlayAreaState(saveState());
|
||||
layouts.setReplayPlayAreaGeometry(saveGeometry());
|
||||
layouts.setReplayCardInfoSize(cardInfoDock->size());
|
||||
layouts.setReplayMessageLayoutSize(messageLayoutDock->size());
|
||||
layouts.setReplayPlayerListSize(playerListDock->size());
|
||||
layouts.setReplayReplaySize(replayDock->size());
|
||||
} else {
|
||||
layouts.setGamePlayAreaState(saveState());
|
||||
layouts.setGamePlayAreaGeometry(saveGeometry());
|
||||
layouts.setGameCardInfoSize(cardInfoDock->size());
|
||||
layouts.setGameMessageLayoutSize(messageLayoutDock->size());
|
||||
layouts.setGamePlayerListSize(playerListDock->size());
|
||||
}
|
||||
|
||||
Tab::hideEvent(event);
|
||||
}
|
||||
|
||||
// Method uses to sync docks state with menu items state
|
||||
bool TabGame::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
|
|
@ -1772,23 +1791,6 @@ bool TabGame::eventFilter(QObject *o, QEvent *e)
|
|||
}
|
||||
}
|
||||
|
||||
if (o == this && e->type() == QEvent::Hide) {
|
||||
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
||||
if (replay) {
|
||||
layouts.setReplayPlayAreaState(saveState());
|
||||
layouts.setReplayPlayAreaGeometry(saveGeometry());
|
||||
layouts.setReplayCardInfoSize(cardInfoDock->size());
|
||||
layouts.setReplayMessageLayoutSize(messageLayoutDock->size());
|
||||
layouts.setReplayPlayerListSize(playerListDock->size());
|
||||
layouts.setReplayReplaySize(replayDock->size());
|
||||
} else {
|
||||
layouts.setGamePlayAreaState(saveState());
|
||||
layouts.setGamePlayAreaGeometry(saveGeometry());
|
||||
layouts.setGameCardInfoSize(cardInfoDock->size());
|
||||
layouts.setGameMessageLayoutSize(messageLayoutDock->size());
|
||||
layouts.setGamePlayerListSize(playerListDock->size());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue