From: vsv Date: Tue, 20 May 2014 08:31:36 +0000 (+0400) Subject: Provide pop-up menu in Salome mode. X-Git-Tag: V_0.2~35^2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cdb49285fe1a5fd592113f9e5337b005251bf240;p=modules%2Fshaper.git Provide pop-up menu in Salome mode. --- diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 4dc852f9a..f5d55c8db 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -78,7 +78,7 @@ void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent) QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const { - QMenu* aMenu = new QMenu(); + QList aActions; XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); QFeatureList aFeatures = aSelMgr->selectedFeatures(); if (aFeatures.size() == 1) { @@ -89,23 +89,25 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const if (aFeature->getKind() == "Part") { boost::shared_ptr aFeaDoc = aFeature->data()->docRef("PartDocument")->value(); if (aMgr->currentDocument() == aFeaDoc) - aMenu->addAction(action("DEACTIVATE_PART_CMD")); + aActions.append(action("DEACTIVATE_PART_CMD")); else - aMenu->addAction(action("ACTIVATE_PART_CMD")); + aActions.append(action("ACTIVATE_PART_CMD")); } else { - aMenu->addAction(action("EDIT_CMD")); + aActions.append(action("EDIT_CMD")); } // Process Root object (document) } else { // If feature is 0 the it means that selected root object (document) if (aMgr->currentDocument() != aMgr->rootDocument()) { - aMenu->addAction(action("ACTIVATE_PART_CMD")); + aActions.append(action("ACTIVATE_PART_CMD")); } } } - if (aMenu->actions().size() > 0) + if (aActions.size() > 0) { + QMenu* aMenu = new QMenu(); + aMenu->addActions(aActions); return aMenu; - delete aMenu; + } return 0; } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 60c7f0b5b..ce8b59a8e 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -127,6 +127,8 @@ void XGUI_Workshop::startApplication() //****************************************************** void XGUI_Workshop::initMenu() { + myContextMenuMgr->createActions(); + if (isSalomeMode()) { // Create only Undo, Redo commands QAction* aAction = salomeConnector()->addEditCommand("UNDO_CMD", @@ -181,8 +183,6 @@ void XGUI_Workshop::initMenu() aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"), QIcon(":pictures/close.png"), QKeySequence::Close); aCommand->connectTo(this, SLOT(onExit())); - - myContextMenuMgr->createActions(); } //******************************************************