From fda381131ccdadd59744b6c72224a3cf3faf9b4e Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 4 Oct 2014 15:12:58 +0100 Subject: [PATCH] Use previous saved stream open to open recent files --- source/app/SubWindowHandle.cpp | 39 ++++++++++++++++++++++++++++------ source/app/SubWindowHandle.h | 4 +++- source/app/plaYUVerApp.cpp | 12 +++++++---- source/app/plaYUVerApp.h | 2 +- 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index cea7865..63eb89c 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -36,8 +36,8 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array for( Int i = 0; i < array.size(); i++ ) { d = array.at( i ); - out << d.m_cFilename << d.m_cResolution.width() - << d.m_cResolution.height() + out << d.m_cFilename << d.m_uiWidth + << d.m_uiHeight << d.m_iPelFormat << d.m_uiFrameRate; @@ -53,12 +53,10 @@ QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& array ) for( Int i = 0; i < array_size; i++ ) { in >> d.m_cFilename; - Int x, y; - in >> x; - in >> y; + in >> d.m_uiWidth; + in >> d.m_uiHeight; in >> d.m_iPelFormat; in >> d.m_uiFrameRate; - d.m_cResolution = QSize( x, y ); array.append( d ); } return in; @@ -148,7 +146,8 @@ Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog ) refreshFrame(); m_sStreamInfo.m_cFilename = cFilename; - m_sStreamInfo.m_cResolution = QSize( Width, Height ); + m_sStreamInfo.m_uiWidth = Width; + m_sStreamInfo.m_uiHeight = Height; m_sStreamInfo.m_iPelFormat = InputFormat; m_sStreamInfo.m_uiFrameRate = FrameRate; @@ -158,6 +157,32 @@ Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog ) return true; } +Bool SubWindowHandle::loadFile( PlaYUVerStreamInfo* streamInfo ) +{ + if( !m_pCurrStream ) + { + m_pCurrStream = new PlaYUVerStream; + } + m_sStreamInfo = *streamInfo; + + if( !m_pCurrStream->open( m_sStreamInfo.m_cFilename, m_sStreamInfo.m_uiWidth, m_sStreamInfo.m_uiHeight, m_sStreamInfo.m_iPelFormat, + m_sStreamInfo.m_uiFrameRate ) ) + { + return false; + } + + m_cViewArea->setInputStream( m_pCurrStream ); + + QApplication::restoreOverrideCursor(); + + refreshFrame(); + + m_cWindowName = m_pCurrStream->getStreamInformationString(); + m_cWindowShortName = QFileInfo( m_sStreamInfo.m_cFilename ).fileName(); + setWindowTitle( m_cWindowName ); + return true; +} + /** * Functions to enable a module in the * current SubWindow diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index 0cc40fc..6f375c9 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -44,7 +44,8 @@ class SubWindowHandle; typedef struct { QString m_cFilename; - QSize m_cResolution; + UInt m_uiWidth; + UInt m_uiHeight; Int m_iPelFormat; UInt m_uiFrameRate; }PlaYUVerStreamInfo; @@ -88,6 +89,7 @@ public: Bool mayClose(); Bool loadFile( QString cFilename, Bool bForceDialog = false ); + Bool loadFile( PlaYUVerStreamInfo* streamInfo ); Void reloadFile(); Bool save( QString filename ); diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index ea84234..3dee403 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -156,7 +156,7 @@ Void plaYUVerApp::closeEvent( QCloseEvent *event ) } } -Void plaYUVerApp::loadFile( QString fileName ) +Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* streamInfo ) { SubWindowHandle *interfaceChild = plaYUVerApp::findSubWindow( mdiArea, fileName ); if( interfaceChild ) @@ -164,9 +164,13 @@ Void plaYUVerApp::loadFile( QString fileName ) mdiArea->setActiveSubWindow( interfaceChild ); return; } - interfaceChild = new SubWindowHandle( this ); //createSubWindow(); - if( interfaceChild->loadFile( fileName ) ) + Bool retChild = false; + if( !streamInfo ) + retChild = interfaceChild->loadFile( fileName ); + else + retChild = interfaceChild->loadFile( streamInfo ); + if(retChild ) { statusBar()->showMessage( tr( "Loading file..." ) ); mdiArea->addSubWindow( interfaceChild ); @@ -237,7 +241,7 @@ Void plaYUVerApp::openRecent() QAction *action = qobject_cast( sender() ); PlaYUVerStreamInfo recentFile = action->data().value(); if( action ) - loadFile( recentFile.m_cFilename ); + loadFile( recentFile.m_cFilename, &recentFile ); } Void plaYUVerApp::save() diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index d82a8d3..3f7c284 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -153,7 +153,7 @@ private: QTime m_cTimer; UInt m_uiAveragePlayInterval; - Void loadFile( QString fileName ); + Void loadFile( QString fileName, PlaYUVerStreamInfo* streamInfo = NULL ); Void readRecentFileList(); Void writeRecentFileList();