Refactor: Simplify closeRequest and remove closed signal (#6062)

* Refactor: simplify closeRequest and remove closed signal

* clean up closeRequest usages
This commit is contained in:
RickyRister 2025-08-01 19:45:54 -07:00 committed by GitHub
parent fd12a1f6be
commit 04be0fe634
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 61 additions and 57 deletions

View file

@ -376,15 +376,19 @@ void TabGame::refreshShortcuts()
}
}
void TabGame::closeRequest(bool forced)
bool TabGame::closeRequest()
{
if (!forced && !leaveGame()) {
return;
if (!leaveGame()) {
return false;
}
emit gameClosing(this);
return close();
}
close();
void TabGame::closeEvent(QCloseEvent *event)
{
emit gameClosing(this);
event->accept();
}
void TabGame::incrementGameTime()
@ -1249,7 +1253,7 @@ void TabGame::createMenuItems()
aConcede = new QAction(this);
connect(aConcede, &QAction::triggered, this, &TabGame::actConcede);
aLeaveGame = new QAction(this);
connect(aLeaveGame, &QAction::triggered, this, [this] { closeRequest(); });
connect(aLeaveGame, &QAction::triggered, this, &TabGame::closeRequest);
aFocusChat = new QAction(this);
connect(aFocusChat, &QAction::triggered, sayEdit, qOverload<>(&LineEditCompleter::setFocus));
aCloseReplay = nullptr;
@ -1299,7 +1303,7 @@ void TabGame::createReplayMenuItems()
aFocusChat = nullptr;
aLeaveGame = nullptr;
aCloseReplay = new QAction(this);
connect(aCloseReplay, &QAction::triggered, this, [this] { closeRequest(); });
connect(aCloseReplay, &QAction::triggered, this, &TabGame::closeRequest);
phasesMenu = nullptr;
gameMenu = new QMenu(this);