]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide pop-up menu in Salome mode.
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 20 May 2014 08:31:36 +0000 (12:31 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 20 May 2014 08:31:36 +0000 (12:31 +0400)
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index 4dc852f9a4d7178e80976f36d56dfbca31bf0ef0..f5d55c8dbbf3736bec921f6e69396e2b4d3fb18b 100644 (file)
@@ -78,7 +78,7 @@ void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent)
 
 QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
 {
-  QMenu* aMenu = new QMenu();
+  QList<QAction*> 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<ModelAPI_Document> 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;
 }
 
index 60c7f0b5bf8c56d814ce347479666f046a89dcee..ce8b59a8ee3f7545955b0cff2d8697cac8e1cec5 100644 (file)
@@ -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();
 }
 
 //******************************************************