Rearrange modules enable/disable code. now the main function is inside ModulesHandle class

This commit is contained in:
jfmcarreira committed 2014-04-23 22:49:42 +01:00
1 parent 88a5b8a09b
commit 769bcead86
5 files changed
+66 -43

No files matched your search

+50 -8
View File
@@ -25,6 +25,9 @@
#include <cstdio>
#include "ModulesHandle.h"
#include "SubWindowHandle.h"
// List of modules includes
#include "FilterFrame.h"
namespace plaYUVer
@@ -32,20 +35,22 @@ namespace plaYUVer
Void ModulesHandle::ModulesList( Bool bCreate )
{
// Register Modules
REGISTER_MODULE( FilterFrame );
}
ModulesHandle::ModulesHandle( QWidget * parent )
{
ModulesList( true );
m_pcParent = parent;
// configure class
setParent( parent );
setParent( m_pcParent );
m_uiModulesCount = 0;
m_uiModuleSelected= -1;
m_uiModuleSelected = -1;
ModulesList( true );
}
ModulesHandle::~ModulesHandle()
@@ -69,12 +74,51 @@ PlaYUVerModuleIf* ModulesHandle::getSelectedModuleIf()
if( m_uiModuleSelected >= 0 )
//if( m_arrayModulesActions.at(m_uiModuleSelected)->isChecked() )
currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected );
currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected );
m_uiModuleSelected = -1;
return currModuleIf;
}
SubWindowHandle* ModulesHandle::toggleSelectedModuleIf( SubWindowHandle* pcSubWindow )
{
SubWindowHandle* interfaceChild = NULL;
PlaYUVerModuleIf* currModuleIf = NULL;
if( m_uiModuleSelected >= 0 )
//if( m_arrayModulesActions.at(m_uiModuleSelected)->isChecked() )
currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected );
m_uiModuleSelected = -1;
if( currModuleIf->m_pcAction->isChecked() )
{
if( currModuleIf->m_cModuleDef.m_bRequiresNewWindow )
{
interfaceChild = new SubWindowHandle( m_pcParent );
//mdiArea->addSubWindow( interfaceChild );
pcSubWindow->setModuleSubWindow( interfaceChild );
pcSubWindow->enableModule( currModuleIf );
interfaceChild->show();
interfaceChild->zoomToFit();
connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), this,
SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
}
else
{
pcSubWindow->enableModule( currModuleIf );
}
currModuleIf->m_pcSubWindow = pcSubWindow;
}
else
{
currModuleIf->m_pcSubWindow->disableModule();
currModuleIf->m_pcSubWindow = NULL;
}
return interfaceChild;
}
QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
{
PlaYUVerModuleIf* currModuleIf;
@@ -88,8 +132,6 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar )
//m_arrayModulesActions.resize( m_uiModulesCount );
for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ )
{
currModuleIf = m_pcPlaYUVerModules.at( i );
+8 -2
View File
@@ -42,9 +42,11 @@
namespace plaYUVer
{
class ModulesHandle : public QObject
class SubWindowHandle;
class ModulesHandle: public QObject
{
Q_OBJECT
Q_OBJECT
public:
ModulesHandle( QWidget * parent = 0 );
~ModulesHandle();
@@ -52,8 +54,11 @@ public:
QMenu* createMenus( QMenuBar *MainAppMenuBar );
Void updateMenus( Bool hasSubWindow );
PlaYUVerModuleIf* getSelectedModuleIf();
SubWindowHandle* toggleSelectedModuleIf( SubWindowHandle* pcSubWindow );
private:
QWidget *m_pcParent;
UInt m_uiModulesCount;
Int m_uiModuleSelected;
QMenu* m_pcModulesMenu;
@@ -64,6 +69,7 @@ private:
Void appendModule( PlaYUVerModuleIf* );
Void ModulesList( Bool bCreate );
private Q_SLOTS:
void selectModule( int index );
};
+2 -1
View File
@@ -73,6 +73,7 @@ typedef struct __PlaYUVerModuleDefinition
bool m_bRequiresNewWindow;
}PlaYUVerModuleDefinition;
class SubWindowHandle;
class PlaYUVerModuleIf
{
@@ -86,7 +87,7 @@ public:
}
QAction* m_pcAction;
SubWindowHandle* m_pcSubWindow;
PlaYUVerModuleDefinition m_cModuleDef;
virtual Void create() {};
+1 -1
View File
@@ -131,7 +131,7 @@ Void SubWindowHandle::disableModule()
if( !m_pcCurrentModule )
return;
m_pcCurrentModule->m_pcAction->setCheckable( false );
m_pcCurrentModule->m_pcAction->setChecked( false );
m_pcCurrentModule->destroy();
m_pcCurrentModule = NULL;
refreshFrame();
+5 -31
View File
@@ -49,7 +49,6 @@ plaYUVerApp::plaYUVerApp()
//mdiArea->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
connect( mdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( chageSubWindowSelection() ) );
//connect( mdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateMenus() ) );
mapperWindow = new QSignalMapper( this );
connect( mapperWindow, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveSubWindow(QWidget*) ) );
@@ -221,32 +220,11 @@ void plaYUVerApp::closeAll()
void plaYUVerApp::selectModule( QAction *curr_action )
{
//emit curr_action->triggered();
if( m_pcCurrentSubWindow )
SubWindowHandle *interfaceChild = m_pcModulesHandle->toggleSelectedModuleIf( m_pcCurrentSubWindow );
if( interfaceChild )
{
PlaYUVerModuleIf* pcCurrMod = m_pcModulesHandle->getSelectedModuleIf();
if( pcCurrMod )
{
if( pcCurrMod->m_cModuleDef.m_bRequiresNewWindow )
{
SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createSubWindow();
mdiArea->addSubWindow( interfaceChild );
// connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, InputStream *) ), this,
// SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
// connect( interfaceChild->getViewArea(), SIGNAL( selectionChanged( QRect ) ), this,
// SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) );
m_pcCurrentSubWindow->setModuleSubWindow( interfaceChild );
m_pcCurrentSubWindow->enableModule( pcCurrMod );
interfaceChild->show();
interfaceChild->zoomToFit();
interfaceChild->getViewArea()->setTool( m_appTool );
}
else
{
m_pcCurrentSubWindow->enableModule( pcCurrMod );
}
}
mdiArea->addSubWindow( interfaceChild );
interfaceChild->getViewArea()->setTool( m_appTool );
}
return;
}
@@ -555,12 +533,8 @@ void plaYUVerApp::chageSubWindowSelection()
SubWindowHandle *new_window = activeSubWindow();
if( activeSubWindow() != m_pcCurrentSubWindow )
{
if( activeSubWindow() )
if( activeSubWindow() )
{
if( m_pcCurrentSubWindow )
{
m_pcCurrentSubWindow->disableModule();
}
m_pcCurrentSubWindow = new_window;
m_pcStreamProperties->setData( m_pcCurrentSubWindow->getInputStream() );
m_pcFrameProperties->setData( m_pcCurrentSubWindow->getInputStream()->getCurrFrame() );