diff options
-rw-r--r-- | qt-ui/diveplanner.cpp | 20 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 1 |
2 files changed, 20 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(); } diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 9c8a2b7a6..310ef737c 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -77,6 +77,7 @@ protected: void deleteTemporaryDivePlan(struct divedatapoint* dp); qreal fromPercent(qreal percent, Qt::Orientation orientation); private slots: + void keyEscAction(); void increaseTime(); void increaseDepth(); void okClicked(); |