Skip to content
Permalink
Browse files

Don't resize canvas size on widget change

  • Loading branch information
NathanW2 committed Apr 28, 2016
1 parent 0739750 commit ef51b702b89ce7c90b3fa9ee8a9d9fab8bc9e528
Showing with 23 additions and 4 deletions.
  1. +18 −4 src/gui/qgsmapcanvas.cpp
  2. +5 −0 src/gui/qgsmapcanvas.h
@@ -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()
{
@@ -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

0 comments on commit ef51b70

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