aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-03 15:29:28 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-03 15:31:21 -0700
commitfafaf0eef0a72727377738c9c71293272e270107 (patch)
treeeb5da5689ce08c3f60769c853df3021f8364dcd0 /qt-ui/maintab.cpp
parent09403f37245e95d851d4470445729afab46fc0fe (diff)
downloadsubsurface-fafaf0eef0a72727377738c9c71293272e270107.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp12
1 files changed, 12 insertions, 0 deletions
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 <QTableView>
#include <QPalette>
#include <QScrollBar>
+#include <QShortcut>
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();
+}