diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 44eddac..21cf315 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -52,7 +52,11 @@ VideoHandle::VideoHandle( QWidget* parent, SubWindowHandle* windowManager ) m_acPlayingSubWindows.clear(); } -VideoHandle::~VideoHandle() {} +VideoHandle::~VideoHandle() +{ + delete m_pcPlayingTimer; + delete m_pcFrameRateFeedbackTimer; +} void VideoHandle::createActions() { @@ -360,7 +364,7 @@ void VideoHandle::update() } m_pcResolutionLabel->setText( resolution ); - m_pcFramePropertiesSideBar->setFrame( pcFrame ); + m_pcFramePropertiesSideBar->setFrame( pcFrame, m_pcCurrentVideoSubWindow->isPlaying() ); m_pcFrameNumInfo->setTotalFrameNum( total_frame_num ); m_pcFrameNumInfo->setCurrFrameNum( frame_num ); @@ -669,13 +673,22 @@ void VideoHandle::calculateRealFrameRate() void VideoHandle::playEvent() { - bool bEndOfSequence = false; + // This value should only be true if it is really needed to refresh the UI after this play event + // Lets assum the current window is not playing. Nothing changes in the UI expect the playing windows + // So no changed is emmited + bool bShouldRefreshUI = false; calculateRealFrameRate(); try { + bool bEndOfSequence = false; for( auto playingSubWindow : m_acPlayingSubWindows ) { bEndOfSequence |= playingSubWindow->playEvent(); + // If the current selected windows is playing then we need to refresh the UI + if( playingSubWindow == m_pcCurrentVideoSubWindow ) + { + bShouldRefreshUI = true; + } } if( bEndOfSequence ) { @@ -702,7 +715,8 @@ void VideoHandle::playEvent() stop(); m_pcCurrentVideoSubWindow->close(); } - emit changed(); + if( bShouldRefreshUI ) + emit changed(); } void VideoHandle::seekEvent( int direction ) diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index ecba954..af6507c 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -89,6 +89,7 @@ int findCalypStreamInfo( CalypFileInfoVector array, QString filename ) class VideoInformation : public QWidget { private: + QTimer* m_pcRefreshTimer; QList m_cTopLeftTextList; QFont m_cTopLeftTextFont; QFont m_cCenterTextFont; @@ -102,6 +103,9 @@ public: setAttribute( Qt::WA_TransparentForMouseEvents ); m_cTopLeftTextFont.setPointSize( 8 ); m_cCenterTextFont.setPointSize( 12 ); + m_pcRefreshTimer = new QTimer; + m_pcRefreshTimer->setSingleShot( true ); + connect( m_pcRefreshTimer, SIGNAL( timeout() ), this, SLOT( update() ) ); } void setInformationTopLeft( const QStringList& textLines ) { @@ -111,7 +115,11 @@ public: m_cTopLeftTextList.append( QStaticText( textLines.at( i ) ) ); } } - void setBusyWindow( bool bFlag ) { m_bBusyWindow = bFlag; } + void setBusyWindow( bool bFlag ) + { + m_bBusyWindow = bFlag; + m_pcRefreshTimer->start( 500 ); + } protected: void paintEvent( QPaintEvent* event ) @@ -704,7 +712,6 @@ bool VideoSubWindow::hasRunningModule() void VideoSubWindow::setFillWindow( bool bFlag ) { m_pcVideoInfo->setBusyWindow( bFlag ); - m_pcVideoInfo->repaint(); } void VideoSubWindow::setCurrFrame( CalypFrame* pcCurrFrame ) @@ -808,6 +815,20 @@ bool VideoSubWindow::saveStream( QString filename ) return iRet; } +bool VideoSubWindow::isPlaying() +{ + if( getCategory() & SubWindowCategory::MODULE_SUBWINDOW ) + { + for( auto window : m_pcCurrentDisplayModule->getSubWindowList() ) + { + if( window->isPlaying() ) + return true; + } + return false; + } + return m_bIsPlaying; +} + bool VideoSubWindow::play() { if( m_pCurrStream && m_pCurrStream->getFrameNum() > 1 ) diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index 26a30e5..377f669 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -127,7 +127,7 @@ public: bool playEvent(); void stop(); - bool isPlaying() { return m_bIsPlaying; } + bool isPlaying(); void seekAbsoluteEvent( unsigned int new_frame_num ); void seekRelativeEvent( bool bIsFoward ); diff --git a/app/docks/FramePropertiesDock.cpp b/app/docks/FramePropertiesDock.cpp index 8a671b8..4867b80 100644 --- a/app/docks/FramePropertiesDock.cpp +++ b/app/docks/FramePropertiesDock.cpp @@ -31,7 +31,7 @@ #include "lib/CalypStream.h" FramePropertiesDock::FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitch ) - : QWidget( parent ), m_pbIsPlaying( pbMainPlaySwitch ), m_bHasFrame( false ) + : QWidget( parent ), m_bIsPlaying( false ), m_bHasFrame( false ) { // -------------- Variables definition -------------- m_iLastFrameType = -1; @@ -297,7 +297,7 @@ void FramePropertiesDock::reset() setEnabled( false ); } -void FramePropertiesDock::setFrame( CalypFrame* pcFrame ) +void FramePropertiesDock::setFrame( CalypFrame* pcFrame, bool isPlaying ) { int colorSpace = pcFrame->getColorSpace(); if( m_iLastFrameType != colorSpace ) @@ -359,12 +359,20 @@ void FramePropertiesDock::setFrame( CalypFrame* pcFrame ) } } setEnabled( true ); - if( pcFrame && !( *m_pbIsPlaying ) ) + m_bIsPlaying = isPlaying; + if( !m_bIsPlaying ) { - m_bHasFrame = true; - m_cFrame = CalypFrame( pcFrame ); - updateDataHistogram(); + if( pcFrame ) + { + m_bHasFrame = true; + m_cFrame = CalypFrame( pcFrame ); + } + else + { + m_bHasFrame = false; + } } + updateDataHistogram(); } void FramePropertiesDock::setSelection( const QRect& selectionArea ) @@ -401,7 +409,7 @@ void FramePropertiesDock::updateDataHistogram() { if( m_bHasFrame && isVisible() ) { - if( !*m_pbIsPlaying ) + if( !m_bIsPlaying ) { if( m_cSelectionArea.isValid() ) { diff --git a/app/docks/FramePropertiesDock.h b/app/docks/FramePropertiesDock.h index ae54d6a..64cfc72 100644 --- a/app/docks/FramePropertiesDock.h +++ b/app/docks/FramePropertiesDock.h @@ -43,7 +43,7 @@ public: QSize sizeHint() const; - void setFrame( CalypFrame* m_pcFrame ); + void setFrame( CalypFrame* m_pcFrame, bool isPlaying ); void setSelection( const QRect& selectionArea ); void reset(); void stopHistogram(); @@ -52,8 +52,8 @@ private: CalypFrame m_cFrame; CalypFrame m_cSelectedFrame; int m_iLastFrameType; + bool m_bIsPlaying; bool m_bHasFrame; - bool* m_pbIsPlaying; QComboBox* channelCB; QComboBox* colorsCB;