Re-format code
This commit is contained in:
+78
-44
@@ -22,18 +22,23 @@
|
||||
* \brief PlaYUVer modules handle
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include "PlaYUVerApp.h"
|
||||
#include "ModulesHandle.h"
|
||||
#include "PlaYUVerSubWindowHandle.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "VideoHandle.h"
|
||||
#include "DialogSubWindowSelector.h"
|
||||
#include "ModulesHandleOptDialog.h"
|
||||
#include "PlaYUVerApp.h"
|
||||
#include "PlaYUVerSubWindowHandle.h"
|
||||
#include "VideoHandle.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "modules/PlaYUVerModuleFactory.h"
|
||||
#include <cstdio>
|
||||
|
||||
ModulesHandle::ModulesHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager, VideoHandle* moduleVideo )
|
||||
: QWidget( parent ), m_pcParent( parent ), m_pcMainWindowManager( windowManager ), m_appModuleVideo( moduleVideo )
|
||||
ModulesHandle::ModulesHandle( QWidget* parent,
|
||||
PlaYUVerSubWindowHandle* windowManager,
|
||||
VideoHandle* moduleVideo )
|
||||
: QWidget( parent )
|
||||
, m_pcParent( parent )
|
||||
, m_pcMainWindowManager( windowManager )
|
||||
, m_appModuleVideo( moduleVideo )
|
||||
{
|
||||
setParent( m_pcParent );
|
||||
}
|
||||
@@ -49,13 +54,16 @@ Void ModulesHandle::createActions()
|
||||
m_pcActionMapper = new QSignalMapper( this );
|
||||
connect( m_pcActionMapper, SIGNAL( mapped( int ) ), this, SLOT( processOpt( int ) ) );
|
||||
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT] = new QAction( "Refresh while playing", parent() );
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setStatusTip( "Force module refreshing while playing" );
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT] = new QAction( "Refresh while
|
||||
// playing", parent() );
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setStatusTip( "Force module
|
||||
// refreshing while playing" );
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setCheckable( true );
|
||||
|
||||
m_arrayActions[LOAD_EXTERNAL_ACT] = new QAction( "Load external module", parent() );
|
||||
m_arrayActions[LOAD_EXTERNAL_ACT]->setStatusTip( "Load an externally build module" );
|
||||
connect( m_arrayActions[LOAD_EXTERNAL_ACT], SIGNAL( triggered() ), this, SLOT( loadExternalModule() ) );
|
||||
connect( m_arrayActions[LOAD_EXTERNAL_ACT], SIGNAL( triggered() ), this,
|
||||
SLOT( loadExternalModule() ) );
|
||||
|
||||
m_arrayActions[APPLY_ALL_ACT] = new QAction( "Apply to All", parent() );
|
||||
m_arrayActions[APPLY_ALL_ACT]->setStatusTip( "Apply module to all frames and save the result" );
|
||||
@@ -64,18 +72,22 @@ Void ModulesHandle::createActions()
|
||||
|
||||
m_arrayActions[SWAP_FRAMES_ACT] = new QAction( "Swap frames", parent() );
|
||||
m_arrayActions[SWAP_FRAMES_ACT]->setStatusTip( "Swap Sub Window order" );
|
||||
connect( m_arrayActions[SWAP_FRAMES_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
|
||||
connect( m_arrayActions[SWAP_FRAMES_ACT], SIGNAL( triggered() ), m_pcActionMapper,
|
||||
SLOT( map() ) );
|
||||
m_pcActionMapper->setMapping( m_arrayActions[SWAP_FRAMES_ACT], SWAP_FRAMES_ACT );
|
||||
|
||||
m_arrayActions[DISABLE_ACT] = new QAction( "Disable Modules", parent() );
|
||||
connect( m_arrayActions[DISABLE_ACT], SIGNAL( triggered() ), this, SLOT( destroyWindowModules() ) );
|
||||
connect( m_arrayActions[DISABLE_ACT], SIGNAL( triggered() ), this,
|
||||
SLOT( destroyWindowModules() ) );
|
||||
|
||||
m_arrayActions[DISABLE_ALL_ACT] = new QAction( "Disable All Modules", parent() );
|
||||
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this, SLOT( destroyAllModulesIf() ) );
|
||||
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this,
|
||||
SLOT( destroyAllModulesIf() ) );
|
||||
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", parent() );
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip(
|
||||
"Show module result in a new window. Some modules already force this feature" );
|
||||
"Show module result in a new window. Some modules already force this "
|
||||
"feature" );
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setCheckable( true );
|
||||
}
|
||||
|
||||
@@ -113,7 +125,8 @@ Void ModulesHandle::buildMenu()
|
||||
{
|
||||
for( Int j = 0; j < m_pcModulesSubMenuList.size(); j++ )
|
||||
{
|
||||
if( m_pcModulesSubMenuList.at( j )->title() == QString( pcCurrModuleIf->m_pchModuleCategory ) )
|
||||
if( m_pcModulesSubMenuList.at( j )->title() ==
|
||||
QString( pcCurrModuleIf->m_pchModuleCategory ) )
|
||||
{
|
||||
currSubMenu = m_pcModulesSubMenuList.at( j );
|
||||
break;
|
||||
@@ -152,7 +165,8 @@ Void ModulesHandle::buildMenu()
|
||||
|
||||
Void ModulesHandle::updateMenus()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcSubWindow =
|
||||
qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
Bool hasSubWindow = pcSubWindow ? true : false;
|
||||
QAction* currModuleAction;
|
||||
|
||||
@@ -195,18 +209,21 @@ Void ModulesHandle::updateMenus()
|
||||
Void ModulesHandle::readSettings()
|
||||
{
|
||||
QSettings appSettings;
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setChecked( appSettings.value( "ModulesHandle/UseNewWindow", false ).toBool() );
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setChecked(
|
||||
appSettings.value( "ModulesHandle/UseNewWindow", false ).toBool() );
|
||||
}
|
||||
|
||||
Void ModulesHandle::writeSettings()
|
||||
{
|
||||
QSettings appSettings;
|
||||
appSettings.setValue( "ModulesHandle/UseNewWindow", m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked() );
|
||||
appSettings.setValue( "ModulesHandle/UseNewWindow",
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked() );
|
||||
}
|
||||
|
||||
Void ModulesHandle::processOpt( Int index )
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcSubWindow =
|
||||
qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
if( pcSubWindow )
|
||||
{
|
||||
PlaYUVerAppModuleIf* pcCurrentModule = pcSubWindow->getDisplayModule();
|
||||
@@ -239,8 +256,8 @@ Void ModulesHandle::loadExternalModule()
|
||||
formatsList << "Shared Libraries (*.so)";
|
||||
QStringList filter;
|
||||
filter << supported << formatsList << tr( "All Files (*)" );
|
||||
QStringList fileNames =
|
||||
QFileDialog::getOpenFileNames( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) );
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames( m_pcParent, tr( "Open File" ), QString(),
|
||||
filter.join( ";;" ) );
|
||||
|
||||
for( Int i = 0; i < fileNames.size(); i++ )
|
||||
{
|
||||
@@ -256,13 +273,15 @@ Void ModulesHandle::activateModule()
|
||||
Qt::KeyboardModifiers keyModifiers = QApplication::keyboardModifiers();
|
||||
Bool bTmpForceNewWindow = false;
|
||||
|
||||
VideoSubWindow* pcVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcVideoSubWindow =
|
||||
qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
if( !pcVideoSubWindow )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( ( keyModifiers & Qt::ControlModifier ) || pcVideoSubWindow->checkCategory( VideoSubWindow::MODULE_SUBWINDOW ) )
|
||||
if( ( keyModifiers & Qt::ControlModifier ) ||
|
||||
pcVideoSubWindow->checkCategory( VideoSubWindow::MODULE_SUBWINDOW ) )
|
||||
{
|
||||
bTmpForceNewWindow = true;
|
||||
}
|
||||
@@ -270,7 +289,8 @@ Void ModulesHandle::activateModule()
|
||||
QString ModuleIfName = pcAction->data().toString();
|
||||
PlaYUVerModuleIf* pcCurrModuleIf =
|
||||
PlaYUVerModuleFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() );
|
||||
PlaYUVerAppModuleIf* pcCurrAppModuleIf = new PlaYUVerAppModuleIf( this, pcAction, pcCurrModuleIf );
|
||||
PlaYUVerAppModuleIf* pcCurrAppModuleIf =
|
||||
new PlaYUVerAppModuleIf( this, pcAction, pcCurrModuleIf );
|
||||
|
||||
QList<VideoSubWindow*> videoSubWindowList;
|
||||
Int numberOfFrames = pcCurrAppModuleIf->m_pcModule->m_uiNumberOfFrames;
|
||||
@@ -284,8 +304,10 @@ Void ModulesHandle::activateModule()
|
||||
maxNumFrames = 255;
|
||||
}
|
||||
DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager,
|
||||
SubWindowAbstract::VIDEO_SUBWINDOW, minNumFrames, maxNumFrames );
|
||||
QList<SubWindowAbstract*> windowsList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
|
||||
SubWindowAbstract::VIDEO_SUBWINDOW,
|
||||
minNumFrames, maxNumFrames );
|
||||
QList<SubWindowAbstract*> windowsList =
|
||||
m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
|
||||
|
||||
if( windowsList.size() == minNumFrames && windowsList.size() == maxNumFrames )
|
||||
{
|
||||
@@ -323,10 +345,12 @@ Void ModulesHandle::activateModule()
|
||||
// Check for same fmt in more than one frame modules
|
||||
for( Int i = 1; i < videoSubWindowList.size(); i++ )
|
||||
{
|
||||
if( !videoSubWindowList.at( i )->getCurrFrame()->haveSameFmt( videoSubWindowList.at( 0 )->getCurrFrame() ) )
|
||||
if( !videoSubWindowList.at( i )->getCurrFrame()->haveSameFmt(
|
||||
videoSubWindowList.at( 0 )->getCurrFrame() ) )
|
||||
{
|
||||
videoSubWindowList.clear();
|
||||
qobject_cast<PlaYUVerApp*>( m_pcParent )->printMessage( "Error! Incompatible frames", LOG_ERROR );
|
||||
qobject_cast<PlaYUVerApp*>( m_pcParent )
|
||||
->printMessage( "Error! Incompatible frames", LOG_ERROR );
|
||||
destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
@@ -356,13 +380,15 @@ Void ModulesHandle::activateModule()
|
||||
ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrAppModuleIf );
|
||||
if( moduleOptDialog.runConfiguration() == QDialog::Rejected )
|
||||
{
|
||||
qobject_cast<PlaYUVerApp*>( m_pcParent )->printMessage( "Module canceled by user!", LOG_WARNINGS );
|
||||
qobject_cast<PlaYUVerApp*>( m_pcParent )
|
||||
->printMessage( "Module canceled by user!", LOG_WARNINGS );
|
||||
destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Bool bShowModulesNewWindow = m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked() | bTmpForceNewWindow;
|
||||
Bool bShowModulesNewWindow =
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->isChecked() | bTmpForceNewWindow;
|
||||
|
||||
QString windowName;
|
||||
|
||||
@@ -376,12 +402,12 @@ Void ModulesHandle::activateModule()
|
||||
windowName.append( QStringLiteral( "Module " ) );
|
||||
windowName.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleName );
|
||||
|
||||
connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo,
|
||||
SLOT( updateSelectionArea( QRect ) ) );
|
||||
connect( pcModuleSubWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo,
|
||||
SLOT( zoomToFactorAll( double, QPoint ) ) );
|
||||
connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo,
|
||||
SLOT( moveAllScrollBars( const QPoint ) ) );
|
||||
connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ),
|
||||
m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) );
|
||||
connect( pcModuleSubWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ),
|
||||
m_appModuleVideo, SLOT( zoomToFactorAll( double, QPoint ) ) );
|
||||
connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ),
|
||||
m_appModuleVideo, SLOT( moveAllScrollBars( const QPoint ) ) );
|
||||
|
||||
pcCurrAppModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow;
|
||||
}
|
||||
@@ -394,8 +420,10 @@ Void ModulesHandle::activateModule()
|
||||
titleDockWidget.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleName );
|
||||
titleDockWidget.append( " Information" );
|
||||
pcCurrAppModuleIf->m_pcDockWidget = new QDockWidget( titleDockWidget, m_pcParent );
|
||||
pcCurrAppModuleIf->m_pcDockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
|
||||
pcCurrAppModuleIf->m_pcDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
pcCurrAppModuleIf->m_pcDockWidget->setFeatures( QDockWidget::DockWidgetMovable |
|
||||
QDockWidget::DockWidgetFloatable );
|
||||
pcCurrAppModuleIf->m_pcDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea |
|
||||
Qt::RightDockWidgetArea );
|
||||
pcCurrAppModuleIf->m_pcDockWidget->setWidget( pcCurrAppModuleIf->m_pcModuleDock );
|
||||
qobject_cast<QMainWindow*>( m_pcParent )
|
||||
->addDockWidget( Qt::RightDockWidgetArea, pcCurrAppModuleIf->m_pcDockWidget );
|
||||
@@ -435,7 +463,8 @@ Void ModulesHandle::activateModule()
|
||||
|
||||
if( !moduleCreated )
|
||||
{
|
||||
qobject_cast<PlaYUVerApp*>( m_pcParent )->printMessage( "Error! Module cannot be created", LOG_ERROR );
|
||||
qobject_cast<PlaYUVerApp*>( m_pcParent )
|
||||
->printMessage( "Error! Module cannot be created", LOG_ERROR );
|
||||
destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
@@ -472,7 +501,8 @@ Void ModulesHandle::destroyModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf )
|
||||
|
||||
Void ModulesHandle::destroyWindowModules()
|
||||
{
|
||||
VideoSubWindow* pcVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
VideoSubWindow* pcVideoSubWindow =
|
||||
qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
if( pcVideoSubWindow )
|
||||
{
|
||||
pcVideoSubWindow->disableModule();
|
||||
@@ -489,7 +519,9 @@ Void ModulesHandle::destroyAllModulesIf()
|
||||
emit changed();
|
||||
}
|
||||
|
||||
Void ModulesHandle::applyModuleIf( QList<PlaYUVerAppModuleIf*> pcCurrModuleIfList, Bool isPlaying, Bool disableThreads )
|
||||
Void ModulesHandle::applyModuleIf( QList<PlaYUVerAppModuleIf*> pcCurrModuleIfList,
|
||||
Bool isPlaying,
|
||||
Bool disableThreads )
|
||||
{
|
||||
for( Int i = 0; i < pcCurrModuleIfList.size() && !isPlaying; i++ )
|
||||
{
|
||||
@@ -526,7 +558,8 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf )
|
||||
QStringList filter;
|
||||
filter << supported << formatsList << tr( "All Files (*)" );
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) );
|
||||
QString fileName = QFileDialog::getSaveFileName( m_pcParent, tr( "Open File" ), QString(),
|
||||
filter.join( ";;" ) );
|
||||
|
||||
Width = pcCurrModuleIf->m_pcProcessedFrame->getWidth();
|
||||
Height = pcCurrModuleIf->m_pcProcessedFrame->getHeight();
|
||||
@@ -535,8 +568,9 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf )
|
||||
FrameRate = pcCurrModuleIf->m_pcSubWindow[0]->getInputStream()->getFrameRate();
|
||||
|
||||
pcCurrModuleIf->m_pcModuleStream = new PlaYUVerStream;
|
||||
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel,
|
||||
PLAYUVER_LITTLE_ENDIAN, FrameRate, false ) )
|
||||
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height,
|
||||
InputFormat, BitsPixel, PLAYUVER_LITTLE_ENDIAN,
|
||||
FrameRate, false ) )
|
||||
{
|
||||
delete pcCurrModuleIf->m_pcModuleStream;
|
||||
pcCurrModuleIf->m_pcModuleStream = NULL;
|
||||
|
||||
Reference in New Issue
Block a user