diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index b31b0a3..13dc94a 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -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( 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 subWindowList = m_pcMainWindowMdiArea->findChildren(); + for( Int i = 0; i < subWindowList.size(); i++ ) { - subWindow = qobject_cast( m_pcMainWindowMdiArea->subWindowList().at( i ) ); - if( subWindow->getCategory() == SubWindowHandle::VIDEO_SUBWINDOW ) - { - videoSubWindow = qobject_cast( 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 selectedWindows = m_listSelectedWindows->selectedItems(); + m_listSelectedWindows->clear(); + m_pcSelectedWindowListNames.clear(); + updateSubWindowList(); } } // Namespace SCode diff --git a/app/DialogSubWindowSelector.h b/app/DialogSubWindowSelector.h index 8eaab1a..f7cc093 100644 --- a/app/DialogSubWindowSelector.h +++ b/app/DialogSubWindowSelector.h @@ -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(); }; diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 011d4d0..7390e60 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -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 ); diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index dc38379..ce00285 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -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 ) diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index ed5803a..9c30590 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -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 ); diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 4af09e8..3e3fc25 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -673,7 +673,6 @@ Void plaYUVerApp::videoSelectionButtonEvent() m_acPlayingSubWindows.clear(); SubWindowHandle *subWindow; QString windowName; - Double scaleFactor = qobject_cast( mdiArea->subWindowList().at( 0 ) )->getScaleFactor(); for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) { subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); @@ -683,11 +682,27 @@ Void plaYUVerApp::videoSelectionButtonEvent() VideoSubWindow* pcVideoSubWinodw = qobject_cast( 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 ); } }