From f5674a392085c3dc688a8a2d639a4a0628a6340a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Basile=20Cl=C3=A9ment?= Date: Sun, 16 Mar 2025 12:09:17 +0100 Subject: [PATCH] Review: use hideEvent and call super --- cockatrice/src/client/tabs/tab_game.cpp | 6 +++--- cockatrice/src/client/tabs/tab_game.h | 2 +- cockatrice/src/client/tabs/tab_supervisor.cpp | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_game.cpp b/cockatrice/src/client/tabs/tab_game.cpp index acb637b11..1b2dc0327 100644 --- a/cockatrice/src/client/tabs/tab_game.cpp +++ b/cockatrice/src/client/tabs/tab_game.cpp @@ -1751,10 +1751,8 @@ void TabGame::createMessageDock(bool bReplay) connect(messageLayoutDock, SIGNAL(topLevelChanged(bool)), this, SLOT(dockTopLevelChanged(bool))); } -void TabGame::closeEvent(QCloseEvent *event) +void TabGame::hideEvent(QHideEvent *event) { - Q_UNUSED(event); - LayoutsSettings &layouts = SettingsCache::instance().layouts(); if (replay) { layouts.setReplayPlayAreaState(saveState()); @@ -1770,6 +1768,8 @@ void TabGame::closeEvent(QCloseEvent *event) layouts.setGameMessageLayoutSize(messageLayoutDock->size()); layouts.setGamePlayerListSize(playerListDock->size()); } + + Tab::hideEvent(event); } // Method uses to sync docks state with menu items state diff --git a/cockatrice/src/client/tabs/tab_game.h b/cockatrice/src/client/tabs/tab_game.h index eaefac4c2..096998728 100644 --- a/cockatrice/src/client/tabs/tab_game.h +++ b/cockatrice/src/client/tabs/tab_game.h @@ -208,7 +208,7 @@ private slots: void actResetLayout(); void freeDocksSize(); - void closeEvent(QCloseEvent *event) override; + void hideEvent(QHideEvent *event) override; bool eventFilter(QObject *o, QEvent *e) override; void dockVisibleTriggered(); void dockFloatingTriggered(); diff --git a/cockatrice/src/client/tabs/tab_supervisor.cpp b/cockatrice/src/client/tabs/tab_supervisor.cpp index d6278fbec..8ba5d791a 100644 --- a/cockatrice/src/client/tabs/tab_supervisor.cpp +++ b/cockatrice/src/client/tabs/tab_supervisor.cpp @@ -234,6 +234,9 @@ void TabSupervisor::refreshShortcuts() void TabSupervisor::closeEvent(QCloseEvent *event) { + // This will accept the event, which we may then override. + QTabWidget::closeEvent(event); + if (getGameCount()) { if (QMessageBox::question(this, tr("Are you sure?"), tr("There are still open games. Are you sure you want to quit?"),