From a55893db93d99624be95fddea9016d4ce17c1ddc Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 9 Dec 2014 17:51:51 +0000 Subject: [PATCH 1/4] fix guessing format when file doesnt exist --- lib/PlaYUVerStream.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 33605be..dd815bc 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -362,17 +362,16 @@ Bool PlaYUVerStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, // Guess resolution by file size if( rWidth == 0 && rHeight == 0 ) { - Char *filename_char = new char[filename.length() + 1]; memcpy( filename_char, filename.toUtf8().constData(), filename.length() + 1 * sizeof(char) ); FILE* pF = fopen( filename_char, "rb" ); - fseek( pF, 0, SEEK_END ); - UInt64 uiFileSize = ftell( pF ); - fclose( pF ); - delete[] filename_char; - - if( pF != NULL ) + if( pF ) { + fseek( pF, 0, SEEK_END ); + UInt64 uiFileSize = ftell( pF ); + fclose( pF ); + delete[] filename_char; + Int count = 0, module, frame_bytes, match; QVector sizeResolution = standardResolutionSizes().sizeResolution; for( Int i = 0; i < sizeResolution.size(); i++ ) @@ -391,7 +390,6 @@ Bool PlaYUVerStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, rHeight = sizeResolution.at( match ).height(); } } - } if( rWidth > 0 && rHeight > 0 && rInputFormat >= 0 ) From fc5e4147f35de8435829f909e56924f5e7d813ee Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 9 Dec 2014 18:13:59 +0000 Subject: [PATCH 2/4] Change video lock read/write setting and add all sequences when it is enable. check if file exists before loading it --- app/Settings.cpp | 7 +------ app/Settings.h | 3 +-- app/plaYUVerApp.cpp | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/Settings.cpp b/app/Settings.cpp index f074854..cf8458f 100644 --- a/app/Settings.cpp +++ b/app/Settings.cpp @@ -93,14 +93,9 @@ Bool Settings::getRepeat() { return m_settings.value( "Playing/Repeat", false ).toBool(); } -Bool Settings::getVideoLock() -{ - return m_settings.value( "Playing/VideoLock", false ).toBool(); -} -Void Settings::setPlayingSettings( Bool repeat, Bool lock ) +Void Settings::setPlayingSettings( Bool repeat) { m_settings.setValue( "Playing/Repeat", repeat ); - m_settings.setValue( "Playing/VideoLock", lock ); } Void Settings::setRecentFileList( PlaYUVerStreamInfoVector recentFileList ) diff --git a/app/Settings.h b/app/Settings.h index be42efd..067e446 100644 --- a/app/Settings.h +++ b/app/Settings.h @@ -54,8 +54,7 @@ public: Void setSelectedTool( Int); Bool getRepeat(); - Bool getVideoLock(); - Void setPlayingSettings( Bool repeat, Bool lock ); + Void setPlayingSettings( Bool repeat ); Void setDockVisibility( Bool statusStreamProperties, Bool statusFrameProperties, Bool statusQualityMeasurement ); Void getDockVisibility( Bool& statusStreamProperties, Bool& statusFrameProperties, Bool& statusQualityMeasurement ); diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 5ace669..b10b662 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -155,6 +155,11 @@ Void plaYUVerApp::closeEvent( QCloseEvent *event ) Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) { + if( !QFileInfo( fileName ).exists() ) + { + statusBar()->showMessage( "File do not exists!" ); + } + SubWindowHandle *interfaceChild = plaYUVerApp::findSubWindow( mdiArea, fileName ); if( interfaceChild ) { @@ -637,6 +642,7 @@ Void plaYUVerApp::stop() } } m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); + m_arrayActions[VIDEO_LOCK_ACT]->setChecked( false ); updateTotalFrameNum(); } @@ -763,6 +769,14 @@ Void plaYUVerApp::lockButtonEvent() { if( m_acPlayingSubWindows.size() > 1 ) m_acPlayingSubWindows.clear(); + + SubWindowHandle *subWindow; + for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) + { + subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); + if( !subWindow->getIsModule() ) + m_acPlayingSubWindows.append( subWindow ); + } } } updateCurrFrameNum(); @@ -1511,7 +1525,7 @@ Void plaYUVerApp::readSettings() //m_appTool = ( ViewArea::eTool )settings.getSelectedTool(); //setAllSubWindowTool(); m_arrayActions[VIDEO_LOOP_ACT]->setChecked( settings.getRepeat() ); - m_arrayActions[VIDEO_LOCK_ACT]->setChecked( settings.getVideoLock() ); + m_arrayActions[VIDEO_LOCK_ACT]->setChecked( false ); m_aRecentFileStreamInfo = settings.getRecentFileList(); updateRecentFileActions(); @@ -1536,7 +1550,7 @@ Void plaYUVerApp::writeSettings() settings.setSelectedTool( ( Int )m_appTool ); settings.setRecentFileList( m_aRecentFileStreamInfo ); settings.setDockVisibility( m_pcStreamProperties->isVisible(), m_pcFrameProperties->isVisible(), m_pcQualityMeasurement->isVisible() ); - settings.setPlayingSettings( m_arrayActions[VIDEO_LOOP_ACT]->isChecked(), m_arrayActions[VIDEO_LOCK_ACT]->isChecked() ); + settings.setPlayingSettings( m_arrayActions[VIDEO_LOOP_ACT]->isChecked() ); } } // NAMESPACE From 43eaa4fa8e6a6968d298a9c25d7c1f6939eb0e6d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 9 Dec 2014 18:54:40 +0000 Subject: [PATCH 3/4] Change video lock button --- app/SubWindowHandle.cpp | 6 +++--- app/plaYUVerApp.cpp | 27 +++++++++++++-------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index 6cae3eb..578155f 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -128,9 +128,9 @@ Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog ) Int InputFormat = -1; if( !m_pCurrStream ) - { - m_pCurrStream = new PlaYUVerStream; - } + { + m_pCurrStream = new PlaYUVerStream; + } m_pCurrStream->getFormat( Width, Height, InputFormat, FrameRate ); diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index b10b662..565e68a 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -758,27 +758,26 @@ Void plaYUVerApp::seekSliderEvent( Int new_frame_num ) Void plaYUVerApp::lockButtonEvent() { - if( !m_arrayActions[VIDEO_LOCK_ACT]->isChecked() ) + if( m_arrayActions[VIDEO_LOCK_ACT]->isChecked() ) { - if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) - { + if( m_acPlayingSubWindows.size() > 1 ) m_acPlayingSubWindows.clear(); - m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); - } - else - { - if( m_acPlayingSubWindows.size() > 1 ) - m_acPlayingSubWindows.clear(); - SubWindowHandle *subWindow; - for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) + SubWindowHandle *subWindow; + for( Int i = 0; i < mdiArea->subWindowList().size(); i++ ) + { + subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); + if( !subWindow->getIsModule() ) { - subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); - if( !subWindow->getIsModule() ) - m_acPlayingSubWindows.append( subWindow ); + m_acPlayingSubWindows.append( subWindow ); + m_pcFrameSlider->setMaximum( qMin( m_pcFrameSlider->maximum(), ( Int )subWindow->getInputStream()->getFrameNum() - 1 ) ); } } } + else + { + stop(); + } updateCurrFrameNum(); updateTotalFrameNum(); } From 5510355f95d22d34b851496832ae6a86cf9f4085 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 9 Dec 2014 19:24:00 +0000 Subject: [PATCH 4/4] Always save last open path when load a file --- app/plaYUVerApp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 565e68a..c57a537 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -206,6 +206,7 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) updateRecentFileActions(); statusBar()->showMessage( tr( "File loaded" ), 2000 ); + m_cLastOpenPath = QFileInfo( fileName ).path(); } else { @@ -255,7 +256,6 @@ Void plaYUVerApp::open() { if( !fileNameList.at( i ).isEmpty() ) { - m_cLastOpenPath = QFileInfo( fileNameList.at( i ) ).path(); loadFile( fileNameList.at( i ) ); } }