Change zoom functions in order to simplify code across subwindows categories

This commit is contained in:
jfmcarreira committed 2014-12-12 03:11:17 +00:00
1 parent 59ab191d62
commit dc65087c9a
6 files changed
+59 -49

No files matched your search

+24 -11
View File
@@ -61,7 +61,9 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdi
m_pushButtonAdd = new QPushButton( "Add", this );
m_pushButtonAddAll = new QPushButton( "Add all", this );
m_pushButtonRemove = new QPushButton( "Remove", this );
m_pushButtonRemoveAll = new QPushButton( "Remove All", this );
m_pushButtonRemove->setEnabled( false );
m_pushButtonRemoveAll->setEnabled( false );
// Selected Sub Window List
m_listSelectedWindows = new QListWidget( this );
@@ -83,6 +85,7 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdi
RightVLayout->addWidget( m_pushButtonAdd );
RightVLayout->addWidget( m_pushButtonAddAll );
RightVLayout->addWidget( m_pushButtonRemove );
RightVLayout->addWidget( m_pushButtonRemoveAll );
RightVLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
RightVLayout->addWidget( m_pushButtonOkCancel );
@@ -99,28 +102,29 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdi
connect( m_pushButtonAdd, SIGNAL( clicked() ), this, SLOT( addSubWindow() ) );
connect( m_pushButtonAddAll, SIGNAL( clicked() ), this, SLOT( addAllSubWindow() ) );
connect( m_pushButtonRemove, SIGNAL( clicked() ), this, SLOT( removeSubWindow() ) );
connect( m_pushButtonRemoveAll, SIGNAL( clicked() ), this, SLOT( removeAllSubWindow() ) );
QMetaObject::connectSlotsByName( this );
// SubWindowHandle* activeSubWindow = qobject_cast<SubWindowHandle *>( m_pcMainWindowMdiArea->activeSubWindow() );
// if( activeSubWindow->getCategory() == SubWindowHandle::VIDEO_SUBWINDOW )
// {
// m_pcSelectedWindowListNames.append( activeSubWindow->getWindowName() );
// }
updateSubWindowList();
}
Void DialogSubWindowSelector::updateSubWindowList()
{
SubWindowHandle *subWindow;
VideoSubWindow *videoSubWindow;
QString currSubWindowName;
m_pcWindowListNames.clear();
for( Int i = 0; i < m_pcMainWindowMdiArea->subWindowList().size(); i++ )
QList<VideoSubWindow*> subWindowList = m_pcMainWindowMdiArea->findChildren<VideoSubWindow*>();
for( Int i = 0; i < subWindowList.size(); i++ )
{
subWindow = qobject_cast<SubWindowHandle *>( m_pcMainWindowMdiArea->subWindowList().at( i ) );
if( subWindow->getCategory() == SubWindowHandle::VIDEO_SUBWINDOW )
{
videoSubWindow = qobject_cast<VideoSubWindow *>( m_pcMainWindowMdiArea->subWindowList().at( i ) );
currSubWindowName = videoSubWindow->getWindowName();
if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !videoSubWindow->getIsModule() )
m_pcWindowListNames.append( currSubWindowName );
}
videoSubWindow = subWindowList.at( i );
currSubWindowName = videoSubWindow->getWindowName();
if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !videoSubWindow->getIsModule() )
m_pcWindowListNames.append( currSubWindowName );
}
m_comboBoxWindowList->clear();
m_comboBoxWindowList->insertItems( 0, m_pcWindowListNames );
@@ -148,10 +152,12 @@ Void DialogSubWindowSelector::updateSubWindowList()
if( m_pcSelectedWindowListNames.size() > 0 )
{
m_pushButtonRemove->setEnabled( true );
m_pushButtonRemoveAll->setEnabled( true );
}
else
{
m_pushButtonRemove->setEnabled( false );
m_pushButtonRemoveAll->setEnabled( false );
}
if( m_pcSelectedWindowListNames.size() >= m_iMinSelectedWindows )
@@ -219,7 +225,14 @@ Void DialogSubWindowSelector::removeSubWindow()
m_listSelectedWindows->insertItems( 0, m_pcSelectedWindowListNames );
updateSubWindowList();
}
}
Void DialogSubWindowSelector::removeAllSubWindow()
{
QList<QListWidgetItem*> selectedWindows = m_listSelectedWindows->selectedItems();
m_listSelectedWindows->clear();
m_pcSelectedWindowListNames.clear();
updateSubWindowList();
}
} // Namespace SCode
+2
View File
@@ -68,6 +68,7 @@ private:
QPushButton* m_pushButtonAdd;
QPushButton* m_pushButtonAddAll;
QPushButton* m_pushButtonRemove;
QPushButton* m_pushButtonRemoveAll;
QListWidget* m_listSelectedWindows;
Void updateSubWindowList();
@@ -76,6 +77,7 @@ private Q_SLOTS:
void addSubWindow();
void addAllSubWindow();
void removeSubWindow();
void removeAllSubWindow();
};
-15
View File
@@ -70,21 +70,6 @@ public:
*/
virtual Void scaleView( Double ) = 0;
/**
* The current image size is scaled to a rectangle as large as possible
* inside (@p width, @p height ) preserving the aspect ratio.
*/
virtual Void scaleView( Int, Int ) = 0;
/**
* This is an overloaded member function, provided for convenience.
* Scales the image to a rectangle with the given size, preserving the
* aspect ratio.
*/
virtual Void scaleView( const QSize & ) = 0;
virtual Void scaleViewByRatio( Double ) = 0;
virtual Double getScaleFactor() = 0;
Void setWindowName( QString );
+5 -15
View File
@@ -375,22 +375,10 @@ Void VideoSubWindow::zoomToFit()
scaleView( niceFit );
}
Void VideoSubWindow::scaleViewByRatio( Double ratio )
{
Q_ASSERT( m_cViewArea->image() );
m_cViewArea->zoomChangeEvent( ratio, QPoint() );
}
Void VideoSubWindow::scaleView( Double scale )
{
Q_ASSERT( m_cViewArea->image() );
m_cViewArea->setZoomFactor( scale );
updateLastScrollValue();
}
Void VideoSubWindow::scaleView( Int width, Int height )
{
scaleView( QSize( width, height ) );
m_cViewArea->zoomChangeEvent( scale, QPoint() );
}
Void VideoSubWindow::scaleView( const QSize & size )
@@ -411,9 +399,11 @@ Void VideoSubWindow::scaleView( const QSize & size )
hfactor = ( Double )newSize.height() / imgViewSize.height();
if( wfactor < hfactor )
scaleView( wfactor );
m_cViewArea->setZoomFactor( wfactor );
else
scaleView( hfactor );
m_cViewArea->setZoomFactor( hfactor );
updateLastScrollValue();
}
void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset )
+7 -2
View File
@@ -164,8 +164,7 @@ public:
Void normalSize();
Void zoomToFit();
Void scaleView( Double scale );
Void scaleView( Int width, Int height );
Void scaleView( const QSize & size );
Void scaleViewByRatio( Double ratio );
Double getScaleFactor()
{
@@ -188,6 +187,12 @@ public:
return m_bIsModule;
}
private:
/**
* Private zoom function to handle
* zoom to fit
*/
Void scaleView( const QSize & size );
protected:
void closeEvent( QCloseEvent *event );
+21 -6
View File
@@ -673,7 +673,6 @@ Void plaYUVerApp::videoSelectionButtonEvent()
m_acPlayingSubWindows.clear();
SubWindowHandle *subWindow;
QString windowName;
Double scaleFactor = qobject_cast<SubWindowHandle*>( mdiArea->subWindowList().at( 0 ) )->getScaleFactor();
for( Int i = 0; i < mdiArea->subWindowList().size(); i++ )
{
subWindow = qobject_cast<SubWindowHandle *>( mdiArea->subWindowList().at( i ) );
@@ -683,11 +682,27 @@ Void plaYUVerApp::videoSelectionButtonEvent()
VideoSubWindow* pcVideoSubWinodw = qobject_cast<VideoSubWindow*>( subWindow );
m_acPlayingSubWindows.append( pcVideoSubWinodw );
pcVideoSubWinodw->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() );
pcVideoSubWinodw->scaleView( scaleFactor );
}
}
m_acPlayingSubWindows.at( 0 )->activateWindow();
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( true );
if( m_acPlayingSubWindows.size() > 0 )
{
m_acPlayingSubWindows.at( 0 )->activateWindow();
if( m_acPlayingSubWindows.size() > 1 )
{
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( true );
}
if( m_bIsPlaying )
{
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
m_acPlayingSubWindows.at( i )->play();
}
}
}
else
{
stop();
}
return;
}
}
@@ -728,7 +743,7 @@ Void plaYUVerApp::scaleFrame( int ratio )
{
if( m_pcCurrentSubWindow )
{
m_pcCurrentSubWindow->scaleViewByRatio( ( Double )( ratio ) / 100.0 );
m_pcCurrentSubWindow->scaleView( ( Double )( ratio ) / 100.0 );
updateZoomFactorSBox();
}
}
@@ -740,7 +755,7 @@ Void plaYUVerApp::setZoomFromSBox( double zoom )
{
lastZoom = activeSubWindow()->getScaleFactor() * 100;
if( zoom / lastZoom != 1.0 )
activeSubWindow()->scaleViewByRatio( zoom / lastZoom );
activeSubWindow()->scaleView( zoom / lastZoom );
}
}