summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/ui.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-10-02 07:16:56 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-10-02 07:16:56 +0200
commit4bc6c9e69170f2e4aa9bdcd908fda7027bcae044 (patch)
treeb0fcea0ad320036fc92933999410e59f884ceb36 /facetracknoir/ui.cpp
parent3a66beb3da397c21c95fb46fd20cd56989541876 (diff)
ui: confirm exit if tracking in progress
Sponsored-by: TrackHat
Diffstat (limited to 'facetracknoir/ui.cpp')
-rw-r--r--facetracknoir/ui.cpp25
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)