From 1a3fb02eb9d905d99dbf2b0b08d3d0592fbb20de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Fri, 28 Jul 2017 19:54:13 +0200 Subject: [PATCH] Move App::Part to a separate global toolbar --- src/Gui/Application.cpp | 1 + src/Gui/CMakeLists.txt | 1 + src/Gui/Command.h | 1 + src/Gui/Workbench.cpp | 6 ++++ src/Mod/PartDesign/Gui/CommandBody.cpp | 45 -------------------------- src/Mod/PartDesign/Gui/Workbench.cpp | 7 ++-- 6 files changed, 11 insertions(+), 50 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 6ea262a5e2..2010dbfcab 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -649,6 +649,7 @@ void Application::createStandardOperations() Gui::CreateMacroCommands(); Gui::CreateViewStdCommands(); Gui::CreateWindowStdCommands(); + Gui::CreateStructureCommands(); Gui::CreateTestCommands(); } diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 4839548443..bc843a6432 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -397,6 +397,7 @@ SET(Command_CPP_SRCS CommandWindow.cpp CommandTest.cpp CommandView.cpp + CommandStructure.cpp ) SET(Command_SRCS ${Command_CPP_SRCS} diff --git a/src/Gui/Command.h b/src/Gui/Command.h index 3076560268..b257360ed6 100644 --- a/src/Gui/Command.h +++ b/src/Gui/Command.h @@ -61,6 +61,7 @@ void CreateFeatCommands(void); void CreateMacroCommands(void); void CreateViewStdCommands(void); void CreateWindowStdCommands(void); +void CreateStructureCommands(void); void CreateTestCommands(void); diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index 65d3988d6c..6f148a1a41 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -622,6 +622,12 @@ ToolBarItem* StdWorkbench::setupToolBars() const *view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_DrawStyle" << "Separator" << "Std_ViewAxo" << "Separator" << "Std_ViewFront" << "Std_ViewTop" << "Std_ViewRight" << "Separator" << "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft" << "Separator" << "Std_MeasureDistance" ; + + // Structure + ToolBarItem* structure = new ToolBarItem( root ); + structure->setCommand("Structure"); + *structure << "Std_Part"; + return root; } diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index e6003d5f8a..d64d56124f 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -75,50 +75,6 @@ App::Part* assertActivePart () { } /* PartDesignGui */ -//=========================================================================== -// PartDesign_Part -//=========================================================================== -DEF_STD_CMD_A(CmdPartDesignPart); - -CmdPartDesignPart::CmdPartDesignPart() - : Command("PartDesign_Part") -{ - sAppModule = "PartDesign"; - sGroup = QT_TR_NOOP("PartDesign"); - sMenuText = QT_TR_NOOP("Create part"); - sToolTipText = QT_TR_NOOP("Create a new part and make it active"); - sWhatsThis = "PartDesign_Part"; - sStatusTip = sToolTipText; - sPixmap = "Tree_Annotation"; -} - -void CmdPartDesignPart::activated(int iMsg) -{ - Q_UNUSED(iMsg); - if ( !PartDesignGui::assureModernWorkflow( getDocument() ) ) - return; - - openCommand("Add a part"); - std::string FeatName = getUniqueObjectName("Part"); - - std::string PartName; - PartName = getUniqueObjectName("Part"); - doCommand(Doc,"App.activeDocument().Tip = App.activeDocument().addObject('App::Part','%s')",PartName.c_str()); - // TODO We really must to set label ourselfs? (2015-08-17, Fat-Zer) - doCommand(Doc,"App.activeDocument().%s.Label = '%s'", PartName.c_str(), - QObject::tr(PartName.c_str()).toUtf8().data()); - doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", - PARTKEY, PartName.c_str()); - - updateActive(); -} - -bool CmdPartDesignPart::isActive(void) -{ - return hasActiveDocument() && !PartDesignGui::isLegacyWorkflow ( getDocument () ); -} - -//=========================================================================== // PartDesign_Body //=========================================================================== DEF_STD_CMD_A(CmdPartDesignBody); @@ -869,7 +825,6 @@ void CreatePartDesignBodyCommands(void) { Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); - rcCmdMgr.addCommand(new CmdPartDesignPart()); rcCmdMgr.addCommand(new CmdPartDesignBody()); rcCmdMgr.addCommand(new CmdPartDesignMigrate()); rcCmdMgr.addCommand(new CmdPartDesignMoveTip()); diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 9a87c917ea..8be2e6ad67 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -341,7 +341,6 @@ void Workbench::activated() const char* NoSel[] = { "PartDesign_Body", - "PartDesign_Part", 0}; Watcher.push_back(new Gui::TaskView::TaskWatcherCommandsEmptySelection( NoSel, @@ -436,8 +435,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const Gui::MenuItem* part = new Gui::MenuItem; root->insertItem(item, part); part->setCommand("&Part Design"); - *part << "PartDesign_Part" - << "PartDesign_Body" + *part << "PartDesign_Body" << "PartDesign_NewSketch" << "Sketcher_LeaveSketch" << "Sketcher_ViewSketch" @@ -504,8 +502,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const Gui::ToolBarItem* root = StdWorkbench::setupToolBars(); Gui::ToolBarItem* part = new Gui::ToolBarItem(root); part->setCommand("Part Design Helper"); - *part << "PartDesign_Part" - << "PartDesign_Body" + *part << "PartDesign_Body" << "PartDesign_NewSketch" << "Sketcher_EditSketch" << "Sketcher_MapSketch"