From 35fd97a8ae968437e12259f4c1b6610dd61d3079 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 16 Feb 2022 17:33:29 +0100 Subject: [PATCH] Gui: add method to reload active workbench --- src/Gui/FreeCADGuiInit.py | 2 ++ src/Gui/PythonWorkbenchPy.xml | 5 +++++ src/Gui/PythonWorkbenchPyImp.cpp | 15 +++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/src/Gui/FreeCADGuiInit.py b/src/Gui/FreeCADGuiInit.py index bc3a6e12b7..332be657cc 100644 --- a/src/Gui/FreeCADGuiInit.py +++ b/src/Gui/FreeCADGuiInit.py @@ -73,6 +73,8 @@ class Workbench: self.__Workbench__.appendContextMenu(name, cmds) def removeContextMenu(self,name): self.__Workbench__.removeContextMenu(name) + def reloadActive(self): + self.__Workbench__.reloadActive() def name(self): return self.__Workbench__.name() def GetClassName(self): diff --git a/src/Gui/PythonWorkbenchPy.xml b/src/Gui/PythonWorkbenchPy.xml index 9232ff9e86..344e467344 100644 --- a/src/Gui/PythonWorkbenchPy.xml +++ b/src/Gui/PythonWorkbenchPy.xml @@ -53,6 +53,11 @@ Remove a command bar + + + Reload the active workbench after changing menus or toolbars + + deprecated -- use appendMenu diff --git a/src/Gui/PythonWorkbenchPyImp.cpp b/src/Gui/PythonWorkbenchPyImp.cpp index 6a4b5d7a3f..db609a3895 100644 --- a/src/Gui/PythonWorkbenchPyImp.cpp +++ b/src/Gui/PythonWorkbenchPyImp.cpp @@ -24,6 +24,7 @@ #include "PreCompiled.h" #include "Workbench.h" +#include "WorkbenchManager.h" // inclusion of the generated files (generated out of PythonWorkbenchPy.xml) #include "PythonWorkbenchPy.h" @@ -274,6 +275,20 @@ PyObject* PythonWorkbenchPy::removeCommandbar(PyObject *args) } PY_CATCH; } +/** Reload the workbench */ +PyObject* PythonWorkbenchPy::reloadActive(PyObject *args) +{ + PY_TRY { + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + Workbench* active = Gui::WorkbenchManager::instance()->active(); + if (active) + active->activate(); + Py_Return; + } PY_CATCH; +} + PyObject* PythonWorkbenchPy::getCustomAttributes(const char* ) const { return nullptr;