Skip to content

Commit ddfb697

Browse files
committed
[composer] Refresh picture size if composition resolution changes (sponsored by City of Uster, Switzerland)
1 parent ecc2ebf commit ddfb697

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/core/composer/qgscomposerpicture.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ void QgsComposerPicture::init()
6868
//connect to atlas feature changing
6969
connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshPicture() ) );
7070

71+
//connect to composer print resolution changing
72+
connect( mComposition, SIGNAL( printResolutionChanged() ), this, SLOT( recalculateSize() ) );
7173
}
7274

7375
QgsComposerPicture::~QgsComposerPicture()
@@ -275,7 +277,7 @@ void QgsComposerPicture::loadPicture( const QFile& file )
275277

276278
if ( mMode != Unknown ) //make sure we start with a new QImage
277279
{
278-
setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
280+
recalculateSize();
279281
}
280282
emit itemChanged();
281283
}
@@ -463,11 +465,18 @@ void QgsComposerPicture::setResizeMode( QgsComposerPicture::ResizeMode mode )
463465
|| ( mode == QgsComposerPicture::Zoom && mPictureRotation != 0 ) )
464466
{
465467
//call set scene rect to force item to resize to fit picture
466-
setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
468+
recalculateSize();
467469
}
468470
update();
469471
}
470472

473+
void QgsComposerPicture::recalculateSize()
474+
{
475+
//call set scene rect with current position/size, as this will trigger the
476+
//picture item to recalculate its frame and image size
477+
setSceneRect( QRectF( pos().x(), pos().y(), rect().width(), rect().height() ) );
478+
}
479+
471480
void QgsComposerPicture::setUsePictureExpression( bool useExpression )
472481
{
473482
if ( useExpression == mUseSourceExpression )

src/core/composer/qgscomposerpicture.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ class CORE_EXPORT QgsComposerPicture: public QgsComposerItem
181181

182182
void updatePictureExpression();
183183

184+
void recalculateSize();
185+
184186
signals:
185187
/**Is emitted on picture rotation change*/
186188
void pictureRotationChanged( double newRotation );

0 commit comments

Comments
 (0)