Skip to content
Permalink
Browse files

[composer] Refresh picture size if composition resolution changes (sp…

…onsored by City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Apr 28, 2014
1 parent ecc2ebf commit ddfb6975fba466ae57da0768ec845ca6d83ea6e3
Showing with 13 additions and 2 deletions.
  1. +11 −2 src/core/composer/qgscomposerpicture.cpp
  2. +2 −0 src/core/composer/qgscomposerpicture.h
@@ -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()
@@ -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();
}
@@ -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 )
@@ -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 );

0 comments on commit ddfb697

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