diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index b42dc1c..e3709ee 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -39,8 +39,8 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : setWindowIcon( QIcon( ":/images/playuver.png" ) ); // Create a new scroll area inside the sub-window - connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); - connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); + connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValue() ) ); + connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValue() ) ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); @@ -71,60 +71,81 @@ QSize SubWindowHandle::getScrollSize() Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset ) { - QScrollBar *scrollBar = horizontalScrollBar(); - scrollBar->setValue( int( scrollBar->value() + Offset.x() ) ); - m_cLastScroll.setX( scrollBar->value() ); - scrollBar = verticalScrollBar(); - scrollBar->setValue( int( scrollBar->value() + Offset.y() ) ); - m_cLastScroll.setY( scrollBar->value() ); - updateLastScrollValue(); + QPoint cLastScroll = m_cCurrScroll; + m_cCurrScroll.setX(int( cLastScroll.x() + Offset.x() )); + m_cCurrScroll.setY(int( cLastScroll.y() + Offset.y() )); + + if(!widget()->visibleRegion().isEmpty()) + { + QScrollBar *scrollBar = horizontalScrollBar(); + scrollBar->setValue( m_cCurrScroll.x() ); + scrollBar = verticalScrollBar(); + scrollBar->setValue( m_cCurrScroll.y() ); + } } // This function was developed with help of the schematics presented in // http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center ) { + QPoint cLastScroll = m_cCurrScroll; QScrollBar *scrollBar = horizontalScrollBar(); if( center.isNull() ) { - scrollBar->setValue( int( scale * scrollBar->value() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) ) ); + m_cCurrScroll.setX(int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) )); } else { - Int x = center.x() - m_cLastScroll.x(); - Int value = int( scale * m_cLastScroll.x() + ( ( scale - 1 ) * x ) ); + Int x = center.x() - cLastScroll.x(); + Int value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) ); if( value > scrollBar->maximum() ) value = scrollBar->maximum(); if( value < scrollBar->minimum() ) value = scrollBar->minimum(); - scrollBar->setValue( value ); + m_cCurrScroll.setX(value); } scrollBar = verticalScrollBar(); if( center.isNull() ) { - scrollBar->setValue( int( scale * scrollBar->value() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) ) ); + m_cCurrScroll.setY(int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) )); } else { - Int y = center.y() - m_cLastScroll.y(); - Int value = int( scale * m_cLastScroll.y() + ( ( scale - 1 ) * y ) ); + Int y = center.y() - cLastScroll.y(); + Int value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) ); if( value > scrollBar->maximum() ) value = scrollBar->maximum(); if( value < scrollBar->minimum() ) value = scrollBar->minimum(); - scrollBar->setValue( value ); + m_cCurrScroll.setY(value); } - updateLastScrollValue(); + if(!widget()->visibleRegion().isEmpty()) + { + scrollBar = horizontalScrollBar(); + scrollBar->setValue( m_cCurrScroll.x() ); + scrollBar = verticalScrollBar(); + scrollBar->setValue( m_cCurrScroll.y() ); + } + + update(); } -Void SubWindowHandle::updateLastScrollValue() +Void SubWindowHandle::updateCurScrollValue() { QScrollBar *scrollBar = horizontalScrollBar(); - m_cLastScroll.setX( scrollBar->value() ); + m_cCurrScroll.setX( scrollBar->value() ); scrollBar = verticalScrollBar(); - m_cLastScroll.setY( scrollBar->value() ); + m_cCurrScroll.setY( scrollBar->value() ); +} + +Void SubWindowHandle::setCurScrollValues() +{ + QScrollBar *scrollBar = horizontalScrollBar(); + scrollBar->setValue(m_cCurrScroll.x() ); + scrollBar = verticalScrollBar(); + scrollBar->setValue(m_cCurrScroll.y() ); } Void SubWindowHandle::setWindowName( QString name ) diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 4670a16..2d77016 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -44,6 +44,7 @@ Q_OBJECT private: QPoint m_cLastScroll; + QPoint m_cCurrScroll; UInt m_uiCategory; QString m_cWindowName; @@ -134,10 +135,11 @@ Q_SIGNALS: void aboutToClose( SubWindowHandle* ); public Q_SLOTS: -void onDestroyed(); + void onDestroyed(); void adjustScrollBarByScale( double scale, QPoint center ); void adjustScrollBarByOffset( QPoint Offset ); - void updateLastScrollValue(); + void updateCurScrollValue(); + void setCurScrollValues(); }; diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 6dfaf02..cb18a0c 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -314,13 +314,17 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset ) { if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() ) { + SubWindowHandle *subWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); for( Int i = 0; i < subWindowList.size(); i++ ) { - if( m_pcCurrentVideoSubWindow == subWindowList.at( i ) ) + subWindow = subWindowList.at( i ); + if( m_pcCurrentVideoSubWindow == subWindow ) continue; else - subWindowList.at( i )->adjustScrollBarByOffset( offset ); + { + subWindow->adjustScrollBarByOffset( offset ); + } } } } diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index d711a67..3c68a53 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -331,6 +331,9 @@ void ViewArea::paintEvent( QPaintEvent *event ) { QRect winRect = event->rect(); + if(visibleRegion().isEmpty()) + return; + if( size().isEmpty() || m_pixmap.isNull() ) return;