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)
|
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
|
// Make sure auxiliary windows don't survive after the main one
|
||||||
if (m_bagWindow)
|
if (m_bagWindow)
|
||||||
m_bagWindow->close();
|
m_bagWindow->close();
|
||||||
|
@ -436,11 +448,14 @@ 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 confirmationBox(QMessageBox::Question, _q("Eliot"), msg,
|
||||||
QMessageBox::Yes | QMessageBox::No, this);
|
QMessageBox::Yes | QMessageBox::No, this);
|
||||||
confirmationBox.setInformativeText(_q("Do you want to continue?"));
|
if (question != "")
|
||||||
|
confirmationBox.setInformativeText(question);
|
||||||
|
else
|
||||||
|
confirmationBox.setInformativeText(_q("Do you want to continue?"));
|
||||||
confirmationBox.setDefaultButton(QMessageBox::Yes);
|
confirmationBox.setDefaultButton(QMessageBox::Yes);
|
||||||
confirmationBox.setEscapeButton(QMessageBox::No);
|
confirmationBox.setEscapeButton(QMessageBox::No);
|
||||||
int res = confirmationBox.exec();
|
int res = confirmationBox.exec();
|
||||||
|
@ -803,7 +818,6 @@ void MainWindow::onGamePrint()
|
||||||
|
|
||||||
void MainWindow::onGameQuit()
|
void MainWindow::onGameQuit()
|
||||||
{
|
{
|
||||||
LOG_INFO("Exiting");
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ private:
|
||||||
void destroyCurrentGame();
|
void destroyCurrentGame();
|
||||||
|
|
||||||
/// Ask for a confirmation
|
/// Ask for a confirmation
|
||||||
bool requestConfirmation(QString msg);
|
bool requestConfirmation(QString msg, QString question = "");
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue