Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ committed Dec 12, 2024
1 parent 14ce7ea commit f4d991f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
#endif

// Delete selection should be disabled when creating node item
connect( mAddNodeItemTool, &QgsLayoutViewTool::activated, this, [ this, backSpace ] { backSpace->setEnabled( false ); mActionDeleteSelection->setEnabled( false ); } );
connect( mAddNodeItemTool, &QgsLayoutViewTool::deactivated, this, [ this, backSpace ] { backSpace->setEnabled( true ); mActionDeleteSelection->setEnabled( true ); } );
connect( mAddNodeItemTool, &QgsLayoutViewTool::activated, this, [this, backSpace] { backSpace->setEnabled( false ); mActionDeleteSelection->setEnabled( false ); } );
connect( mAddNodeItemTool, &QgsLayoutViewTool::deactivated, this, [this, backSpace] { backSpace->setEnabled( true ); mActionDeleteSelection->setEnabled( true ); } );


mActionPreviewModeOff->setChecked( true );
Expand Down Expand Up @@ -3936,11 +3936,6 @@ void QgsLayoutDesignerDialog::activateNewItemCreationTool( int id, bool nodeBase
if ( mView )
mView->setTool( mAddNodeItemTool );
}

if ( mLayout )
{
mLayout->deselectAll();
}
}

void QgsLayoutDesignerDialog::createLayoutPropertiesWidget()
Expand Down
11 changes: 10 additions & 1 deletion src/gui/layout/qgslayoutviewtooladdnodeitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ void QgsLayoutViewToolAddNodeItem::layoutPressEvent( QgsLayoutViewMouseEvent *ev
mRubberBand.reset( QgsGui::layoutItemGuiRegistry()->createNodeItemRubberBand( mItemMetadataId, view() ) );
if ( mRubberBand )
layout()->addItem( mRubberBand.get() );

// On first press, deselect the currently selected item, if any
view()->deselectAll();
}

if ( mRubberBand )
Expand Down Expand Up @@ -192,8 +195,14 @@ void QgsLayoutViewToolAddNodeItem::moveTemporaryNode( QPointF scenePoint, Qt::Ke
void QgsLayoutViewToolAddNodeItem::setRubberBandNodes()
{
QList<QGraphicsItem *> items = mRubberBand->childItems();

// Rubber band is not a QGraphicsItem with children, but may be
// a custom QGraphicsPolygonItem / QGraphicsPathItem returned by a Python plugin
// In this case, directly append it to the list.
if ( items.isEmpty() )
return;
{
items << mRubberBand.get();
}

if ( QGraphicsPolygonItem *polygonItem = dynamic_cast<QGraphicsPolygonItem *>( items[0] ) )
{
Expand Down

0 comments on commit f4d991f

Please sign in to comment.