diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index b8b2d3a..acbaeb6 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -322,26 +322,35 @@ void plaYUVerApp::pause() { m_pcCurrentSubWindow->pause(); } - m_pcFrameSlider->setValue( m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() ); + updateCurrFrameNum(); } setTimerStatus(); } void plaYUVerApp::stop() { + if( m_acPlayingSubWindows.size() > 0 ) + { for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { m_acPlayingSubWindows.at( i )->stop(); } m_acPlayingSubWindows.clear(); setTimerStatus(); - m_pcFrameSlider->setValue( m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() ); - + updateCurrFrameNum(); if( m_uiAveragePlayInterval ) qDebug( ) << "Real display time: " << QString::number( 1000 / m_uiAveragePlayInterval ) << " fps"; m_uiAveragePlayInterval = 0; + } + else + { + if( m_pcCurrentSubWindow ) + { + seekSliderEvent( 0 ); + } + } } void plaYUVerApp::playEvent() @@ -354,13 +363,13 @@ void plaYUVerApp::playEvent() { case -1: stop(); - m_pcFrameSlider->setValue( m_pcCurrentSubWindow ? m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() : 0 ); + updateCurrFrameNum(); break; case -2: if( !actionVideoLoop->isChecked() ) { stop(); - m_pcFrameSlider->setValue( m_pcCurrentSubWindow ? m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() : 0 ); + updateCurrFrameNum(); return; } break; @@ -374,12 +383,29 @@ void plaYUVerApp::playEvent() break; } } - if( m_pcCurrentSubWindow ) - m_pcFrameSlider->setValue( m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() ); - + updateCurrFrameNum(); m_uiAveragePlayInterval = ( m_uiAveragePlayInterval + time ) / 2; } +Void plaYUVerApp::updateCurrFrameNum() +{ + if( m_pcCurrentSubWindow ) + { + Int frame_num = m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum(); + m_pcFrameSlider->setValue( frame_num ); + m_pcCurrFrameNumLabel->setText( QString( tr( "%1" ) ).arg( frame_num ) ); + } +} +Void plaYUVerApp::updateTotalFrameNum( UInt total_frame_num ) +{ + if( m_pcCurrentSubWindow && total_frame_num == 0 ) + { + total_frame_num = m_pcCurrentSubWindow->getInputStream()->getFrameNum(); + } + m_pcFrameSlider->setMaximum( total_frame_num - 1 ); + m_pcTotalFrameNumLabel->setText( QString( tr( "%1" ) ).arg( total_frame_num ) ); +} + void plaYUVerApp::seekEvent( int direction ) { if( m_pcCurrentSubWindow ) @@ -394,8 +420,9 @@ void plaYUVerApp::seekEvent( int direction ) else { m_pcCurrentSubWindow->seekRelativeEvent( direction > 0 ? true : false ); - m_pcFrameSlider->setValue( m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() ); + } + updateCurrFrameNum(); } } @@ -413,8 +440,8 @@ void plaYUVerApp::seekSliderEvent( int new_frame_num ) else { m_pcCurrentSubWindow->seekAbsoluteEvent( ( UInt )new_frame_num ); - m_pcFrameSlider->setValue( m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() ); } + updateCurrFrameNum(); } } @@ -476,9 +503,10 @@ void plaYUVerApp::chageSubWindowSelection() // { // playingTimer->stop(); // } - m_pcFrameSlider->setMaximum( activeSubWindow()->getInputStream()->getFrameNum() - 1 ); - m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); m_pcCurrentSubWindow = activeSubWindow(); + updateCurrFrameNum(); + updateTotalFrameNum(); + m_pcCurrFrameNumLabel->setText( QString( tr( "%1" ) ).arg( m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() ) ); updateProperties(); } else @@ -615,8 +643,9 @@ Void plaYUVerApp::updateMenus() if( !hasSubWindow ) { m_pcFrameSlider->setValue( 0 ); + m_pcCurrFrameNumLabel->setText("-"); + m_pcTotalFrameNumLabel->setText("-"); } - actionNavigationTool->setEnabled( hasSubWindow ); actionSelectionTool->setEnabled( hasSubWindow ); @@ -920,7 +949,16 @@ Void plaYUVerApp::createToolBars() toolbarVideo->addAction( actionVideoCenter ); */ toolbarVideo->addWidget( m_pcFrameSlider ); - + toolbarVideo->addWidget( new QLabel ); + m_pcCurrFrameNumLabel = new QLabel; + m_pcCurrFrameNumLabel->setText("-"); + toolbarVideo->addWidget( m_pcCurrFrameNumLabel ); + QLabel *forwardslash = new QLabel; + forwardslash->setText("/"); + toolbarVideo->addWidget( forwardslash ); + m_pcTotalFrameNumLabel = new QLabel; + m_pcTotalFrameNumLabel->setText("-"); + toolbarVideo->addWidget( m_pcTotalFrameNumLabel ); } Void plaYUVerApp::createDockWidgets() diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index 2fd311c..52bea4b 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -116,6 +116,8 @@ private: Void loadFile( QString fileName ); //! Playing functions Void setTimerStatus(); + Void updateCurrFrameNum(); + Void updateTotalFrameNum( UInt total_frame_num = 0 ); Void updateMenus(); Void updateProperties(); @@ -135,6 +137,8 @@ private: Bool m_bIsPlaying; QVector m_acPlayingSubWindows; QSlider *m_pcFrameSlider; + QLabel *m_pcCurrFrameNumLabel; + QLabel *m_pcTotalFrameNumLabel; QSignalMapper *mapperZoom;