Skip to content

Commit

Permalink
Gui: restore tree view content menu action order
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder authored and wwmayer committed Sep 10, 2019
1 parent b991b8c commit 56d8f22
Showing 1 changed file with 17 additions and 30 deletions.
47 changes: 17 additions & 30 deletions src/Gui/Tree.cpp
Expand Up @@ -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";
Expand Down Expand Up @@ -836,47 +834,36 @@ void TreeWidget::contextMenuEvent (QContextMenuEvent * e)
DocumentObjectItem* objitem = static_cast<DocumentObjectItem*>
(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<QAction*> editAct = editMenu.actions();
if (!editAct.isEmpty()) {
contextMenu.addSeparator();
for (QList<QAction*>::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);

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<QAction*> editAct = editMenu.actions();
if (!editAct.isEmpty()) {
QAction* topact = contextMenu.actions().front();
for (QList<QAction*>::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);
}
}
}


Expand Down

0 comments on commit 56d8f22

Please sign in to comment.