Skip to content
Permalink
Browse files

Fix #11330 (Composer legend can be smaller than its content)

  • Loading branch information
wonder-sk committed Oct 21, 2014
1 parent 3546b32 commit fe9c5c4f098bd483c9b9265438ab3bffc3aa18aa
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/core/composer/qgscomposerlegend.cpp
@@ -100,6 +100,14 @@ void QgsComposerLegend::paint( QPainter* painter, const QStyleOptionGraphicsItem

QgsLegendRenderer legendRenderer( mLegendModel2, mSettings );
legendRenderer.setLegendSize( rect().size() );

//adjust box if width or height is too small
QSizeF size = legendRenderer.minimumSize();
if ( size.height() > rect().height() )
setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), size.height() ) );
if ( size.width() > rect().width() )
setSceneRect( QRectF( pos().x(), pos().y(), size.width(), rect().height() ) );

legendRenderer.drawLegend( painter );

painter->restore();
@@ -116,7 +124,7 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
{
QgsLegendRenderer legendRenderer( mLegendModel2, mSettings );
QSizeF size = legendRenderer.minimumSize();
if ( !painter )
if ( painter )
legendRenderer.drawLegend( painter );
return size;
}

2 comments on commit fe9c5c4

@nyalldawson

This comment has been minimized.

Copy link
Collaborator

@nyalldawson nyalldawson replied Oct 21, 2014

@wonder-sk dammit... Now I've got no excuse for not fixing #11321!

@nyalldawson

This comment has been minimized.

Copy link
Collaborator

@nyalldawson nyalldawson replied Oct 21, 2014

(Thanks though... This fix is appreciated!)

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