Skip to content

Commit

Permalink
Customize menus
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddleStroke committed Jan 6, 2025
1 parent d735cdd commit 54f6027
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/Gui/Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ void TreeWidget::contextMenuEvent(QContextMenuEvent* e)
MenuItem view;
Gui::Application::Instance->setupContextMenu("Tree", &view);

view << "Std_Properties" << "Separator" << "Std_Expressions";
view << "Std_Group" << "Separator" << "Std_Properties" << "Separator" << "Std_Expressions";
Workbench::createLinkMenu(&view);

QMenu contextMenu;
Expand Down
38 changes: 8 additions & 30 deletions src/Gui/Workbench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,19 +580,16 @@ void StdWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
{
if (strcmp(recipient,"View") == 0)
{
createLinkMenu(item);
*item << "Separator";

auto StdViews = new MenuItem;
StdViews->setCommand( "Standard views" );

*StdViews << "Std_ViewIsometric" << "Separator" << "Std_ViewHome" << "Std_ViewFront" << "Std_ViewTop" << "Std_ViewRight"
<< "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft"
<< "Separator" << "Std_ViewRotateLeft" << "Std_ViewRotateRight";

*item << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_AlignToSelection" << "Std_DrawStyle"
<< StdViews << "Separator"
<< "Std_ViewDockUndockFullscreen";
*item << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_AlignToSelection"
<< "Separator" << StdViews
<< "Separator" << "Std_DrawStyle" << "Std_ViewDockUndockFullscreen";

if (Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0) {
*item << "Separator" << "Std_ToggleVisibility"
Expand Down Expand Up @@ -776,18 +773,10 @@ ToolBarItem* StdWorkbench::setupToolBars() const
// File
auto file = new ToolBarItem( root );
file->setCommand("File");
*file << "Std_New" << "Std_Open" << "Std_Save";

// Edit
auto edit = new ToolBarItem( root );
edit->setCommand("Edit");
*edit << "Std_Undo" << "Std_Redo"
<< "Separator" << "Std_Refresh";

// Clipboard
auto clipboard = new ToolBarItem( root , ToolBarItem::DefaultVisibility::Hidden );
clipboard->setCommand("Clipboard");
*clipboard << "Std_Cut" << "Std_Copy" << "Std_Paste";
*file << "Std_NewGroup" << "Std_OpenGroup" << "Std_SaveGroup"
<< "Separator" << "Std_Undo" << "Std_Redo" << "Std_Refresh"
<< "Separator" << "Std_VarSet" << "Std_TextDocument"
<< "Separator" << "Std_ToolsGroup";

// Workbench switcher
auto wb = new ToolBarItem(root);
Expand All @@ -800,12 +789,6 @@ ToolBarItem* StdWorkbench::setupToolBars() const
*macro << "Std_DlgMacroRecord" << "Std_DlgMacroExecute"
<< "Std_DlgMacroExecuteDirect";

// View
auto view = new ToolBarItem( root );
view->setCommand("View");
*view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewGroup" << "Std_AlignToSelection"
<< "Separator" << "Std_DrawStyle" << "Std_TreeViewActions";

// Individual views
auto individualViews = new ToolBarItem(root, ToolBarItem::DefaultVisibility::Hidden);
individualViews->setCommand("Individual views");
Expand All @@ -817,15 +800,10 @@ ToolBarItem* StdWorkbench::setupToolBars() const
<< "Std_ViewBottom"
<< "Std_ViewLeft";

// Structure
auto structure = new ToolBarItem( root );
structure->setCommand("Structure");
*structure << "Std_Part" << "Std_Group" << "Std_VarSet";

// Help
auto help = new ToolBarItem( root );
help->setCommand("Help");
*help << "Std_WhatsThis";
*help << "Std_HelpGroup";

return root;
}
Expand Down
13 changes: 10 additions & 3 deletions src/Mod/Measure/Gui/WorkbenchManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ void WorkbenchManipulator::modifyMenuBar([[maybe_unused]] Gui::MenuItem* menuBar

void WorkbenchManipulator::modifyToolBars(Gui::ToolBarItem* toolBar)
{
auto tbView = toolBar->findItem("View");
if (!tbView) {
auto tb = toolBar->findItem("File");
if (!tb) {
return;
}

auto itemMeasure = new Gui::ToolBarItem();
itemMeasure->setCommand("Std_Measure");
tbView->appendItem(itemMeasure);

auto item = tb->findItem("Std_ToolsGroup");
if (item) {
tb->insertItem(item, itemMeasure);
}
else {
tb->appendItem(itemMeasure);
}
}
4 changes: 2 additions & 2 deletions src/Mod/Part/Gui/WorkbenchManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ void WorkbenchManipulator::addSelectionFilter(Gui::ToolBarItem* toolBar)

void WorkbenchManipulator::addDatums(Gui::ToolBarItem* toolBar)
{
if (auto view = toolBar->findItem("Structure")) {
if (auto view = toolBar->findItem("File")) {
auto add = new Gui::ToolBarItem(); // NOLINT
add->setCommand("Part_Datums");
auto item = view->findItem("Std_Group");
auto item = view->findItem("Std_VarSet");
if (item) {
view->insertItem(item, add);
}
Expand Down

0 comments on commit 54f6027

Please sign in to comment.