Skip to content
Permalink
Browse files

Restore picture atlas handling

  • Loading branch information
nyalldawson committed Jan 5, 2018
1 parent fee1c21 commit 4a7813b9537d1d923a700db516b7df0d35d7da10
@@ -235,6 +235,11 @@ Emitted when the context's ``layer`` is changed.
%Docstring
Emitted certain settings in the context is changed, e.g. by setting a new feature or vector layer
for the context.
%End

void dpiChanged();
%Docstring
Emitted when the context's DPI is changed.
%End

};
@@ -89,7 +89,11 @@ void QgsLayoutContext::setLayer( QgsVectorLayer *layer )

void QgsLayoutContext::setDpi( double dpi )
{
if ( dpi == mMeasurementConverter.dpi() )
return;

mMeasurementConverter.setDpi( dpi );
emit dpiChanged();
}

double QgsLayoutContext::dpi() const
@@ -236,6 +236,11 @@ class CORE_EXPORT QgsLayoutContext : public QObject
*/
void changed();

/**
* Emitted when the context's DPI is changed.
*/
void dpiChanged();

private:

Flags mFlags = nullptr;
@@ -54,14 +54,12 @@ QgsLayoutItemPicture::QgsLayoutItemPicture( QgsLayout *layout )

//connect some signals

#if 0 //TODO
//connect to atlas feature changing
//to update the picture source expression
connect( &mComposition->atlasComposition(), &QgsAtlasComposition::featureChanged, this, [ = ] { refreshPicture(); } );
connect( &layout->context(), &QgsLayoutContext::changed, this, [ = ] { refreshPicture(); } );

//connect to layout print resolution changing
connect( layout->context(), &QgsLayoutContext::printResolutionChanged, this, &QgsLayoutItemPicture::recalculateSize );
#endif
connect( &layout->context(), &QgsLayoutContext::dpiChanged, this, &QgsLayoutItemPicture::recalculateSize );

connect( this, &QgsLayoutItem::sizePositionChanged, this, &QgsLayoutItemPicture::shapeChanged );
}
@@ -145,9 +145,17 @@ void TestQgsLayoutContext::layer()
void TestQgsLayoutContext::dpi()
{
QgsLayoutContext context;

QSignalSpy spyDpiChanged( &context, &QgsLayoutContext::dpiChanged );
context.setDpi( 600 );
QCOMPARE( context.dpi(), 600.0 );
QCOMPARE( context.measurementConverter().dpi(), 600.0 );
QCOMPARE( spyDpiChanged.count(), 1 );

context.setDpi( 600 );
QCOMPARE( spyDpiChanged.count(), 1 );
context.setDpi( 6000 );
QCOMPARE( spyDpiChanged.count(), 2 );
}

void TestQgsLayoutContext::renderContextFlags()

0 comments on commit 4a7813b

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