refactor: modernize code

This commit is contained in:
jfmcarreira committed 2024-10-02 23:33:21 +01:00
1 parent 0cf79bf7a5
commit 05be89459e
12 files changed
+547 -628

No files matched your search

+10 -15
View File
@@ -226,14 +226,14 @@ QMenu* VideoHandle::createImageMenu()
return m_pcMenuImage;
}
QToolBar* VideoHandle::createToolBar()
auto VideoHandle::createToolBar() -> QPointer<QToolBar>
{
m_toolbarVideo = new QToolBar( tr( "Video" ) );
QPointer m_toolbarVideo = new QToolBar( tr( "Video" ) );
m_toolbarVideo->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
m_toolbarVideo->addAction( m_arrayActions[PLAY_ACT] );
m_toolbarVideo->addAction( m_arrayActions[STOP_ACT] );
QLabel* pcLockLabel = new QLabel( "PlayingLock" );
QPointer pcLockLabel = new QLabel( "PlayingLock" );
pcLockLabel->setAlignment( Qt::AlignCenter );
m_arrayActions[VIDEO_LOCK_ACT] = m_toolbarVideo->addWidget( pcLockLabel );
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false );
@@ -242,6 +242,7 @@ QToolBar* VideoHandle::createToolBar()
m_toolbarVideo->addWidget( m_pcFrameSlider );
m_toolbarVideo->addAction( m_arrayActions[VIDEO_FORWARD_ACT] );
m_toolbarVideo->addWidget( new QLabel );
m_pcFrameNumInfo = new FrameNumberWidget;
m_toolbarVideo->addWidget( m_pcFrameNumInfo );
@@ -383,8 +384,7 @@ void VideoHandle::readSettings()
QSettings appSettings;
m_arrayActions[VIDEO_REPEAT_ACT]->setChecked( appSettings.value( "VideoHandle/Repeat", false ).toBool() );
m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->setChecked( appSettings.value( "VideoHandle/VideoZoomLock", false ).toBool() );
if( !appSettings.value( "VideoHandle/FrameProperties", true ).toBool() )
m_pcFramePropertiesDock->close();
if( !appSettings.value( "VideoHandle/FrameProperties", true ).toBool() ) m_pcFramePropertiesDock->close();
m_uiViewTool = appSettings.value( "VideoHandle/SelectedTool", ViewArea::NavigationView ).toUInt();
setTool( m_uiViewTool );
@@ -630,8 +630,7 @@ unsigned long VideoHandle::getMaxFrameNumber()
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
currFrames = m_acPlayingSubWindows.at( i )->getFrameNum();
if( currFrames < maxFrames )
maxFrames = currFrames;
if( currFrames < maxFrames ) maxFrames = currFrames;
}
}
else
@@ -682,8 +681,7 @@ void VideoHandle::play()
{
auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow );
if( videoStreamSubWindow == nullptr )
return;
if( videoStreamSubWindow == nullptr ) return;
if( !videoStreamSubWindow->isPlaying() ) // Not playing
{
@@ -802,8 +800,7 @@ void VideoHandle::playEvent()
stop();
m_pcCurrentVideoSubWindow->close();
}
if( bShouldRefreshUI )
emit changed();
if( bShouldRefreshUI ) emit changed();
// auto end = std::chrono::steady_clock::now();
// std::cout << "Elapsed time going to next frame: "
@@ -861,8 +858,7 @@ void VideoHandle::seekVideo()
void VideoHandle::seekSliderEvent( int new_frame_num )
{
// TODO: Fix this slot
if( m_bIsPlaying )
return;
if( m_bIsPlaying ) return;
if( auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
{
@@ -943,8 +939,7 @@ void VideoHandle::videoSelectionButtonEvent()
void VideoHandle::setComponent( int component )
{
if( m_pcCurrentVideoSubWindow == nullptr )
return;
if( m_pcCurrentVideoSubWindow == nullptr ) return;
if( component < 0 )
{
m_pcCurrentVideoSubWindow->getViewArea()->clearFilteredChannel();