Skip to content
Permalink
Browse files

Escape should cancel rotation map tool

  • Loading branch information
nyalldawson authored and 3nids committed Jan 21, 2018
1 parent 5a80ec5 commit 8a6fcc8eace5ff412107d8267b52b40f69624df0
Showing with 17 additions and 0 deletions.
  1. +15 −0 src/app/qgsmaptoolrotatefeature.cpp
  2. +2 −0 src/app/qgsmaptoolrotatefeature.h
@@ -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() );
@@ -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 )
@@ -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()
@@ -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();
}
@@ -43,6 +43,7 @@ class APP_EXPORT QgsAngleMagnetWidget : public QWidget
signals:
void angleChanged( double angle );
void angleEditingFinished( double angle );
void angleEditingCanceled();


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

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

private:

0 comments on commit 8a6fcc8

Please sign in to comment.
You can’t perform that action at this time.