diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 7390e60..82e7013 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -81,6 +81,10 @@ public: { return m_uiCategory; } + +Q_SIGNALS: + void zoomChanged(); + }; } // NAMESPACE diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index ce00285..c56c84e 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -93,7 +93,8 @@ VideoSubWindow::VideoSubWindow( QWidget * parent, Bool isModule ) : // Create a new interface to show images m_cViewArea = new ViewArea( m_cScrollArea ); - connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SLOT( adjustScrollBarByZoom(double, QPoint) ) ); + connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SLOT( processZoomChanged(double, QPoint) ) ); + connect( m_cViewArea, SIGNAL( moveScroll( QPoint ) ), this, SLOT( adjustScrollBarByOffset(QPoint) ) ); connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) ); connect( m_cScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); @@ -406,6 +407,12 @@ Void VideoSubWindow::scaleView( const QSize & size ) updateLastScrollValue(); } +Void VideoSubWindow::processZoomChanged( Double factor, QPoint center ) +{ + adjustScrollBarByZoom( factor, center ); + emit zoomChanged(); +} + void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset ) { QScrollBar *scrollBar = m_cScrollArea->horizontalScrollBar(); @@ -420,7 +427,7 @@ void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset ) // This function was developed with help of the schematics presented in // http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position -void VideoSubWindow::adjustScrollBarByZoom( double factor, QPoint center ) +Void VideoSubWindow::adjustScrollBarByZoom( Double factor, QPoint center ) { QScrollBar *scrollBar = m_cScrollArea->horizontalScrollBar(); if( center.isNull() ) diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index c98fdd9..2bb5ca4 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -159,18 +159,19 @@ public: Void applyModuleAllFrames(); /** - * Reimplemented function from SubWindowHandle + * Virtual functions from SubWindowHandle */ Void normalSize(); Void zoomToFit(); Void scaleView( Double scale ); - Void scaleViewByRatio( Double ratio ); Double getScaleFactor() { return m_cViewArea->getZoomFactor(); } + Void adjustScrollBarByZoom( Double factor, QPoint center ); + QSize sizeHint() const; QString getWindowShortName() @@ -200,7 +201,7 @@ protected: public Q_SLOTS: void updateSelectedArea( QRect area ); - void adjustScrollBarByZoom( double factor, QPoint center ); + void processZoomChanged( double , QPoint ); void adjustScrollBarByOffset( QPoint Offset ); void updateLastScrollValue(); }; diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 3e3fc25..e96bd15 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -169,6 +169,7 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) return; } videoSubWindow = new VideoSubWindow( this ); //createSubWindow(); + SubWindowHandle *subWindow = videoSubWindow; if( !pStreamInfo ) { Int idx = findPlaYUVerStreamInfo( m_aRecentFileStreamInfo, fileName ); @@ -192,7 +193,8 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) connect( videoSubWindow->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), this, SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) ); connect( videoSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), this, SLOT( updatePropertiesSelectedArea( QRect ) ) ); - connect( videoSubWindow->getViewArea(), SIGNAL( zoomFactorChanged( double , QPoint ) ), this, SLOT( updateZoomFactorSBox() ) ); + + connect( subWindow, SIGNAL( zoomChanged() ), this, SLOT( updateZoomFactorSBox() ) ); videoSubWindow->zoomToFit(); videoSubWindow->getViewArea()->setTool( m_appTool ); @@ -744,7 +746,6 @@ Void plaYUVerApp::scaleFrame( int ratio ) if( m_pcCurrentSubWindow ) { m_pcCurrentSubWindow->scaleView( ( Double )( ratio ) / 100.0 ); - updateZoomFactorSBox(); } }