Move scroll area into VideoSubWindow
This commit is contained in:
+13
-103
@@ -26,6 +26,7 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QScrollBar>
|
||||
#include <QIcon>
|
||||
#include <QHBoxLayout>
|
||||
#include "SubWindowAbstract.h"
|
||||
#include "PlaYUVerMdiSubWindow.h"
|
||||
|
||||
@@ -33,7 +34,7 @@ namespace plaYUVer
|
||||
{
|
||||
|
||||
SubWindowAbstract::SubWindowAbstract( QWidget * parent, UInt category ) :
|
||||
QScrollArea( parent ),
|
||||
QWidget( parent ),
|
||||
m_cSubWindow( NULL )
|
||||
{
|
||||
setParent( parent );
|
||||
@@ -44,22 +45,12 @@ SubWindowAbstract::SubWindowAbstract( 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( updateCurScrollValues() ) );
|
||||
connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) );
|
||||
|
||||
setWidgetResizable( true );
|
||||
|
||||
//setWidgetResizable( true );
|
||||
m_pcLayout = NULL;
|
||||
m_uiCategory = category;
|
||||
m_cLastScroll = QPoint();
|
||||
m_cWindowName = QString( " " );
|
||||
|
||||
connect(this, SIGNAL(destroyed()), this, SLOT(onDestroyed()));
|
||||
}
|
||||
|
||||
void SubWindowAbstract::onDestroyed()
|
||||
{
|
||||
return;
|
||||
connect( this, SIGNAL( destroyed() ), this, SLOT( onDestroyed() ) );
|
||||
}
|
||||
|
||||
SubWindowAbstract::~SubWindowAbstract()
|
||||
@@ -67,98 +58,17 @@ SubWindowAbstract::~SubWindowAbstract()
|
||||
return;
|
||||
}
|
||||
|
||||
QSize SubWindowAbstract::getScrollSize()
|
||||
Void SubWindowAbstract::setWidget( QWidget* widget )
|
||||
{
|
||||
return QSize( viewport()->size().width() - 5, viewport()->size().height() - 5 );
|
||||
if( !m_pcLayout )
|
||||
m_pcLayout = new QHBoxLayout( this );
|
||||
|
||||
m_pcLayout->addWidget( widget );
|
||||
}
|
||||
|
||||
Void SubWindowAbstract::adjustScrollBarByOffset( QPoint Offset )
|
||||
void SubWindowAbstract::onDestroyed()
|
||||
{
|
||||
QPoint cLastScroll = m_cCurrScroll;
|
||||
QScrollBar *scrollBarH, *scrollBarV;
|
||||
Int valueX, valueY;
|
||||
|
||||
valueX = int( cLastScroll.x() + Offset.x() );
|
||||
valueY = int( cLastScroll.y() + Offset.y() );
|
||||
|
||||
scrollBarH = horizontalScrollBar();
|
||||
if( valueX > scrollBarH->maximum() )
|
||||
valueX = scrollBarH->maximum();
|
||||
if( valueX < scrollBarH->minimum() )
|
||||
valueX = scrollBarH->minimum();
|
||||
m_cCurrScroll.setX(valueX);
|
||||
|
||||
scrollBarV = verticalScrollBar();
|
||||
if( valueY > scrollBarV->maximum() )
|
||||
valueY = scrollBarV->maximum();
|
||||
if( valueY < scrollBarV->minimum() )
|
||||
valueY = scrollBarV->minimum();
|
||||
m_cCurrScroll.setY( valueY );
|
||||
|
||||
// Update window scroll
|
||||
scrollBarH->setValue( m_cCurrScroll.x() );
|
||||
scrollBarV->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 SubWindowAbstract::adjustScrollBarByScale( Double scale, QPoint center )
|
||||
{
|
||||
QPoint cLastScroll = m_cCurrScroll;
|
||||
QScrollBar *scrollBarH, *scrollBarV;
|
||||
|
||||
scrollBarH = horizontalScrollBar();
|
||||
if( center.isNull() )
|
||||
{
|
||||
m_cCurrScroll.setX(int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBarH->pageStep() / 2 ) ));
|
||||
}
|
||||
else
|
||||
{
|
||||
Int x = center.x() - cLastScroll.x();
|
||||
Int value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) );
|
||||
if( value > scrollBarH->maximum() )
|
||||
value = scrollBarH->maximum();
|
||||
if( value < scrollBarH->minimum() )
|
||||
value = scrollBarH->minimum();
|
||||
m_cCurrScroll.setX(value);
|
||||
}
|
||||
|
||||
scrollBarV = verticalScrollBar();
|
||||
if( center.isNull() )
|
||||
{
|
||||
m_cCurrScroll.setY(int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBarV->pageStep() / 2 ) ));
|
||||
}
|
||||
else
|
||||
{
|
||||
Int y = center.y() - cLastScroll.y();
|
||||
Int value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) );
|
||||
if( value > scrollBarV->maximum() )
|
||||
value = scrollBarV->maximum();
|
||||
if( value < scrollBarV->minimum() )
|
||||
value = scrollBarV->minimum();
|
||||
m_cCurrScroll.setY(value);
|
||||
}
|
||||
|
||||
// Update window scroll
|
||||
scrollBarH->setValue( m_cCurrScroll.x() );
|
||||
scrollBarV->setValue( m_cCurrScroll.y() );
|
||||
|
||||
}
|
||||
|
||||
Void SubWindowAbstract::updateCurScrollValues()
|
||||
{
|
||||
QScrollBar *scrollBar = horizontalScrollBar();
|
||||
m_cCurrScroll.setX( scrollBar->value() );
|
||||
scrollBar = verticalScrollBar();
|
||||
m_cCurrScroll.setY( scrollBar->value() );
|
||||
}
|
||||
|
||||
Void SubWindowAbstract::setCurScrollValues()
|
||||
{
|
||||
QScrollBar *scrollBar = horizontalScrollBar();
|
||||
scrollBar->setValue(m_cCurrScroll.x() );
|
||||
scrollBar = verticalScrollBar();
|
||||
scrollBar->setValue(m_cCurrScroll.y() );
|
||||
return;
|
||||
}
|
||||
|
||||
Void SubWindowAbstract::setWindowName( QString name )
|
||||
@@ -177,7 +87,7 @@ Bool SubWindowAbstract::mayClose()
|
||||
return true;
|
||||
}
|
||||
|
||||
QSize SubWindowAbstract::sizeHint( ) const
|
||||
QSize SubWindowAbstract::sizeHint() const
|
||||
{
|
||||
return QSize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user