Skip to content
Permalink
Browse files

Fix missing page shadows

  • Loading branch information
nyalldawson committed Dec 19, 2017
1 parent 54acc80 commit b594ecd7c51e4594d65c9df0afe349c6dab38b12
@@ -91,8 +91,9 @@ will be set to true if string could be successfully interpreted as a
page orientation.
%End

virtual void attemptResize( const QgsLayoutSize &size, bool includesFrame = false );
virtual QRectF boundingRect() const;

virtual void attemptResize( const QgsLayoutSize &size, bool includesFrame = false );

virtual QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = 0 ) /Factory/;

@@ -32,10 +32,11 @@ QgsLayoutItemPage::QgsLayoutItemPage( QgsLayout *layout )
setFlag( QGraphicsItem::ItemIsMovable, false );
setZValue( QgsLayout::ZPage );

// use a hidden pen to specify the amount the page "bleeds" outside it's scene bounds,
// (it's a lot easier than reimplementing boundingRect() just to handle this)
QPen shadowPen( QBrush( Qt::transparent ), layout->pageCollection()->pageShadowWidth() * 2 );
setPen( shadowPen );
connect( this, &QgsLayoutItem::sizePositionChanged, this, [ = ]
{
mBoundingRect = QRectF();
prepareGeometryChange();
} );

QFont font;
QFontMetrics fm( font );
@@ -123,6 +124,17 @@ QgsLayoutItemPage::Orientation QgsLayoutItemPage::decodePageOrientation( const Q
return Landscape;
}

QRectF QgsLayoutItemPage::boundingRect() const
{
if ( mBoundingRect.isNull() )
{
double shadowWidth = mLayout->pageCollection()->pageShadowWidth();
mBoundingRect = rect();
mBoundingRect.adjust( 0, 0, shadowWidth, shadowWidth );
}
return mBoundingRect;
}

void QgsLayoutItemPage::attemptResize( const QgsLayoutSize &size, bool includesFrame )
{
QgsLayoutItem::attemptResize( size, includesFrame );
@@ -121,8 +121,8 @@ class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
*/
static QgsLayoutItemPage::Orientation decodePageOrientation( const QString &string, bool *ok SIP_OUT = nullptr );

QRectF boundingRect() const override;
void attemptResize( const QgsLayoutSize &size, bool includesFrame = false ) override;

QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = nullptr ) override SIP_FACTORY;

public slots:
@@ -140,6 +140,7 @@ class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
double mMaximumShadowWidth = -1;

std::unique_ptr< QgsLayoutItemPageGrid > mGrid;
mutable QRectF mBoundingRect;

friend class TestQgsLayoutPage;
};

0 comments on commit b594ecd

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