Skip to content

Commit

Permalink
[composer] Refresh picture size if composition resolution changes (sp…
Browse files Browse the repository at this point in the history
…onsored by City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Apr 28, 2014
1 parent ecc2ebf commit ddfb697
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/core/composer/qgscomposerpicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ void QgsComposerPicture::init()
//connect to atlas feature changing
connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshPicture() ) );

//connect to composer print resolution changing
connect( mComposition, SIGNAL( printResolutionChanged() ), this, SLOT( recalculateSize() ) );
}

QgsComposerPicture::~QgsComposerPicture()
Expand Down Expand Up @@ -275,7 +277,7 @@ void QgsComposerPicture::loadPicture( const QFile& file )

if ( mMode != Unknown ) //make sure we start with a new QImage
{
setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
recalculateSize();
}
emit itemChanged();
}
Expand Down Expand Up @@ -463,11 +465,18 @@ void QgsComposerPicture::setResizeMode( QgsComposerPicture::ResizeMode mode )
|| ( mode == QgsComposerPicture::Zoom && mPictureRotation != 0 ) )
{
//call set scene rect to force item to resize to fit picture
setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
recalculateSize();
}
update();
}

void QgsComposerPicture::recalculateSize()
{
//call set scene rect with current position/size, as this will trigger the
//picture item to recalculate its frame and image size
setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
}

void QgsComposerPicture::setUsePictureExpression( bool useExpression )
{
if ( useExpression == mUseSourceExpression )
Expand Down
2 changes: 2 additions & 0 deletions src/core/composer/qgscomposerpicture.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem

void updatePictureExpression();

void recalculateSize();

signals:
/**Is emitted on picture rotation change*/
void pictureRotationChanged( double newRotation );
Expand Down

0 comments on commit ddfb697

Please sign in to comment.