diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 4d21efe..7a1d06f 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -47,6 +47,7 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) : m_cScrollArea->setWidget( m_cViewArea ); m_cWindowName = QString( " " ); + m_bIsPlaying = true; m_dScaleFactor = 1; } @@ -93,7 +94,7 @@ bool SubWindowHandle::loadFile( const QString &fileName ) normalSize(); - m_cWindowName = QString("ola"); + m_cWindowName = QString( "ola" ); m_cWindowName = m_currStream.getStreamInformationString(); m_cCurrFileName = fileName; @@ -133,23 +134,35 @@ bool SubWindowHandle::save() return true; } -bool SubWindowHandle::playEvent() +int SubWindowHandle::playEvent() { - m_currStream.readFrame(); - if( m_currStream.checkErrors( READING ) ) - { - QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_cCurrFileName ) ); - return false; - } - else if( m_currStream.checkErrors( END_OF_SEQ ) ) + if( m_bIsPlaying ) { + m_currStream.readFrame(); + if( m_currStream.checkErrors( READING ) ) + { + QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_cCurrFileName ) ); + return false; + } + else if( m_currStream.checkErrors( END_OF_SEQ ) ) + { + m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) ); + return false; + } m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) ); - return false; } - m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) ); return true; } +Void SubWindowHandle::stopEvent() +{ + m_currStream.seekInput( 0 ); + m_currStream.readFrame(); + m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) ); + return; +} + + Void SubWindowHandle::normalSize() { m_dScaleFactor = 1.0; diff --git a/source/SubWindowHandle.h b/source/SubWindowHandle.h index 2b3a0c6..174eac5 100644 --- a/source/SubWindowHandle.h +++ b/source/SubWindowHandle.h @@ -57,6 +57,8 @@ private: Double m_dScaleFactor; + Bool m_bIsPlaying; + public: SubWindowHandle( QWidget * parent = 0 ); ~SubWindowHandle(); @@ -64,7 +66,7 @@ public: bool loadFile( const QString &fileName ); bool save(); - bool playEvent(); + Void stopEvent(); InputStream* getInputStream() { @@ -124,8 +126,8 @@ public: protected: Void closeEvent( QCloseEvent *event ); -private Q_SLOTS: - +public Q_SLOTS: + int playEvent(); }; } // NAMESPACE diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index ba4feac..6f9f453 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -68,8 +68,6 @@ plaYUVerApp::plaYUVerApp() setAcceptDrops( true ); mdiArea->setAcceptDrops( true ); - connect( playingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) ); - } Void plaYUVerApp::closeEvent( QCloseEvent *event ) @@ -136,14 +134,14 @@ void plaYUVerApp::save() void plaYUVerApp::play() { - UInt frameRate; - UInt timeInterval; - - frameRate = activeSubWindow()->getInputStream()->getFrameRate(); - timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 ); - - playingTimer->start( timeInterval ); - + if( activeSubWindow() ) + { + UInt frameRate = activeSubWindow()->getInputStream()->getFrameRate(); + UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 ); + playingTimer->start( timeInterval ); + //connect( playingTimer, SIGNAL( timeout() ), activeSubWindow(), SLOT( playEvent() ) ); + connect( playingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) ); + } } void plaYUVerApp::pause() @@ -153,6 +151,10 @@ void plaYUVerApp::pause() void plaYUVerApp::stop() { + if( activeSubWindow() ) + { + activeSubWindow()->stopEvent(); + } playingTimer->stop(); //disconnect( playingTimer, SIGNAL( timeout() ), 0, 0 ); } @@ -251,7 +253,7 @@ void plaYUVerApp::updateWindowMenu() if( number_windows > 1 ) { actionNext->setEnabled( true ); - actionPrevious->setEnabled( true ); + actionPrevious->setEnabled( true ); } else {