From bfa649d5e6dff5bc5d36c8f935439176f78706e3 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 6 Jul 2014 03:18:31 +0100 Subject: [PATCH] Add a new struct to include the stream info and save it in qsettings --- source/app/PlaYUVerSettings.cpp | 13 +++++++++++++ source/app/PlaYUVerSettings.h | 5 +++++ source/app/SubWindowHandle.cpp | 10 +++++++--- source/app/SubWindowHandle.h | 25 +++++++++++++++++++++++-- source/app/main.cpp | 4 ++++ source/app/plaYUVerApp.cpp | 9 +++++++-- source/app/plaYUVerApp.h | 12 +++++++++++- 7 files changed, 70 insertions(+), 8 deletions(-) diff --git a/source/app/PlaYUVerSettings.cpp b/source/app/PlaYUVerSettings.cpp index f1cab01..f4745ab 100644 --- a/source/app/PlaYUVerSettings.cpp +++ b/source/app/PlaYUVerSettings.cpp @@ -103,6 +103,19 @@ Void PlaYUVerSettings::setPlayingSettings( Bool repeat, Bool lock ) m_settings.setValue( "Playing/VideoLock", lock ); } +Void PlaYUVerSettings::setRecentFileList( PlaYUVerRecentFileListInfo recentFileList ) +{ + QVariant var; + var.setValue( recentFileList ); + m_settings.setValue("MainWindow/RecentFileList", var ); +} + +PlaYUVerRecentFileListInfo PlaYUVerSettings::getRecentFileList() +{ + QVariant value = m_settings.value("MainWindow/RecentFileList"); + return value.value(); +} + // - - - - - - - - - - - - - - Grid Settings - - - - - - - - - - - - - - - - - - GridManager::Style PlaYUVerSettings::gridStyle() diff --git a/source/app/PlaYUVerSettings.h b/source/app/PlaYUVerSettings.h index 58fe9b9..3f20953 100644 --- a/source/app/PlaYUVerSettings.h +++ b/source/app/PlaYUVerSettings.h @@ -29,6 +29,7 @@ #include "PlaYUVerDefs.h" #include #include "GridManager.h" +#include "SubWindowHandle.h" namespace plaYUVer { @@ -59,6 +60,10 @@ public: Void setDockVisibility( Bool statusStreamProperties, Bool statusFrameProperties, Bool statusQualityMeasurement ); Void getDockVisibility( Bool& statusStreamProperties, Bool& statusFrameProperties, Bool& statusQualityMeasurement ); + // - - - - - - - - - - Recent Files Settings - - - - - - - - - - - - - + Void setRecentFileList( PlaYUVerRecentFileListInfo ); + PlaYUVerRecentFileListInfo getRecentFileList(); + // - - - - - - - - - - - - Grid Settings - - - - - - - - - - - - - - - GridManager::Style gridStyle(); Void setGridStyle( GridManager::Style v ); diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index be6cec4..0979b0b 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -75,7 +75,7 @@ SubWindowHandle::~SubWindowHandle() Void SubWindowHandle::reloadFile() { Int currFrameNum = m_pCurrStream->getCurrFrameNum(); - loadFile( m_cCurrFileName, false ); + loadFile( m_sStreamInfo.m_cFilename, false ); seekAbsoluteEvent( currFrameNum ); } @@ -112,7 +112,11 @@ Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog ) refreshFrame(); - m_cCurrFileName = cFilename; + m_sStreamInfo.m_cFilename = cFilename; + m_sStreamInfo.m_cResolution = QSize( Width, Height); + m_sStreamInfo.m_iPelFormat = InputFormat; + m_sStreamInfo.m_uiFrameRate = FrameRate; + m_cWindowName = m_pCurrStream->getStreamInformationString(); setWindowTitle( m_cWindowName ); return true; @@ -233,7 +237,7 @@ Int SubWindowHandle::playEvent() m_pCurrStream->readFrame(); if( m_pCurrStream->checkErrors( PlaYUVerStream::READING ) ) { - QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_cCurrFileName ) ); + QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_sStreamInfo.m_cFilename ) ); return -3; } return 0; diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index 1111be2..6ba8b5b 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -38,8 +38,21 @@ namespace plaYUVer { + class SubWindowHandle; +struct structPlaYUVERStreamInfo +{ + QString m_cFilename; + QSize m_cResolution; + Int m_iPelFormat; + UInt m_uiFrameRate; +}; + +//typedef QVector PlaYUVerRecentFileListInfo; +typedef struct structPlaYUVERStreamInfo PlaYUVerRecentFileListInfo; +typedef struct structPlaYUVERStreamInfo PlaYUVerStreamInfo; + class SubWindowHandle: public QMdiSubWindow { Q_OBJECT @@ -49,6 +62,8 @@ private: QScrollArea* m_cScrollArea; ViewArea* m_cViewArea; + PlaYUVerStreamInfo m_sStreamInfo; + PlaYUVerStream* m_pCurrStream; PlaYUVerFrame* m_pcCurrFrame; @@ -57,7 +72,6 @@ private: SubWindowHandle* m_pcReferenceSubWindow; QString m_cWindowName; - QString m_cCurrFileName; Bool m_bIsPlaying; Bool m_bIsModule; @@ -91,6 +105,11 @@ public: Void refreshFrame(); Void setCurrFrame( PlaYUVerFrame* pcCurrFrame ); + PlaYUVerStreamInfo getStreamInfo() + { + return m_sStreamInfo; + } + PlaYUVerStream* getInputStream() { return m_pCurrStream; @@ -191,7 +210,7 @@ public: QString currentFile() { - return m_cCurrFileName; + return m_sStreamInfo.m_cFilename; } Bool getIsModule() @@ -210,4 +229,6 @@ public Q_SLOTS: } // NAMESPACE +Q_DECLARE_METATYPE(plaYUVer::PlaYUVerRecentFileListInfo); + #endif // __SUBWINDOWHANDLE_H__ diff --git a/source/app/main.cpp b/source/app/main.cpp index 157e985..a973489 100644 --- a/source/app/main.cpp +++ b/source/app/main.cpp @@ -24,6 +24,7 @@ #include #include "plaYUVerApp.h" +#include "SubWindowHandle.h" #ifdef USE_FERVOR #include "fvupdater.h" #endif @@ -36,6 +37,9 @@ int main( int argc, char *argv[] ) QApplication::setApplicationVersion("PLAYUVER_VERSION"); QApplication::setOrganizationName("pixlra"); QApplication::setOrganizationDomain("playuver.pixlra"); + + qRegisterMetaType("PlaYUVerRecentFileListInfo"); + plaYUVerApp w; w.show(); w.parseArgs( argc, argv ); diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 0bb3359..e2ef8b5 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -23,7 +23,6 @@ */ #include "plaYUVerApp.h" -#include "SubWindowHandle.h" #include "PlaYUVerStream.h" #include "DialogSubWindowSelector.h" #ifdef USE_FERVOR @@ -176,6 +175,8 @@ Void plaYUVerApp::loadFile( QString fileName ) interfaceChild->zoomToFit(); interfaceChild->getViewArea()->setTool( m_appTool ); updateZoomFactorSBox(); + //m_aRecentFileStreamInfo.append( interfaceChild->getStreamInfo() ); + m_aRecentFileStreamInfo = interfaceChild->getStreamInfo(); statusBar()->showMessage( tr( "File loaded" ), 2000 ); } else @@ -658,7 +659,7 @@ Void plaYUVerApp::lockButtonEvent() if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) { m_acPlayingSubWindows.clear(); - m_acPlayingSubWindows.append(m_pcCurrentSubWindow); + m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); } else { @@ -1372,6 +1373,9 @@ Void plaYUVerApp::readSettings() setAllSubWindowTool(); m_arrayActions[VIDEO_LOOP_ACT]->setChecked( settings.getRepeat() ); m_arrayActions[VIDEO_LOCK_ACT]->setChecked( settings.getVideoLock() ); + + m_aRecentFileStreamInfo = settings.getRecentFileList(); + Bool visibleStreamProp, visibleFrameProp, visibleQualityMeasure; settings.getDockVisibility( visibleStreamProp, visibleFrameProp, visibleQualityMeasure ); if( !visibleStreamProp ) @@ -1390,6 +1394,7 @@ Void plaYUVerApp::writeSettings() settings.setMainWindowSize( size() ); settings.setLastOpenPath( m_cLastOpenPath ); 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() ); } diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index 845da77..a7e7c1b 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -33,6 +33,7 @@ #include #endif #include +#include "SubWindowHandle.h" #include "ModulesHandle.h" #include "PropertiesSidebar.h" #include "QualityMeasurementSidebar.h" @@ -40,7 +41,6 @@ namespace plaYUVer { -class SubWindowHandle; class PlaYUVerStream; class plaYUVerApp: public QMainWindow @@ -51,6 +51,11 @@ public: plaYUVerApp(); Void parseArgs( Int argc, Char *argv[] ); + enum RecentFileList + { + MAXRECENTFILES, + }; + protected: Void closeEvent( QCloseEvent *event ); @@ -125,6 +130,9 @@ private: Void loadFile( QString fileName ); + Void readRecentFileList(); + Void writeRecentFileList(); + Void zoomToFitAll(); //! Playing functions @@ -249,6 +257,8 @@ private: QAction *actionSelectionTool; enum eTool m_appTool; + PlaYUVerRecentFileListInfo m_aRecentFileStreamInfo; + }; } // NAMESPACE