Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Escape should cancel rotation map tool
  • Loading branch information
nyalldawson authored and 3nids committed Jan 22, 2018
1 parent 5a80ec5 commit 8a6fcc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app/qgsmaptoolrotatefeature.cpp
Expand Up @@ -109,6 +109,11 @@ bool QgsAngleMagnetWidget::eventFilter( QObject *obj, QEvent *ev )
if ( obj == mAngleSpinBox && ev->type() == QEvent::KeyPress )
{
QKeyEvent *event = static_cast<QKeyEvent *>( ev );
if ( event->key() == Qt::Key_Escape )
{
emit angleEditingCanceled();
return true;
}
if ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return )
{
emit angleEditingFinished( angle() );
Expand Down Expand Up @@ -309,6 +314,13 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
applyRotation( mRotation );
}

void QgsMapToolRotateFeature::cancel()
{
deleteRotationWidget();
deleteRubberband();
mRotationActive = false;
}

void QgsMapToolRotateFeature::updateRubberband( double rotation )
{
if ( mRotationActive )
Expand Down Expand Up @@ -455,6 +467,7 @@ void QgsMapToolRotateFeature::createRotationWidget()

connect( mRotationWidget, &QgsAngleMagnetWidget::angleChanged, this, &QgsMapToolRotateFeature::updateRubberband );
connect( mRotationWidget, &QgsAngleMagnetWidget::angleEditingFinished, this, &QgsMapToolRotateFeature::applyRotation );
connect( mRotationWidget, &QgsAngleMagnetWidget::angleEditingCanceled, this, &QgsMapToolRotateFeature::cancel );
}

void QgsMapToolRotateFeature::deleteRotationWidget()
Expand All @@ -463,6 +476,8 @@ void QgsMapToolRotateFeature::deleteRotationWidget()
{
disconnect( mRotationWidget, &QgsAngleMagnetWidget::angleChanged, this, &QgsMapToolRotateFeature::updateRubberband );
disconnect( mRotationWidget, &QgsAngleMagnetWidget::angleEditingFinished, this, &QgsMapToolRotateFeature::applyRotation );
disconnect( mRotationWidget, &QgsAngleMagnetWidget::angleEditingCanceled, this, &QgsMapToolRotateFeature::cancel );

mRotationWidget->releaseKeyboard();
mRotationWidget->deleteLater();
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmaptoolrotatefeature.h
Expand Up @@ -43,6 +43,7 @@ class APP_EXPORT QgsAngleMagnetWidget : public QWidget
signals:
void angleChanged( double angle );
void angleEditingFinished( double angle );
void angleEditingCanceled();


public slots:
Expand Down Expand Up @@ -81,6 +82,7 @@ class APP_EXPORT QgsMapToolRotateFeature: public QgsMapToolEdit
void updateRubberband( double rotation );

void applyRotation( double rotation );
void cancel();

private:

Expand Down

0 comments on commit 8a6fcc8

Please sign in to comment.