Skip to content

Commit

Permalink
Fix offset tool does not apply offsets which are only directly
Browse files Browse the repository at this point in the history
entered into the offset distance widget (without mouse moves)

Refs #44866
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Aug 30, 2021
1 parent d5b2217 commit e8e4ef4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/app/qgsmaptooloffsetcurve.cpp
Expand Up @@ -131,6 +131,15 @@ void QgsMapToolOffsetCurve::canvasReleaseEvent( QgsMapMouseEvent *e )
}
}

void QgsMapToolOffsetCurve::applyOffsetFromWidget( double offset, Qt::KeyboardModifiers modifiers )
{
if ( mSourceLayer && !mOriginalGeometry.isNull() && !qgsDoubleNear( offset, 0 ) )
{
mGeometryModified = true;
applyOffset( offset, modifiers );
}
}

void QgsMapToolOffsetCurve::applyOffset( double offset, Qt::KeyboardModifiers modifiers )
{
if ( !mSourceLayer || offset == 0.0 )
Expand Down Expand Up @@ -579,7 +588,7 @@ void QgsMapToolOffsetCurve::createUserInputWidget()
mUserInputWidget->setFocus( Qt::TabFocusReason );

connect( mUserInputWidget, &QgsOffsetUserWidget::offsetChanged, this, &QgsMapToolOffsetCurve::updateGeometryAndRubberBand );
connect( mUserInputWidget, &QgsOffsetUserWidget::offsetEditingFinished, this, &QgsMapToolOffsetCurve::applyOffset );
connect( mUserInputWidget, &QgsOffsetUserWidget::offsetEditingFinished, this, &QgsMapToolOffsetCurve::applyOffsetFromWidget );
connect( mUserInputWidget, &QgsOffsetUserWidget::offsetEditingCanceled, this, &QgsMapToolOffsetCurve::cancel );

connect( mUserInputWidget, &QgsOffsetUserWidget::offsetConfigChanged, this, [ = ] {updateGeometryAndRubberBand( mUserInputWidget->offset() );} );
Expand All @@ -590,7 +599,7 @@ void QgsMapToolOffsetCurve::deleteUserInputWidget()
if ( mUserInputWidget )
{
disconnect( mUserInputWidget, &QgsOffsetUserWidget::offsetChanged, this, &QgsMapToolOffsetCurve::updateGeometryAndRubberBand );
disconnect( mUserInputWidget, &QgsOffsetUserWidget::offsetEditingFinished, this, &QgsMapToolOffsetCurve::applyOffset );
disconnect( mUserInputWidget, &QgsOffsetUserWidget::offsetEditingFinished, this, &QgsMapToolOffsetCurve::applyOffsetFromWidget );
disconnect( mUserInputWidget, &QgsOffsetUserWidget::offsetEditingCanceled, this, &QgsMapToolOffsetCurve::cancel );
mUserInputWidget->releaseKeyboard();
mUserInputWidget->deleteLater();
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmaptooloffsetcurve.h
Expand Up @@ -69,6 +69,8 @@ class APP_EXPORT QgsMapToolOffsetCurve: public QgsMapToolEdit
//! Places curve offset from the mouse position or from the value entered in the spin box
void updateGeometryAndRubberBand( double offset );

void applyOffsetFromWidget( double offset, Qt::KeyboardModifiers modifiers );

//! Apply the offset either from the spin box or from the mouse event
void applyOffset( double offset, Qt::KeyboardModifiers modifiers );

Expand Down

0 comments on commit e8e4ef4

Please sign in to comment.