From b4979106b922130b7e077e992d58ca8a42f1f317 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 22 Mar 2014 15:51:23 +0000 Subject: [PATCH] Improve modules interface. Add a variable to mark the module category and type. change some function in the plaYUVerApp to fix modules disabling when closing a sub window --- source/ModulesHandle.cpp | 21 +++++++++++++---- source/ModulesHandle.h | 1 + source/SubWindowHandle.cpp | 6 +++++ source/modules/FilterFrame.cpp | 3 ++- source/modules/PlaYUVerModuleIf.h | 13 ++++++++--- source/plaYUVerApp.cpp | 39 +++++++++++++++++-------------- source/plaYUVerApp.h | 6 ++++- 7 files changed, 63 insertions(+), 26 deletions(-) diff --git a/source/ModulesHandle.cpp b/source/ModulesHandle.cpp index b0ae046..ae189ec 100644 --- a/source/ModulesHandle.cpp +++ b/source/ModulesHandle.cpp @@ -35,7 +35,6 @@ ModulesHandle::ModulesHandle( QWidget * parent ) REGISTER_MODULE( FilterFrame ); - // configure class setParent( parent ); m_uiModulesCount = 0; @@ -51,7 +50,6 @@ Void ModulesHandle::appendModule( PlaYUVerModuleIf* pIfModule ) { m_pcPlaYUVerModules.append( pIfModule ); m_uiModulesCount++; - } void ModulesHandle::selectModule( int index ) @@ -75,6 +73,7 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) { PlaYUVerModuleIf* currModuleIf; QAction* currAction; + Bool bCategoryExists = false; m_pcActionMapper = new QSignalMapper( this ); connect( m_pcActionMapper, SIGNAL( mapped(int) ), this, SLOT( selectModule(int) ) ); @@ -82,11 +81,16 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) m_pcModulesMenu = MainAppMenuBar->addMenu( "&Modules" ); //m_arrayModulesActions.resize( m_uiModulesCount ); - +Int total = 0; for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ ) { currModuleIf = m_pcPlaYUVerModules.at( i ); + for( Int j = 0; j < total; j++ ) + { + + } + currAction = new QAction( tr( currModuleIf->m_cModuleDef.m_pchModuleName ), parent() ); currAction->setStatusTip( tr( currModuleIf->m_cModuleDef.m_pchModuleTooltip ) ); currAction->setCheckable( true ); @@ -99,7 +103,16 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) currModuleIf->m_pcAction = currAction; } return m_pcModulesMenu; - //MainAppMenuBar-> +} + +Void ModulesHandle::updateMenus( Bool hasSubWindow ) +{ + QAction* currModuleAction; + for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ ) + { + currModuleAction = m_arrayModulesActions.at( i ); + currModuleAction->setEnabled( hasSubWindow ); + } } } // NAMESPACE diff --git a/source/ModulesHandle.h b/source/ModulesHandle.h index 4391828..7f11044 100644 --- a/source/ModulesHandle.h +++ b/source/ModulesHandle.h @@ -59,6 +59,7 @@ public: ~ModulesHandle(); QMenu* createMenus( QMenuBar *MainAppMenuBar ); + Void updateMenus( Bool hasSubWindow ); PlaYUVerModuleIf* getSelectedModuleIf(); private: diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 0d73b54..645dfe5 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -57,6 +57,11 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) : SubWindowHandle::~SubWindowHandle() { delete m_cViewArea; + if( !m_pcCurrentModule ) + return; + m_pcCurrentModule->m_pcAction->setChecked( false ); + m_pcCurrentModule->destroy(); + m_pcCurrentModule = NULL; } bool SubWindowHandle::loadFile( const QString &fileName ) @@ -129,6 +134,7 @@ Void SubWindowHandle::disableModule() { if( !m_pcCurrentModule ) return; + m_pcCurrentModule->destroy(); m_pcCurrentModule = NULL; refreshFrame(); diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp index 912e1a3..e3842d0 100644 --- a/source/modules/FilterFrame.cpp +++ b/source/modules/FilterFrame.cpp @@ -30,7 +30,8 @@ namespace plaYUVer { PlaYUVerModuleDefinition FilterFrameDef = { - "FrameLevel", + FRAME_LEVEL_MODULE, + "Filters" "Y_Filter", "Filter Y matrix of YUV frame", }; diff --git a/source/modules/PlaYUVerModuleIf.h b/source/modules/PlaYUVerModuleIf.h index 4a4b15b..5f2fe6f 100644 --- a/source/modules/PlaYUVerModuleIf.h +++ b/source/modules/PlaYUVerModuleIf.h @@ -38,11 +38,18 @@ class QAction; namespace plaYUVer { +enum __PlaYUVerModuleTypes +{ + FRAME_LEVEL_MODULE, + VIDEO_LEVEL_MODULE, +}; + typedef struct __PlaYUVerModuleDefinition { - const char *m_pchModuleType; - const char *m_pchModuleName; - const char *m_pchModuleTooltip; + int m_pchModuleType; + char* m_pchModuleCategory; + char* m_pchModuleName; + char* m_pchModuleTooltip; }PlaYUVerModuleDefinition; diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 964b6d5..5ee2767 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -237,11 +237,14 @@ void plaYUVerApp::chageSubWindowSelection() { if( m_pcCurrentSubWindow ) m_pcCurrentSubWindow->disableModule(); - m_pcFrameSlider->setMaximum( activeSubWindow()->getInputStream()->getFrameNum() - 1 ); m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); m_pcCurrentSubWindow = activeSubWindow(); } + else + { + m_pcCurrentSubWindow = NULL; + } updateMenus(); //updateWindowMenu(); } @@ -267,6 +270,8 @@ Void plaYUVerApp::updateMenus() actionVideoBackward->setEnabled( hasSubWindow ); actionVideoForward->setEnabled( hasSubWindow ); m_pcFrameSlider->setEnabled( hasSubWindow ); + + m_pcModulesHandle->updateMenus( hasSubWindow ); } void plaYUVerApp::updateWindowMenu() @@ -471,21 +476,21 @@ Void plaYUVerApp::createActions() Void plaYUVerApp::createMenus() { - m_arrayMenu.resize( 4 ); + m_arrayMenu.resize( TOTAL_MENUS ); - m_arrayMenu[OTHER_MENU] = menuBar()->addMenu( tr( "&File" ) ); - m_arrayMenu[OTHER_MENU]->addAction( actionOpen ); - m_arrayMenu[OTHER_MENU]->addSeparator(); - m_arrayMenu[OTHER_MENU]->addAction( actionSave ); - m_arrayMenu[OTHER_MENU]->addSeparator(); - m_arrayMenu[OTHER_MENU]->addAction( actionClose ); - m_arrayMenu[OTHER_MENU]->addAction( actionExit ); + m_arrayMenu[FILE_MENU] = menuBar()->addMenu( tr( "&File" ) ); + m_arrayMenu[FILE_MENU]->addAction( actionOpen ); + m_arrayMenu[FILE_MENU]->addSeparator(); + m_arrayMenu[FILE_MENU]->addAction( actionSave ); + m_arrayMenu[FILE_MENU]->addSeparator(); + m_arrayMenu[FILE_MENU]->addAction( actionClose ); + m_arrayMenu[FILE_MENU]->addAction( actionExit ); - m_arrayMenu[OTHER_MENU + 1] = menuBar()->addMenu( tr( "&View" ) ); - m_arrayMenu[OTHER_MENU + 1]->addAction( actionZoomIn ); - m_arrayMenu[OTHER_MENU + 1]->addAction( actionZoomOut ); - m_arrayMenu[OTHER_MENU + 1]->addAction( actionNormalSize ); - m_arrayMenu[OTHER_MENU + 1]->addAction( actionZoomToFit ); + m_arrayMenu[VIEW_MENU] = menuBar()->addMenu( tr( "&View" ) ); + m_arrayMenu[VIEW_MENU]->addAction( actionZoomIn ); + m_arrayMenu[VIEW_MENU]->addAction( actionZoomOut ); + m_arrayMenu[VIEW_MENU]->addAction( actionNormalSize ); + m_arrayMenu[VIEW_MENU]->addAction( actionZoomToFit ); QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() ); connect( modules_menu, SIGNAL( triggered(QAction *) ), this, SLOT( selectModule(QAction *) ) ); @@ -496,9 +501,9 @@ Void plaYUVerApp::createMenus() menuBar()->addSeparator(); - m_arrayMenu[OTHER_MENU + 2] = menuBar()->addMenu( tr( "&Help" ) ); - m_arrayMenu[OTHER_MENU + 2]->addAction( actionAbout ); - m_arrayMenu[OTHER_MENU + 2]->addAction( actionAboutQt ); + m_arrayMenu[ABOUT_MENU] = menuBar()->addMenu( tr( "&Help" ) ); + m_arrayMenu[ABOUT_MENU]->addAction( actionAbout ); + m_arrayMenu[ABOUT_MENU]->addAction( actionAboutQt ); } Void plaYUVerApp::createToolBars() diff --git a/source/plaYUVerApp.h b/source/plaYUVerApp.h index a7b3705..82e9a0a 100644 --- a/source/plaYUVerApp.h +++ b/source/plaYUVerApp.h @@ -128,7 +128,11 @@ private: */ enum MAIN_APP_MENU_LIST { - WINDOW_MENU = 0, OTHER_MENU, + FILE_MENU = 0, + VIEW_MENU, + WINDOW_MENU, + ABOUT_MENU, + TOTAL_MENUS, }; QVector m_arrayMenu;