From fafaf0eef0a72727377738c9c71293272e270107 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 3 Jun 2014 15:29:28 -0700 Subject: Cancel dive edit when escape key is pressed Also seems intuitive. What's odd is that in the Planner you get a confirmation dialog while here you don't. We should be consistent. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 12 ++++++++++++ qt-ui/maintab.h | 1 + 2 files changed, 13 insertions(+) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 7c28a4972..e274b7485 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -26,6 +26,7 @@ #include #include #include +#include MainTab::MainTab(QWidget *parent) : QTabWidget(parent), weightModel(new WeightModel(this)), @@ -48,6 +49,10 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), action = new QAction(tr("Cancel"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges())); + + QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this); + connect(closeKey, SIGNAL(activated()), this, SLOT(escDetected())); + addMessageAction(action); if (qApp->style()->objectName() == "oxygen") @@ -280,6 +285,7 @@ bool MainTab::eventFilter(QObject *object, QEvent *event) if (editMode != NONE) return false; + // for the dateTimeEdit widget we need to ignore Wheel events as well (as long as we aren't editing) if (object->objectName() == "dateTimeEdit" && (event->type() == QEvent::FocusIn || event->type() == QEvent::Wheel)) @@ -1052,3 +1058,9 @@ QString MainTab::trHemisphere(const char *orig) { return tr(orig); } + +void MainTab::escDetected() +{ + if (editMode != NONE) + rejectChanges(); +} diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 4d6a0e139..fefe0f6c0 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -82,6 +82,7 @@ slots: void toggleTriggeredColumn(); void updateTextLabels(bool showUnits = true); QString trHemisphere(const char *orig); + void escDetected(void); private: Ui::MainTab ui; -- cgit v1.2.3-70-g09d2