mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-17 06:11:49 +01:00
Warn before exiting Eliot when a game is started
This commit is contained in:
parent
c7cf102674
commit
219b99192d
2 changed files with 18 additions and 4 deletions
|
@ -358,6 +358,18 @@ void MainWindow::showDefinition(QString iWord)
|
|||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (m_game)
|
||||
{
|
||||
QString msg = _q("A game has been started.");
|
||||
if (!requestConfirmation(msg, _q("Do you really want to quit?")))
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("Exiting");
|
||||
|
||||
// Make sure auxiliary windows don't survive after the main one
|
||||
if (m_bagWindow)
|
||||
m_bagWindow->close();
|
||||
|
@ -436,10 +448,13 @@ void MainWindow::changeDictionary(QString iFileName)
|
|||
}
|
||||
|
||||
|
||||
bool MainWindow::requestConfirmation(QString msg)
|
||||
bool MainWindow::requestConfirmation(QString msg, QString question)
|
||||
{
|
||||
QMessageBox confirmationBox(QMessageBox::Question, _q("Eliot"), msg,
|
||||
QMessageBox::Yes | QMessageBox::No, this);
|
||||
if (question != "")
|
||||
confirmationBox.setInformativeText(question);
|
||||
else
|
||||
confirmationBox.setInformativeText(_q("Do you want to continue?"));
|
||||
confirmationBox.setDefaultButton(QMessageBox::Yes);
|
||||
confirmationBox.setEscapeButton(QMessageBox::No);
|
||||
|
@ -803,7 +818,6 @@ void MainWindow::onGamePrint()
|
|||
|
||||
void MainWindow::onGameQuit()
|
||||
{
|
||||
LOG_INFO("Exiting");
|
||||
close();
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ private:
|
|||
void destroyCurrentGame();
|
||||
|
||||
/// Ask for a confirmation
|
||||
bool requestConfirmation(QString msg);
|
||||
bool requestConfirmation(QString msg, QString question = "");
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue