MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / closeEvent

Method closeEvent

MiniZincIDE/mainwindow.cpp:524–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522}
523
524void MainWindow::closeEvent(QCloseEvent* e) {
525 // make sure any modifications in solver configurations are saved
526// on_conf_solver_conf_currentIndexChanged(ui->conf_solver_conf->currentIndex());
527
528 bool modified = false;
529 for (int i=0; i<ui->tabWidget->count(); i++) {
530 auto ce = qobject_cast<CodeEditor*>(ui->tabWidget->widget(i));
531 if (ce && ce->document()->isModified()) {
532 modified = true;
533 break;
534 }
535 }
536 if (modified) {
537 int ret = QMessageBox::warning(this, "MiniZinc IDE",
538 "There are modified documents.\nDo you want to discard the changes or cancel?",
539 QMessageBox::Discard | QMessageBox::Cancel);
540 if (ret == QMessageBox::Cancel) {
541 e->ignore();
542 return;
543 }
544 }
545 for (auto& sc : ui->config_window->solverConfigs()) {
546 if (sc->modified) {
547 int ret = QMessageBox::warning(this, "MiniZinc IDE",
548 "There are modified solver configurations.\nDo you want to discard the changes or cancel?",
549 QMessageBox::Discard | QMessageBox::Cancel);
550 if (ret == QMessageBox::Cancel) {
551 e->ignore();
552 return;
553 }
554 break;
555 }
556 }
557 if (getProject().isModified()) {
558 int ret = QMessageBox::warning(this, "MiniZinc IDE",
559 "The project has been modified.\nDo you want to discard the changes or cancel?",
560 QMessageBox::Discard | QMessageBox::Cancel);
561 if (ret == QMessageBox::Cancel) {
562 e->ignore();
563 return;
564 }
565 }
566 if (processRunning) {
567 int ret = QMessageBox::warning(this, "MiniZinc IDE",
568 "MiniZinc is currently running a solver.\nDo you want to quit anyway and stop the current process?",
569 QMessageBox::Yes| QMessageBox::No);
570 if (ret == QMessageBox::No) {
571 e->ignore();
572 return;
573 }
574 }
575
576 // At this point we're definitely closing
577 emit terminating();
578
579 for (int i=0; i<ui->tabWidget->count(); i++) {
580 CodeEditor* ce = qobject_cast<CodeEditor*>(ui->tabWidget->widget(i));
581 if (ce) {

Callers

nothing calls this directly

Calls 9

countMethod · 0.80
isModifiedMethod · 0.80
setDocumentMethod · 0.80
hasProjectFileMethod · 0.80
removeMethod · 0.80
projectFileMethod · 0.80
isHiddenMethod · 0.80
acceptMethod · 0.80
widgetMethod · 0.45

Tested by

no test coverage detected