summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index a7bd0af4c..016a47e04 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -123,9 +123,27 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
connect(cancelBtn, SIGNAL(clicked()), this, SLOT(cancelClicked()));
minMinutes = TIME_INITIAL_MAX;
+
+ QAction *escAction = new QAction(this);
+ escAction->setShortcut(Qt::Key_Escape);
+ escAction->setShortcutContext(Qt::ApplicationShortcut);
+ addAction(escAction);
+
+ connect(escAction, SIGNAL(triggered(bool)), this, SLOT(keyEscAction()));
+
setRenderHint(QPainter::Antialiasing);
}
+void DivePlannerGraphics::keyEscAction()
+{
+ if (scene()->selectedItems().count()){
+ scene()->clearSelection();
+ return;
+ }
+
+ cancelClicked();
+}
+
qreal DivePlannerGraphics::fromPercent(qreal percent, Qt::Orientation orientation)
{
qreal total = orientation == Qt::Horizontal ? sceneRect().width() : sceneRect().height();
@@ -419,7 +437,7 @@ void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent* event)
if (event->modifiers().testFlag(Qt::ControlModifier)){
setSelected(true);
}
- // mousePressEvent 'grabs' the mouse and keyboard, annoying.
+ // mousePressEvent 'grabs' the mouse and keyboard, annoying.
ungrabMouse();
ungrabKeyboard();
}