Skip to content

Commit

Permalink
Port method for pausing layout view updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 17, 2017
1 parent 1b8f4a0 commit 113664f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/gui/layout/qgslayoutview.sip
Expand Up @@ -265,6 +265,7 @@ Returns the delta (in layout coordinates) by which to move items
for the given key ``event``.
%End


public slots:

void zoomFull();
Expand Down Expand Up @@ -557,6 +558,8 @@ item and should have its properties displayed in any designer windows.

virtual void dragEnterEvent( QDragEnterEvent *e );

virtual void paintEvent( QPaintEvent *event );


};

Expand Down
13 changes: 13 additions & 0 deletions src/gui/layout/qgslayoutview.cpp
Expand Up @@ -1002,6 +1002,19 @@ void QgsLayoutView::dragEnterEvent( QDragEnterEvent *e )
e->ignore();
}

void QgsLayoutView::paintEvent( QPaintEvent *event )
{
if ( mPaintingEnabled )
{
QGraphicsView::paintEvent( event );
event->accept();
}
else
{
event->ignore();
}
}

void QgsLayoutView::invalidateCachedRenders()
{
if ( !currentLayout() )
Expand Down
10 changes: 10 additions & 0 deletions src/gui/layout/qgslayoutview.h
Expand Up @@ -270,6 +270,13 @@ class GUI_EXPORT QgsLayoutView: public QGraphicsView
*/
QPointF deltaForKeyEvent( QKeyEvent *event );

/**
* Sets whether widget repainting should be allowed for the view. This is
* used to temporarily halt painting while exporting layouts.
* \note Not available in Python bindings.
*/
void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; } SIP_SKIP

public slots:

/**
Expand Down Expand Up @@ -512,6 +519,7 @@ class GUI_EXPORT QgsLayoutView: public QGraphicsView
void resizeEvent( QResizeEvent *event ) override;
void scrollContentsBy( int dx, int dy ) override;
void dragEnterEvent( QDragEnterEvent *e ) override;
void paintEvent( QPaintEvent *event ) override;

private slots:

Expand Down Expand Up @@ -543,6 +551,8 @@ class GUI_EXPORT QgsLayoutView: public QGraphicsView

QgsPreviewEffect *mPreviewEffect = nullptr;

bool mPaintingEnabled = true;

friend class TestQgsLayoutView;
friend class QgsLayoutMouseHandles;

Expand Down

0 comments on commit 113664f

Please sign in to comment.