From 8b01a2b1e3b50ece1f53ec9e93b4b49d457b0709 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 7 Apr 2011 12:55:54 +0000 Subject: [PATCH] Fix pb with plugin manager (menu is not shown) --- src/CAM/CAM_Module.cxx | 36 +++++++++++++++++++++++++----------- src/CAM/CAM_Module.h | 2 ++ src/Qtx/QtxActionToolMgr.cxx | 24 ++++++++++++++++++++---- src/Qtx/QtxActionToolMgr.h | 4 ++-- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 7b31c6f2f..db8e6521b 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -82,7 +82,9 @@ CAM_Module::CAM_Module( const QString& name ) : QObject(), myApp( 0 ), myName( name ), - myDataModel( 0 ) + myDataModel( 0 ), + myMenuShown( false ), + myToolShown( false ) { } @@ -396,7 +398,7 @@ int CAM_Module::createTool( const QString& name ) ActionMgrLocker lock( toolMgr() ); - return toolMgr()->createToolBar( name ); + return toolMgr()->createToolBar( name, myToolShown ); } /*! @@ -428,7 +430,8 @@ int CAM_Module::createTool( QAction* a, const int tBar, const int id, const int int regId = registerAction( id, a ); int intId = toolMgr()->insert( a, tBar, idx ); - setToolShown( a, false ); + if ( !myToolShown ) + setToolShown( a, false ); return intId != -1 ? regId : -1; } @@ -462,7 +465,8 @@ int CAM_Module::createTool( QAction* a, const QString& tBar, const int id, const int regId = registerAction( id, a ); int intId = toolMgr()->insert( a, tBar, idx ); - setToolShown( a, false ); + if ( !myToolShown ) + setToolShown( a, false ); return intId != -1 ? regId : -1; } @@ -494,7 +498,8 @@ int CAM_Module::createTool( const int id, const int tBar, const int idx ) int intId = toolMgr()->insert( action( id ), tBar, idx ); - setToolShown( action( id ), false ); + if ( !myToolShown ) + setToolShown( action( id ), false ); return intId != -1 ? id : -1; } @@ -526,7 +531,8 @@ int CAM_Module::createTool( const int id, const QString& tBar, const int idx ) int intId = toolMgr()->insert( action( id ), tBar, idx ); - setToolShown( action( id ), false ); + if ( !myToolShown ) + setToolShown( action( id ), false ); return intId != -1 ? id : -1; } @@ -631,7 +637,8 @@ int CAM_Module::createMenu( QAction* a, const int menu, const int id, const int int regId = registerAction( id, a ); int intId = menuMgr()->insert( a, menu, group, idx ); - setMenuShown( a, false ); + if ( !myMenuShown ) + setMenuShown( a, false ); return intId != -1 ? regId : -1; } @@ -672,8 +679,9 @@ int CAM_Module::createMenu( QAction* a, const QString& menu, const int id, const int regId = registerAction( id, a ); int intId = menuMgr()->insert( a, menu, group, idx ); - setMenuShown( a, false ); - + if ( !myMenuShown ) + setMenuShown( a, false ); + return intId != -1 ? regId : -1; } @@ -707,7 +715,8 @@ int CAM_Module::createMenu( const int id, const int menu, const int group, const int intId = menuMgr()->insert( action( id ), menu, group, idx ); - setMenuShown( action( id ), false ); + if ( !myMenuShown ) + setMenuShown( action( id ), false ); return intId != -1 ? id : -1; } @@ -746,7 +755,8 @@ int CAM_Module::createMenu( const int id, const QString& menu, const int group, int intId = menuMgr()->insert( action( id ), menu, group, idx ); - setMenuShown( action( id ), false ); + if ( !myMenuShown ) + setMenuShown( action( id ), false ); return intId != -1 ? id : -1; } @@ -758,6 +768,8 @@ int CAM_Module::createMenu( const int id, const QString& menu, const int group, */ void CAM_Module::setMenuShown( const bool on ) { + myMenuShown = on; + QtxActionMenuMgr* mMgr = menuMgr(); if ( !mMgr ) return; @@ -805,6 +817,8 @@ void CAM_Module::setMenuShown( const int id, const bool on ) */ void CAM_Module::setToolShown( const bool on ) { + myToolShown = on; + QtxActionToolMgr* tMgr = toolMgr(); if ( !tMgr ) return; diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index 2a3022d66..487f32088 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -137,6 +137,8 @@ private: QString myInfo; //!< latest info message CAM_DataModel* myDataModel; //!< data model QMap myActionMap; //!< menu actions + bool myMenuShown; //!< menu shown flag + bool myToolShown; //!< tool shown flag friend class CAM_Application; }; diff --git a/src/Qtx/QtxActionToolMgr.cxx b/src/Qtx/QtxActionToolMgr.cxx index f603ba0f4..c949ab278 100644 --- a/src/Qtx/QtxActionToolMgr.cxx +++ b/src/Qtx/QtxActionToolMgr.cxx @@ -99,15 +99,30 @@ QMainWindow* QtxActionToolMgr::mainWindow() const \param title toolbar title \param tid requested toolbar ID \param mw parent main window; if it is null, the tool manager's main window is used + \param vis show toolbar visible immediately after creation (true by default) \return id of created/found toolbar */ -int QtxActionToolMgr::createToolBar( const QString& title, const int tid, QMainWindow* mw ) +int QtxActionToolMgr::createToolBar( const QString& title, const int tid, QMainWindow* mw, bool vis ) { - return createToolBar( title, true, Qt::AllToolBarAreas, tid, mw ); + return createToolBar( title, true, Qt::AllToolBarAreas, tid, mw, vis ); } +/*! + \brief Create toolbar and assign \a id to it. + + If \a tid is less than 0, the identifier is generated automatically. + If toolbar with given \a tid is already registered, the toolbar will not be created. + + \param title toolbar title + \param floatable if \c true, new toolbar is made floatable + \param dockAreas dock areas of the main window where the new toolbar can be situated + \param tid requested toolbar ID + \param mw parent main window; if it is null, the tool manager's main window is used + \param vis show toolbar visible immediately after creation (true by default) + \return id of created/found toolbar +*/ int QtxActionToolMgr::createToolBar( const QString& title, bool floatable, Qt::ToolBarAreas dockAreas, - int tid, QMainWindow* mw ) + int tid, QMainWindow* mw, bool vis ) { static int _toolBarId = -1; @@ -141,7 +156,8 @@ int QtxActionToolMgr::createToolBar( const QString& title, bool floatable, Qt::T tb->setWindowTitle( title ); tb->setObjectName( title ); tb->setToolTip( title ); - QApplication::postEvent( tb, new QHideEvent()); + if ( !vis ) + QApplication::postEvent( tb, new QHideEvent()); } tInfo.toolBar = tb; diff --git a/src/Qtx/QtxActionToolMgr.h b/src/Qtx/QtxActionToolMgr.h index 1a8fae787..6fbda0828 100644 --- a/src/Qtx/QtxActionToolMgr.h +++ b/src/Qtx/QtxActionToolMgr.h @@ -65,9 +65,9 @@ public: QMainWindow* mainWindow() const; - int createToolBar( const QString&, int = -1, QMainWindow* = 0 ); + int createToolBar( const QString&, int = -1, QMainWindow* = 0, bool = true ); int createToolBar( const QString&, bool, Qt::ToolBarAreas = Qt::AllToolBarAreas, - int = -1, QMainWindow* = 0 ); + int = -1, QMainWindow* = 0, bool = true ); void removeToolBar( const QString& ); void removeToolBar( const int ); -- 2.39.2