From 009056672473e5325d331c724253c3f25bc5db7f Mon Sep 17 00:00:00 2001 From: Kris <37947442+OfficialKris@users.noreply.github.com> Date: Wed, 18 Jun 2025 23:33:36 -0700 Subject: [PATCH] Gui: Move Submenu Commands in Tool Menu (#20864) * Moved tools submenu commands and title case * Apply suggestions from code review Co-authored-by: Max Wilfinger <6246609+maxwxyz@users.noreply.github.com> --------- Co-authored-by: Kacper Donat Co-authored-by: Max Wilfinger <6246609+maxwxyz@users.noreply.github.com> --- src/Gui/CommandStd.cpp | 8 +-- src/Gui/Workbench.cpp | 25 +++++----- src/Mod/Measure/Gui/AppMeasureGui.cpp | 4 -- src/Mod/Measure/Gui/CMakeLists.txt | 2 - src/Mod/Measure/Gui/WorkbenchManipulator.cpp | 51 -------------------- src/Mod/Measure/Gui/WorkbenchManipulator.h | 41 ---------------- 6 files changed, 17 insertions(+), 114 deletions(-) delete mode 100644 src/Mod/Measure/Gui/WorkbenchManipulator.cpp delete mode 100644 src/Mod/Measure/Gui/WorkbenchManipulator.h diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index e8089ff289..2837ccd190 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -379,9 +379,9 @@ StdCmdDlgParameter::StdCmdDlgParameter() { sGroup = "Tools"; sMenuText = QT_TR_NOOP("E&dit parameters..."); - sToolTipText = QT_TR_NOOP("Opens a Dialog to edit the parameters"); + sToolTipText = QT_TR_NOOP("Opens a dialog to edit the parameters"); sWhatsThis = "Std_DlgParameter"; - sStatusTip = QT_TR_NOOP("Opens a Dialog to edit the parameters"); + sStatusTip = QT_TR_NOOP("Opens a dialog to edit the parameters"); sPixmap = "Std_DlgParameter"; eType = 0; } @@ -404,9 +404,9 @@ StdCmdDlgPreferences::StdCmdDlgPreferences() { sGroup = "Tools"; sMenuText = QT_TR_NOOP("Prefere&nces ..."); - sToolTipText = QT_TR_NOOP("Opens a Dialog to edit the preferences"); + sToolTipText = QT_TR_NOOP("Opens a dialog to edit the preferences"); sWhatsThis = "Std_DlgPreferences"; - sStatusTip = QT_TR_NOOP("Opens a Dialog to edit the preferences"); + sStatusTip = QT_TR_NOOP("Opens a dialog to edit the preferences"); sPixmap = "preferences-system"; eType = 0; sAccel = "Ctrl+,"; diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index 6aecbb3b49..5acad2bc8f 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -718,24 +718,25 @@ MenuItem* StdWorkbench::setupMenuBar() const // Tools auto tool = new MenuItem( menuBar ); tool->setCommand("&Tools"); - *tool << "Std_DlgParameter" +#ifdef BUILD_ADDONMGR + *tool << "Std_AddonMgr" + << "Separator"; +#endif + *tool << "Std_Measure" + << "Std_UnitsCalculator" << "Separator" - << "Std_ViewScreenShot" << "Std_ViewLoadImage" + << "Std_ViewScreenShot" + << "Std_TextDocument" + << "Std_DemoMode" + << "Separator" << "Std_SceneInspector" << "Std_DependencyGraph" << "Std_ExportDependencyGraph" + << "Separator" << "Std_ProjectUtil" - << "Separator" - << "Std_TextDocument" - << "Separator" - << "Std_DemoMode" - << "Std_UnitsCalculator" - << "Separator" + << "Std_DlgParameter" << "Std_DlgCustomize"; -#ifdef BUILD_ADDONMGR - *tool << "Std_AddonMgr"; -#endif // Macro auto macro = new MenuItem( menuBar ); @@ -811,7 +812,7 @@ ToolBarItem* StdWorkbench::setupToolBars() const auto view = new ToolBarItem( root ); view->setCommand("View"); *view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewGroup" << "Std_AlignToSelection" - << "Separator" << "Std_DrawStyle" << "Std_TreeViewActions"; + << "Separator" << "Std_DrawStyle" << "Std_TreeViewActions" << "Std_Measure"; // Individual views auto individualViews = new ToolBarItem(root, ToolBarItem::DefaultVisibility::Hidden); diff --git a/src/Mod/Measure/Gui/AppMeasureGui.cpp b/src/Mod/Measure/Gui/AppMeasureGui.cpp index 2897c1591b..4da57110ef 100644 --- a/src/Mod/Measure/Gui/AppMeasureGui.cpp +++ b/src/Mod/Measure/Gui/AppMeasureGui.cpp @@ -37,7 +37,6 @@ #include "ViewProviderMeasureAngle.h" #include "ViewProviderMeasureDistance.h" #include "ViewProviderMeasureBase.h" -#include "WorkbenchManipulator.h" // use a different name to CreateCommand() @@ -87,9 +86,6 @@ PyMOD_INIT_FUNC(MeasureGui) PyObject* mod = MeasureGui::initModule(); Base::Console().log("Loading GUI of Measure module... done\n"); - auto manip = std::make_shared(); - Gui::WorkbenchManipulator::installManipulator(manip); - // instantiating the commands CreateMeasureCommands(); diff --git a/src/Mod/Measure/Gui/CMakeLists.txt b/src/Mod/Measure/Gui/CMakeLists.txt index ef1909afc1..68acddfbbe 100644 --- a/src/Mod/Measure/Gui/CMakeLists.txt +++ b/src/Mod/Measure/Gui/CMakeLists.txt @@ -50,8 +50,6 @@ SET(MeasureGui_SRCS ViewProviderMeasureAngle.h ViewProviderMeasureDistance.cpp ViewProviderMeasureDistance.h - WorkbenchManipulator.cpp - WorkbenchManipulator.h DlgPrefsMeasureAppearanceImp.ui DlgPrefsMeasureAppearanceImp.cpp DlgPrefsMeasureAppearanceImp.h diff --git a/src/Mod/Measure/Gui/WorkbenchManipulator.cpp b/src/Mod/Measure/Gui/WorkbenchManipulator.cpp deleted file mode 100644 index 0041db16d7..0000000000 --- a/src/Mod/Measure/Gui/WorkbenchManipulator.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2024 David Friedli * - * * - * This file is part of FreeCAD. * - * * - * FreeCAD is free software: you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 2.1 of the * - * License, or (at your option) any later version. * - * * - * FreeCAD is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with FreeCAD. If not, see * - * . * - * * - **************************************************************************/ - - -#include "PreCompiled.h" -#include "WorkbenchManipulator.h" -#include -#include - -using namespace MeasureGui; - -void WorkbenchManipulator::modifyMenuBar([[maybe_unused]] Gui::MenuItem* menuBar) -{ - auto menuTools = menuBar->findItem("&Tools"); - if (!menuTools) { - return; - } - auto itemMeasure = new Gui::MenuItem(); - itemMeasure->setCommand("Std_Measure"); - menuTools->appendItem(itemMeasure); -} - -void WorkbenchManipulator::modifyToolBars(Gui::ToolBarItem* toolBar) -{ - auto tbView = toolBar->findItem("View"); - if (!tbView) { - return; - } - - auto itemMeasure = new Gui::ToolBarItem(); - itemMeasure->setCommand("Std_Measure"); - tbView->appendItem(itemMeasure); -} diff --git a/src/Mod/Measure/Gui/WorkbenchManipulator.h b/src/Mod/Measure/Gui/WorkbenchManipulator.h deleted file mode 100644 index 767f1e058c..0000000000 --- a/src/Mod/Measure/Gui/WorkbenchManipulator.h +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2024 David Friedli * - * * - * This file is part of FreeCAD. * - * * - * FreeCAD is free software: you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 2.1 of the * - * License, or (at your option) any later version. * - * * - * FreeCAD is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with FreeCAD. If not, see * - * . * - * * - **************************************************************************/ - - -#ifndef MEASUREGUI_WORKBENCHMANIPULATOR_H -#define MEASUREGUI_WORKBENCHMANIPULATOR_H - -#include - -namespace MeasureGui -{ - -class WorkbenchManipulator: public Gui::WorkbenchManipulator -{ -protected: - void modifyMenuBar(Gui::MenuItem* menuBar) override; - void modifyToolBars(Gui::ToolBarItem* toolBar) override; -}; - -} // namespace MeasureGui - - -#endif // MEASUREGUI_WORKBENCHMANIPULATOR_H