summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir
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
parent3a66beb3da397c21c95fb46fd20cd56989541876 (diff)
ui: confirm exit if tracking in progress
Sponsored-by: TrackHat
Diffstat (limited to 'facetracknoir')
-rw-r--r--facetracknoir/ui.cpp25
-rw-r--r--facetracknoir/ui.h2
2 files changed, 26 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)
diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h
index 1abd92ff..1b71b7f8 100644
--- a/facetracknoir/ui.h
+++ b/facetracknoir/ui.h
@@ -66,6 +66,8 @@ class MainWindow : public QMainWindow, private State
static bool get_new_config_name_from_dialog(QString &ret);
void set_profile(const QString& profile);
void maybe_save();
+ bool maybe_not_close_tracking();
+ void closeEvent(QCloseEvent *e) override;
private slots:
void _save();
void save();