Skip to content

Commit

Permalink
Don't resize canvas size on widget change
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Apr 28, 2016
1 parent 0739750 commit ef51b70
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1352,13 +1352,11 @@ void QgsMapCanvas::mouseReleaseEvent( QMouseEvent* e )

} // mouseReleaseEvent

void QgsMapCanvas::resizeEvent( QResizeEvent * e )
void QgsMapCanvas::updateMapSize()
{
QGraphicsView::resizeEvent( e );
mResizeTimer->start( 500 );

QSize lastSize = viewport()->size();

mSettings.setOutputSize( lastSize );
mMapRenderer->setOutputSize( lastSize, mSettings.outputDpi() );

Expand All @@ -1376,12 +1374,28 @@ void QgsMapCanvas::resizeEvent( QResizeEvent * e )
emit extentsChanged();
}


void QgsMapCanvas::resizeEvent( QResizeEvent * e )
{
QGraphicsView::resizeEvent( e );

QSize size = viewport()->size();
if ( size.width() > mSettings.outputSize().width() || size.height() > mSettings.outputSize().height() )
{
updateMapSize();
}
else
{
moveCanvasContents( true );
}
}

void QgsMapCanvas::paintEvent( QPaintEvent *e )
{
// no custom event handling anymore

QGraphicsView::paintEvent( e );
} // paintEvent
}

void QgsMapCanvas::updateCanvasItemPositions()
{
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -501,6 +501,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! @note added in 2.8
static void enableRotation( bool enabled );


private slots:
//! called when current maptool is destroyed
void mapToolDestroyed();
Expand Down Expand Up @@ -746,6 +747,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView

QgsExpressionContextScope mExpressionContextScope;

//! Force a resize of the map canvas item
//! @note added in 2.16
void updateMapSize();

}; // class QgsMapCanvas
Q_NOWARN_DEPRECATED_POP

Expand Down

0 comments on commit ef51b70

Please sign in to comment.