// Exit application SLOT
void Simulator::exitApplication() {
// Check if an evolution or a test are in progress
if ((evolutionInProgress) || (testInProgress)) {
// Pause the simulation
mainWindow->checkBox_PauseEvolution->setChecked(true);
// Show a dialog box asking confirmation to the user
int reply;
if (evolutionInProgress
) reply
= QMessageBox::warning(this, tr
("Application exit"),
tr("An evolution is in progress.\nAre you really sure you want to exit now?"),
else reply
= QMessageBox::warning(this, tr
("Application exit"),
tr("A test is in progress.\nAre you really sure you want to exit now?"),
// Check the answer provided by the user (exit or not)
// If an evolution is running, ask to the user if he'd like to save the population
if ((currentGeneration != 0) && (evolutionInProgress)) {
tr("Save current population"), tr("Do you want to save the current population, in order to restore the simulation later?"),
savePopulation();
directoryName
= seedDirectory
+ "/Gen_" + QString::number(currentGeneration
);
tr("Population saved"), tr("The population has been saved into the directory:\n%1").arg(directoryName));
}
}
// Quit the application
::exit(0);
} else {
// Return to the simulation
mainWindow->checkBox_PauseEvolution->setChecked(false);
}
} else { // If no simulations or tests are in progress, directly quit the application
emit confirmClosing();
}
}
// Exit application SLOT
void Simulator::exitApplication() {
// Check if an evolution or a test are in progress
if ((evolutionInProgress) || (testInProgress)) {
// Pause the simulation
mainWindow->checkBox_PauseEvolution->setChecked(true);
// Show a dialog box asking confirmation to the user
int reply;
if (evolutionInProgress) reply = QMessageBox::warning(this, tr("Application exit"),
tr("An evolution is in progress.\nAre you really sure you want to exit now?"),
QMessageBox::No | QMessageBox::Default, QMessageBox::Yes | QMessageBox::Escape);
else reply = QMessageBox::warning(this, tr("Application exit"),
tr("A test is in progress.\nAre you really sure you want to exit now?"),
QMessageBox::No | QMessageBox::Default, QMessageBox::Yes | QMessageBox::Escape);
// Check the answer provided by the user (exit or not)
if (reply == QMessageBox::Yes) {
// If an evolution is running, ask to the user if he'd like to save the population
if ((currentGeneration != 0) && (evolutionInProgress)) {
int answer = QMessageBox::question(this,
tr("Save current population"), tr("Do you want to save the current population, in order to restore the simulation later?"),
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape);
if (answer == QMessageBox::Yes) {
savePopulation();
QString directoryName;
directoryName = seedDirectory + "/Gen_" + QString::number(currentGeneration);
QMessageBox::information(this,
tr("Population saved"), tr("The population has been saved into the directory:\n%1").arg(directoryName));
}
}
// Quit the application
::exit(0);
} else {
// Return to the simulation
mainWindow->checkBox_PauseEvolution->setChecked(false);
}
} else { // If no simulations or tests are in progress, directly quit the application
emit confirmClosing();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks