From e1ec5a1f0a586bc4ca4b9ae306c9f81de5a5cf4b Mon Sep 17 00:00:00 2001 From: Luis Lucas Date: Sun, 23 Mar 2014 16:08:51 +0000 Subject: [PATCH] Some adjustments to viewarea widget resize. Sequence is kept in the middle of the scrollarea even when sub-window is resized. --- source/SubWindowHandle.cpp | 1 + source/ViewArea.cpp | 19 +++++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index c595c59..923879f 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -45,6 +45,7 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) : // Define the cViewArea as the widget inside the scroll area m_cScrollArea->setWidget( m_cViewArea ); + m_cScrollArea->setWidgetResizable(true); m_pcCurrentModule = NULL; diff --git a/source/ViewArea.cpp b/source/ViewArea.cpp index 340523d..8949957 100755 --- a/source/ViewArea.cpp +++ b/source/ViewArea.cpp @@ -104,11 +104,10 @@ void ViewArea::setZoomFactor( double f ) //return; m_zoomFactor = f; - emit( zoomFactorChanged( m_zoomFactor ) ); + //emit( zoomFactorChanged( m_zoomFactor ) ); updateSize(); - repaint(); - updateGeometry(); + update(); } void ViewArea::setMode( ViewMode mode ) @@ -214,16 +213,7 @@ void ViewArea::updateSize() int h = m_pixmap.height() * m_zoomFactor; setMinimumSize( w, h ); - QWidget *p = parentWidget(); - if( p ) - { - // If the parent size is bigger than the minimum area to view the - // image, resize() will call resizeEvent(); otherwise, we need to - // perform the necessary updates (updateOffset). - resize( p->width(), p->height() ); - } - if( w <= width() && h <= height() ) - updateOffset(); + updateOffset(); } void ViewArea::updateOffset() @@ -250,12 +240,13 @@ void ViewArea::updateOffset() //////////////////////////////////////////////////////////////////////////////// // Resize Event //////////////////////////////////////////////////////////////////////////////// -void ViewArea::resizeEvent( QResizeEvent */* event */) +void ViewArea::resizeEvent( QResizeEvent *event ) { if( size().isEmpty() || m_pixmap.isNull() ) return; updateOffset(); + update(); } //////////////////////////////////////////////////////////////////////////////// // Paint Event