From 1d1602c7d7a8c62607628b87719f9039a0f5401e Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 8 Feb 2014 03:15:01 +0000 Subject: [PATCH] All a slide into the MainWindow toolbar --- source/InputStream.cpp | 2 +- source/SubWindowHandle.cpp | 8 +++++ source/SubWindowHandle.h | 1 + source/plaYUVerApp.cpp | 67 +++++++++++++++++++++++++------------- source/plaYUVerApp.h | 2 +- 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/source/InputStream.cpp b/source/InputStream.cpp index 1a0cef5..9e7c478 100755 --- a/source/InputStream.cpp +++ b/source/InputStream.cpp @@ -291,7 +291,7 @@ Void InputStream::seekInput( Int new_frame_num ) UInt64 frame_bytes_input = m_uiWidth * m_uiHeight * 1.5; UInt64 nbytes_seek = frame_bytes_input * new_frame_num; fseek( m_pFile, nbytes_seek, SEEK_SET ); - m_iCurrFrameNum = new_frame_num; + m_iCurrFrameNum = new_frame_num - 1; } } diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index e997343..9ea4ca6 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -161,6 +161,14 @@ bool SubWindowHandle::playEvent() return false; } +Void SubWindowHandle::seekEvent( UInt new_frame_num ) +{ + m_pCurrStream->seekInput( new_frame_num ); + m_pCurrStream->readFrame(); + m_pCurrStream->getFrame( m_pCurrFrameQImage ); + m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); +} + Void SubWindowHandle::stopEvent() { m_pCurrStream->seekInput( 0 ); diff --git a/source/SubWindowHandle.h b/source/SubWindowHandle.h index 91745d1..e92233b 100644 --- a/source/SubWindowHandle.h +++ b/source/SubWindowHandle.h @@ -68,6 +68,7 @@ public: bool save(); Void stopEvent(); + Void seekEvent( UInt new_frame_num ); InputStream* getInputStream() { diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 7886aa7..53580c5 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -152,8 +152,8 @@ void plaYUVerApp::pause() void plaYUVerApp::stop() { activeSubWindow()->stopEvent(); + m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); playingTimer->stop(); - } void plaYUVerApp::playEvent() @@ -162,8 +162,17 @@ void plaYUVerApp::playEvent() { if( !activeSubWindow()->playEvent() ) { - playingTimer->stop(); + stop(); } + m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); + } +} + +void plaYUVerApp::seekSliderEvent( int new_frame_num ) +{ + if( activeSubWindow() ) + { + activeSubWindow()->seekEvent( new_frame_num ); } } @@ -202,6 +211,11 @@ void plaYUVerApp::about() void plaYUVerApp::chageSubWindowSelection() { playingTimer->stop(); + if( activeSubWindow() ) + { + m_pcFrameSlider->setMaximum( activeSubWindow()->getInputStream()->getFrameNum() - 1 ); + m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); + } updateMenus(); //updateWindowMenu(); } @@ -226,6 +240,7 @@ Void plaYUVerApp::updateMenus() actionVideoStop->setEnabled( hasSubWindow ); actionVideoBackward->setEnabled( hasSubWindow ); actionVideoForward->setEnabled( hasSubWindow ); + m_pcFrameSlider->setEnabled( hasSubWindow ); } void plaYUVerApp::updateWindowMenu() @@ -358,20 +373,26 @@ Void plaYUVerApp::createActions() // ------------ Playing ------------ actionVideoPlay = new QAction( "VideoPlay", this ); + actionVideoPlay->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ) ); + connect( actionVideoPlay, SIGNAL( triggered() ), this, SLOT( play() ) ); + actionVideoPause = new QAction( "VideoPause", this ); + actionVideoPause->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPause ) ) ); + connect( actionVideoPause, SIGNAL( triggered() ), this, SLOT( pause() ) ); + actionVideoStop = new QAction( "VideoStop", this ); + actionVideoStop->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaStop ) ) ); + connect( actionVideoStop, SIGNAL( triggered() ), this, SLOT( stop() ) ); + actionVideoBackward = new QAction( "VideoBackward", this ); + actionVideoBackward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) ); actionVideoForward = new QAction( "VideoForward", this ); + actionVideoForward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) ); + actionVideoLoop = new QAction( "VideoLoop", this ); actionVideoLock = new QAction( "VideoLock", this ); actionVideoInterlace = new QAction( "VideoInterlace", this ); actionVideoCenter = new QAction( "VideoCenter", this ); - - actionVideoPlay->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ) ); - actionVideoPause->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPause ) ) ); - actionVideoStop->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaStop ) ) ); - actionVideoBackward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) ); - actionVideoForward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) ); /* actionVideoLoop ->setIcon( QIcon( ":/images/videoloop.png" ) ); actionVideoLock ->setIcon( QIcon( ":/images/lock.png" ) ); @@ -379,9 +400,13 @@ Void plaYUVerApp::createActions() actionVideoCenter ->setIcon( QIcon( ":/images/center.png" ) ); */ - connect( actionVideoPlay, SIGNAL( triggered() ), this, SLOT( play() ) ); - connect( actionVideoPause, SIGNAL( triggered() ), this, SLOT( pause() ) ); - connect( actionVideoStop, SIGNAL( triggered() ), this, SLOT( stop() ) ); + m_pcFrameSlider = new QSlider; + m_pcFrameSlider->setOrientation( Qt::Horizontal ); + m_pcFrameSlider->setMaximumWidth( 100 ); + m_pcFrameSlider->setMaximumWidth( 300 ); + m_pcFrameSlider->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) ); + m_pcFrameSlider->setEnabled( false ); + connect( m_pcFrameSlider, SIGNAL( valueChanged(int) ), this, SLOT( seekSliderEvent(int) ) ); // ------------ Window ------------ @@ -463,19 +488,15 @@ Void plaYUVerApp::createToolBars() toolbarVideo->addAction( actionVideoPause ); toolbarVideo->addAction( actionVideoStop ); /* - toolbarVideo->addAction( actionVideoBackward ); - toolbarVideo->addAction( actionVideoForward ); - toolbarVideo->addAction( actionVideoLoop ); - toolbarVideo->addAction( actionVideoLock ); - toolbarVideo->addAction( actionVideoInterlace ); - toolbarVideo->addAction( actionVideoCenter ); - */ - m_pcFrameSlider = new QSlider; - m_pcFrameSlider->setOrientation( Qt::Horizontal ); - m_pcFrameSlider->setMaximumWidth( 100 ); - m_pcFrameSlider->setMaximumWidth( 100 ); - m_pcFrameSlider->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) ); + toolbarVideo->addAction( actionVideoBackward ); + toolbarVideo->addAction( actionVideoForward ); + toolbarVideo->addAction( actionVideoLoop ); + toolbarVideo->addAction( actionVideoLock ); + toolbarVideo->addAction( actionVideoInterlace ); + toolbarVideo->addAction( actionVideoCenter ); + */ toolbarVideo->addWidget( m_pcFrameSlider ); + } Void plaYUVerApp::createStatusBar() diff --git a/source/plaYUVerApp.h b/source/plaYUVerApp.h index fb23bca..bd3b8db 100644 --- a/source/plaYUVerApp.h +++ b/source/plaYUVerApp.h @@ -60,7 +60,7 @@ private Q_SLOTS: void pause(); void stop(); void playEvent(); - + void seekSliderEvent(int new_frame_num ); /** * Scale the image by a given factor * @param factor factor of scale. Ex: 120 scale the image up by 20% and