Don't resize canvas size on widget change

This commit is contained in:
Nathan 2016-04-29 04:07:18 +10:00
parent 0739750e20
commit ef51b702b8
2 changed files with 23 additions and 4 deletions

View File

@ -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() );
@ -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()
{

View File

@ -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();
@ -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