summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-04 11:06:28 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-04 11:06:28 -0300
commitc23dd354b9811956407da6d2eca3edbcc4999127 (patch)
tree63cef0eff740b41f762ddbbbc79a87bc6ed8253c /qt-ui
parentf457415f7ae8ff3cfd86dc5f629117c78fe56c3c (diff)
downloadsubsurface-c23dd354b9811956407da6d2eca3edbcc4999127.tar.gz
Added a shortcut to 'esc', so it clears the selection or cancels the plan.
Added a shortcut to the esc key, so it clears the selection, if there's no selection, it acts just like clicking on the 'cancel' button. Next: delete selected handlers. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp20
-rw-r--r--qt-ui/diveplanner.h1
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();