From 56d8f22fc5bd671b2bb2d62bcddafe3c09510a4c Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Tue, 3 Sep 2019 21:02:01 +0800 Subject: [PATCH] Gui: restore tree view content menu action order --- src/Gui/Tree.cpp | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 8c7b64a357..1776c94d4b 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -785,8 +785,6 @@ void TreeWidget::contextMenuEvent (QContextMenuEvent * e) { // ask workbenches and view provider, ... MenuItem view; - view << "Std_TreeViewActions"; - Gui::Application::Instance->setupContextMenu("Tree", &view); view << "Std_Expressions"; @@ -836,32 +834,6 @@ void TreeWidget::contextMenuEvent (QContextMenuEvent * e) DocumentObjectItem* objitem = static_cast (this->contextItem); - auto selItems = this->selectedItems(); - // if only one item is selected setup the edit menu - if (selItems.size() == 1) { - - auto cmd = Gui::Application::Instance->commandManager().getCommandByName("Std_LinkSelectLinked"); - if(cmd && cmd->isActive()) - cmd->addTo(&contextMenu); - cmd = Gui::Application::Instance->commandManager().getCommandByName("Std_LinkSelectLinkedFinal"); - if(cmd && cmd->isActive()) - cmd->addTo(&contextMenu); - - objitem->object()->setupContextMenu(&editMenu, this, SLOT(onStartEditing())); - QList editAct = editMenu.actions(); - if (!editAct.isEmpty()) { - contextMenu.addSeparator(); - for (QList::iterator it = editAct.begin(); it != editAct.end(); ++it) - contextMenu.addAction(*it); - QAction* first = editAct.front(); - contextMenu.setDefaultAction(first); - if (objitem->object()->isEditing()) - contextMenu.addAction(finishEditingAction); - } - } - - contextMenu.addSeparator(); - App::Document* doc = objitem->object()->getObject()->getDocument(); showHiddenAction->setChecked(doc->ShowHidden.getValue()); contextMenu.addAction(this->showHiddenAction); @@ -869,14 +841,29 @@ void TreeWidget::contextMenuEvent (QContextMenuEvent * e) hideInTreeAction->setChecked(!objitem->object()->showInTree()); contextMenu.addAction(this->hideInTreeAction); - contextMenu.addAction(this->searchObjectsAction); - if (objitem->object()->getObject()->isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) contextMenu.addAction(this->createGroupAction); contextMenu.addAction(this->markRecomputeAction); contextMenu.addAction(this->recomputeObjectAction); contextMenu.addAction(this->relabelObjectAction); + + auto selItems = this->selectedItems(); + // if only one item is selected setup the edit menu + if (selItems.size() == 1) { + objitem->object()->setupContextMenu(&editMenu, this, SLOT(onStartEditing())); + QList editAct = editMenu.actions(); + if (!editAct.isEmpty()) { + QAction* topact = contextMenu.actions().front(); + for (QList::iterator it = editAct.begin(); it != editAct.end(); ++it) + contextMenu.insertAction(topact,*it); + QAction* first = editAct.front(); + contextMenu.setDefaultAction(first); + if (objitem->object()->isEditing()) + contextMenu.insertAction(topact, this->finishEditingAction); + contextMenu.insertSeparator(topact); + } + } }