Skip to content

Commit d8be3f5

Browse files
committedNov 29, 2019
[layouts] When dropping a picture to a layout, place the center of
the picture item at the cursor drop location instead of the top left We want the drop location to be the center of the placed item, because drag thumbnails are usually centered on the mouse cursor
1 parent 6ef3746 commit d8be3f5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎src/app/layout/qgslayoutimagedrophandler.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ bool QgsLayoutImageDropHandler::handleFileDrop( QgsLayoutDesignerInterface *ifac
5050
std::unique_ptr< QgsLayoutItemPicture > item = qgis::make_unique< QgsLayoutItemPicture >( iface->layout() );
5151

5252
QgsLayoutPoint layoutPoint = iface->layout()->convertFromLayoutUnits( point, iface->layout()->units() );
53-
item->attemptMove( layoutPoint );
5453

5554
item->setPicturePath( file );
5655

@@ -59,6 +58,13 @@ bool QgsLayoutImageDropHandler::handleFileDrop( QgsLayoutDesignerInterface *ifac
5958
// and then move back to standard freeform image sizing
6059
item->setResizeMode( QgsLayoutItemPicture::Zoom );
6160

61+
// we want the drop location to be the center of the placed item, because drag thumbnails are usually centered on the mouse cursor
62+
item->setReferencePoint( QgsLayoutItem::Middle );
63+
item->attemptMove( layoutPoint );
64+
65+
// reset to standard top-left reference point location
66+
item->setReferencePoint( QgsLayoutItem::UpperLeft );
67+
6268
// and auto select new item for convenience
6369
QList< QgsLayoutItem * > newSelection;
6470
newSelection << item.get();

0 commit comments

Comments
 (0)
Please sign in to comment.