Skip to content
Permalink
Browse files

Merge pull request #34797 from lbartoletti/fix_key_conflict_for_close…

…_editing_line

Use a different key sequence for close editing line. Fixes #34793
  • Loading branch information
m-kuhn authored and lbartoletti committed Mar 5, 2020
1 parent fb3efd8 commit 1a456103fd5dd551cb604009c215720e66247921
@@ -274,7 +274,7 @@ void QgsMapToolDigitizeFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
return;
}

if ( mode() == CapturePolygon )
if ( mode() == CapturePolygon || e->modifiers() == Qt::ShiftModifier )
{
closePolygon();
}
@@ -482,5 +482,23 @@ void TestQgsMapToolAddFeatureLine::testTopologicalEditingZ()
mCanvas->snappingUtils()->setConfig( cfg );
cfg.project()->setTopologicalEditing( topologicalEditing );
}

void TestQgsMapToolAddFeatureLine::testCloseLine()
{
TestQgsMapToolAdvancedDigitizingUtils utils( mCaptureTool );

mCanvas->setCurrentLayer( mLayerCloseLine );
QSet<QgsFeatureId> oldFids = utils.existingFeatureIds();
utils.mouseClick( 1, 1, Qt::LeftButton );
utils.mouseClick( 5, 1, Qt::LeftButton );
utils.mouseClick( 5, 5, Qt::LeftButton );
utils.mouseClick( 5, 5, Qt::RightButton, Qt::ShiftModifier );
QgsFeatureId newFid = utils.newFeatureId( oldFids );

QString wkt = "LineString (1 1, 5 1, 5 5, 1 1)";
QCOMPARE( mLayerCloseLine->getFeature( newFid ).geometry(), QgsGeometry::fromWkt( wkt ) );

mLayerCloseLine->undoStack()->undo();
}
QGSTEST_MAIN( TestQgsMapToolAddFeatureLine )
#include "testqgsmaptooladdfeatureline.moc"
@@ -97,12 +97,12 @@ class TestQgsMapToolAdvancedDigitizingUtils
mouseRelease( mapX, mapY, button, stateKey, snap );
}

void keyClick( int key )
void keyClick( int key, Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers() )
{
QKeyEvent e1( QEvent::KeyPress, key, Qt::KeyboardModifiers() );
QKeyEvent e1( QEvent::KeyPress, key, stateKey );
mMapTool->keyPressEvent( &e1 );

QKeyEvent e2( QEvent::KeyRelease, key, Qt::KeyboardModifiers() );
QKeyEvent e2( QEvent::KeyRelease, key, stateKey );
mMapTool->keyReleaseEvent( &e2 );
}

@@ -183,12 +183,12 @@ class TestQgsMapToolUtils
mouseRelease( mapX, mapY, button, stateKey, snap );
}

void keyClick( int key )
void keyClick( int key, Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers() )
{
QKeyEvent e1( QEvent::KeyPress, key, Qt::KeyboardModifiers() );
QKeyEvent e1( QEvent::KeyPress, key, stateKey );
mMapTool->keyPressEvent( &e1 );

QKeyEvent e2( QEvent::KeyRelease, key, Qt::KeyboardModifiers() );
QKeyEvent e2( QEvent::KeyRelease, key, stateKey );
mMapTool->keyReleaseEvent( &e2 );
}

0 comments on commit 1a45610

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