From bc5258a94d91055db0cdfde62459a43fc2431edd Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 5 Jan 2018 17:27:16 +0000 Subject: [PATCH] Start implementation of a method to save the entire stream --- app/PlaYUVerApp.cpp | 38 ++++++++++++++++++++++++++++++++++++-- app/PlaYUVerApp.h | 4 +++- app/VideoSubWindow.cpp | 10 ++++++++++ app/VideoSubWindow.h | 1 + 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 0121d6a..6668394 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -312,7 +312,34 @@ Void PlaYUVerApp::openRecent() loadFile( recentFile.m_cFilename, &recentFile ); } -Void PlaYUVerApp::save() +Void PlaYUVerApp::saveFrame() +{ + if( m_pcCurrentVideoSubWindow ) + { + VideoSubWindow* saveWindow = m_pcCurrentVideoSubWindow; + + QStringList fileNames = showFileDialog( false ); + if( fileNames.size() == 1 ) + { + QString fileName = fileNames[0]; + m_cLastOpenPath = QFileInfo( fileName ).path(); + try + { + saveWindow->save( fileName ); + } + catch( PlaYUVerFailure& e ) + { + QApplication::restoreOverrideCursor(); + QString warningMsg = "Cannot save file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + e.what(); + QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); + printMessage( warningMsg, LOG_ERROR ); + return; + } + } + } +} + +Void PlaYUVerApp::saveStream() { if( m_pcCurrentVideoSubWindow ) { @@ -612,7 +639,13 @@ Void PlaYUVerApp::createActions() m_arrayActions[SAVE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogSaveButton ) ); m_arrayActions[SAVE_ACT]->setShortcuts( QKeySequence::SaveAs ); m_arrayActions[SAVE_ACT]->setStatusTip( tr( "Save current frame" ) ); - connect( m_arrayActions[SAVE_ACT], SIGNAL( triggered() ), this, SLOT( save() ) ); + connect( m_arrayActions[SAVE_ACT], SIGNAL( triggered() ), this, SLOT( saveFrame() ) ); + + m_arrayActions[SAVE_STREAM_ACT] = new QAction( QIcon( ":/images/save.png" ), tr( "&Save Stream" ), this ); + m_arrayActions[SAVE_STREAM_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogSaveButton ) ); + m_arrayActions[SAVE_STREAM_ACT]->setShortcuts( QKeySequence::SaveAs ); + m_arrayActions[SAVE_STREAM_ACT]->setStatusTip( tr( "Save current stream" ) ); + connect( m_arrayActions[SAVE_ACT], SIGNAL( triggered() ), this, SLOT( saveStream() ) ); m_arrayActions[FORMAT_ACT] = new QAction( tr( "&Format" ), this ); m_arrayActions[FORMAT_ACT]->setIcon( QIcon::fromTheme( "transform-scale", QIcon( ":/images/configuredialog.png" ) ) ); @@ -722,6 +755,7 @@ Void PlaYUVerApp::createMenus() } m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[SAVE_ACT] ); + // m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[SAVE_STREAM_ACT] ); m_arrayMenu[FILE_MENU]->addSeparator(); m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[FORMAT_ACT] ); m_arrayMenu[FILE_MENU]->addAction( m_arrayActions[RELOAD_ACT] ); diff --git a/app/PlaYUVerApp.h b/app/PlaYUVerApp.h index aeae7d2..e4d46fa 100644 --- a/app/PlaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -91,7 +91,8 @@ private Q_SLOTS: void open(); // void openDevice(); void openRecent(); - void save(); + void saveFrame(); + void saveStream(); void format(); void reload(); void reloadAll(); @@ -210,6 +211,7 @@ private: OPEN_ACT = 0, OPEN_DEVICE_ACT, SAVE_ACT, + SAVE_STREAM_ACT, FORMAT_ACT, RELOAD_ACT, RELOAD_ALL_ACT, diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 1c8f290..659710f 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -700,6 +700,16 @@ Bool VideoSubWindow::save( QString filename ) return iRet; } +Bool VideoSubWindow::saveStream( QString filename ) +{ + Bool iRet = false; + QApplication::setOverrideCursor( Qt::WaitCursor ); + + // TODO: implement this + QApplication::restoreOverrideCursor(); + return iRet; +} + Bool VideoSubWindow::play() { if( m_pCurrStream && m_pCurrStream->getFrameNum() > 1 ) diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index cbc5611..47d2db0 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -113,6 +113,7 @@ public: Bool loadFile( PlaYUVerStreamInfo* streamInfo ); Void loadAll(); Bool save( QString filename ); + Bool saveStream( QString filename ); Void refreshSubWindow(); Void refreshFrame( Bool bThreaded = false );