diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index b46243753..7d65b1423 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -225,7 +225,7 @@ bool BitmapFactoryInst::loadPixmap(const QString& filename, QPixmap& icon) const QPixmap BitmapFactoryInst::pixmap(const char* name) const { if (!name || *name == '\0') - return QPixmap(px); + return QPixmap(); // as very first test check whether the pixmap is in the cache QMap::ConstIterator it = d->xpmCache.find(name); diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index 483041644..bfcd1fff7 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -1094,7 +1094,8 @@ bool PythonGroupCommand::isActive(void) Action * PythonGroupCommand::createAction(void) { Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); - pcAction->setDropDownMenu(true); + pcAction->setDropDownMenu(hasDropDownMenu()); + pcAction->setExclusive(isExclusive()); applyCommandData(this->getName(), pcAction); @@ -1103,6 +1104,7 @@ Action * PythonGroupCommand::createAction(void) try { Base::PyGILStateLocker lock; Py::Object cmd(_pcPyCommand); + Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); Py::Callable call(cmd.getAttr("GetCommands")); Py::Tuple args; @@ -1111,6 +1113,11 @@ Action * PythonGroupCommand::createAction(void) Py::String str(*it); QAction* cmd = pcAction->addAction(QString()); cmd->setProperty("CommandName", QByteArray(static_cast(str).c_str())); + + PythonCommand* pycmd = dynamic_cast(rcCmdMgr.getCommandByName(cmd->property("CommandName").toByteArray())); + if (pycmd) { + cmd->setCheckable(pycmd->isCheckable()); + } } if (cmd.hasAttr("GetDefaultCommand")) { @@ -1229,6 +1236,38 @@ const char* PythonGroupCommand::getAccel() const return getResource("Accel"); } +bool PythonGroupCommand::isExclusive() const +{ + PyObject* item = PyDict_GetItemString(_pcPyResource,"Exclusive"); + if (!item) { + return false; + } + + if (PyBool_Check(item)) { + return PyObject_IsTrue(item) ? true : false; + } + else { + throw Base::Exception("PythonGroupCommand::isExclusive(): Method GetResources() of the Python " + "command object contains the key 'Exclusive' which is not a boolean"); + } +} + +bool PythonGroupCommand::hasDropDownMenu() const +{ + PyObject* item = PyDict_GetItemString(_pcPyResource,"DropDownMenu"); + if (!item) { + return true; + } + + if (PyBool_Check(item)) { + return PyObject_IsTrue(item) ? true : false; + } + else { + throw Base::Exception("PythonGroupCommand::hasDropDownMenu(): Method GetResources() of the Python " + "command object contains the key 'DropDownMenu' which is not a boolean"); + } +} + //=========================================================================== // CommandManager //=========================================================================== diff --git a/src/Gui/Command.h b/src/Gui/Command.h index 22dde1b8d..99a669d76 100644 --- a/src/Gui/Command.h +++ b/src/Gui/Command.h @@ -402,6 +402,8 @@ public: const char* getStatusTip () const; const char* getPixmap () const; const char* getAccel () const; + bool isExclusive () const; + bool hasDropDownMenu () const; //@} protected: