confirmation dialog on close

This commit is contained in:
Zach H 2015-07-14 19:53:13 -04:00
parent da3ade3205
commit ebd516fbf3
2 changed files with 11 additions and 8 deletions

View file

@ -136,17 +136,20 @@ void TabSupervisor::retranslateUi()
bool TabSupervisor::closeRequest() bool TabSupervisor::closeRequest()
{ {
if (getGameCount()) { 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) { {
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;
}
else
{
if (QMessageBox::question(this, tr("Close Cockatrice"), tr("Are you sure you want to close Cockatrice?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)
return false; return false;
}
} }
foreach(TabDeckEditor *tab, deckEditorTabs) foreach(TabDeckEditor *tab, deckEditorTabs)
{ if (!tab->confirmClose())
if(!tab->confirmClose())
return false; return false;
}
return true; return true;
} }

View file

@ -71,7 +71,7 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even
client->disconnectFromServer(); client->disconnectFromServer();
QString reasonStr; QString reasonStr;
switch (event.reason()) { switch (event.reason()) {
case Event_ConnectionClosed::USER_LIMIT_REACHED: reasonStr = tr("The server has reached its maximum user capacity, please check back later."); break; case Event_ConnectionClosed::USER_LIMIT_REACHED: reasonStr = tr("The server has reached its maximum user capacity, please check back later."); break;
case Event_ConnectionClosed::TOO_MANY_CONNECTIONS: reasonStr = tr("There are too many concurrent connections from your address."); break; case Event_ConnectionClosed::TOO_MANY_CONNECTIONS: reasonStr = tr("There are too many concurrent connections from your address."); break;
case Event_ConnectionClosed::BANNED: { case Event_ConnectionClosed::BANNED: {
reasonStr = tr("Banned by moderator"); reasonStr = tr("Banned by moderator");
@ -632,7 +632,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
{ {
// workaround Qt bug where closeEvent gets called twice // workaround Qt bug where closeEvent gets called twice
static bool bClosingDown=false; static bool bClosingDown=false;
if(bClosingDown) if (bClosingDown)
return; return;
bClosingDown=true; bClosingDown=true;