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>
This commit is contained in:
Tomaz Canabrava 2013-07-04 11:06:28 -03:00
parent f457415f7a
commit c23dd354b9
2 changed files with 20 additions and 1 deletions

View file

@ -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();
}

View file

@ -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();