Gui: [skip ci] add method to return list of QAction of a Command
This commit is contained in:
@@ -94,5 +94,10 @@ Usage: menuText, tooltipText, whatsThisText, statustipText, pixmapText, shortcut
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getAction">
|
||||
<Documentation>
|
||||
<UserDocu>getAction() -> list of QAction</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "MainWindow.h"
|
||||
#include "Selection.h"
|
||||
#include "Window.h"
|
||||
#include "WidgetFactory.h"
|
||||
|
||||
// inclusion of the generated files (generated out of AreaPy.xml)
|
||||
#include "CommandPy.h"
|
||||
@@ -311,6 +312,36 @@ PyObject* CommandPy::getInfo(PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* CommandPy::getAction(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return nullptr;
|
||||
|
||||
Command* cmd = this->getCommandPtr();
|
||||
if (cmd) {
|
||||
Action* action = cmd->getAction();
|
||||
ActionGroup* group = qobject_cast<ActionGroup*>(action);
|
||||
|
||||
PythonWrapper wrap;
|
||||
wrap.loadWidgetsModule();
|
||||
|
||||
Py::List list;
|
||||
if (group) {
|
||||
for (auto a : group->actions())
|
||||
list.append(wrap.fromQObject(a));
|
||||
}
|
||||
else if (action) {
|
||||
list.append(wrap.fromQObject(action->action()));
|
||||
}
|
||||
|
||||
return Py::new_reference_to(list);
|
||||
}
|
||||
else {
|
||||
PyErr_Format(Base::BaseExceptionFreeCADError, "No such command");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *CommandPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user