diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-02 07:16:56 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-02 07:16:56 +0200 |
commit | 4bc6c9e69170f2e4aa9bdcd908fda7027bcae044 (patch) | |
tree | b0fcea0ad320036fc92933999410e59f884ceb36 /facetracknoir/ui.cpp | |
parent | 3a66beb3da397c21c95fb46fd20cd56989541876 (diff) |
ui: confirm exit if tracking in progress
Sponsored-by: TrackHat
Diffstat (limited to 'facetracknoir/ui.cpp')
-rw-r--r-- | facetracknoir/ui.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 15fdd308..eb6cf7e1 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -93,6 +93,14 @@ MainWindow::MainWindow() : QMessageBox::Ok, QMessageBox::NoButton); } +void MainWindow::closeEvent(QCloseEvent *e) +{ + if (maybe_not_close_tracking()) + e->ignore(); + else + e->accept(); +} + bool MainWindow::get_new_config_name_from_dialog(QString& ret) { new_file_dialog dlg; @@ -410,8 +418,23 @@ void MainWindow::showCurveConfiguration() { mk_window<MapWidget, Mappings&, main_settings&>(&mapping_widget, pose, s); } +bool MainWindow::maybe_not_close_tracking() +{ + if (work != nullptr) + { + auto btn = QMessageBox::warning(this, "Tracking active", + "Are you sure you want to exit? This will terminate tracking.", + QMessageBox::Yes, QMessageBox::No); + if (btn == QMessageBox::No) + return true; + } + return false; +} + void MainWindow::exit() { - QCoreApplication::exit(0); + + if (!maybe_not_close_tracking()) + QCoreApplication::exit(0); } void MainWindow::profileSelected(QString name) |