Merge branch 'master' into visual_deck_storage_v2

This commit is contained in:
BruebachL 2025-01-12 19:04:05 +01:00 committed by GitHub
commit b750cc28c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 4377 additions and 3615 deletions

View file

@ -164,7 +164,7 @@ void DeckViewContainer::retranslateUi()
{
loadLocalButton->setText(tr("Load deck..."));
loadRemoteButton->setText(tr("Load remote deck..."));
unloadDeckButton->setText(tr("Unload deck..."));
unloadDeckButton->setText(tr("Unload deck"));
readyStartButton->setText(tr("Ready to start"));
forceStartGameButton->setText(tr("Force start"));
updateSideboardLockButtonText();
@ -581,16 +581,14 @@ void TabGame::emitUserEvent()
TabGame::~TabGame()
{
scene->clearViews();
delete replay;
QMapIterator<int, Player *> i(players);
while (i.hasNext()) {
delete i.next().value();
}
players.clear();
emit gameClosing(this);
}
void TabGame::updatePlayerListDockTitle()
@ -701,9 +699,15 @@ void TabGame::retranslateUi()
scene->retranslateUi();
}
void TabGame::closeRequest()
void TabGame::closeRequest(bool forced)
{
actLeaveGame();
if (!forced && !leaveGame()) {
return;
}
emit gameClosing(this);
close();
}
void TabGame::replayNextEvent(Player::EventProcessingOptions options)
@ -794,19 +798,23 @@ void TabGame::actConcede()
}
}
void TabGame::actLeaveGame()
/**
* Confirms the leave game and sends the leave game command, if applicable.
*
* @return True if the leave game is confirmed
*/
bool TabGame::leaveGame()
{
if (!gameClosed) {
if (!spectator)
if (QMessageBox::question(this, tr("Leave game"), tr("Are you sure you want to leave this game?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
return;
return false;
if (!replay)
sendGameCommand(Command_LeaveGame());
}
scene->clearViews();
deleteLater();
return true;
}
void TabGame::actSay()
@ -1598,7 +1606,7 @@ void TabGame::createMenuItems()
aConcede = new QAction(this);
connect(aConcede, SIGNAL(triggered()), this, SLOT(actConcede()));
aLeaveGame = new QAction(this);
connect(aLeaveGame, SIGNAL(triggered()), this, SLOT(actLeaveGame()));
connect(aLeaveGame, &QAction::triggered, this, [this] { closeRequest(); });
aFocusChat = new QAction(this);
connect(aFocusChat, SIGNAL(triggered()), sayEdit, SLOT(setFocus()));
aCloseReplay = nullptr;
@ -1648,7 +1656,7 @@ void TabGame::createReplayMenuItems()
aFocusChat = nullptr;
aLeaveGame = nullptr;
aCloseReplay = new QAction(this);
connect(aCloseReplay, SIGNAL(triggered()), this, SLOT(actLeaveGame()));
connect(aCloseReplay, &QAction::triggered, this, [this] { closeRequest(); });
phasesMenu = nullptr;
gameMenu = new QMenu(this);