+ allow to set a default action for an exclusive group

This commit is contained in:
wmayer 2015-09-20 15:47:11 +02:00
parent ec91085765
commit cda9bf9ed5
3 changed files with 19 additions and 0 deletions

View File

@ -266,6 +266,11 @@ void ActionGroup::setExclusive (bool b)
_group->setExclusive(b);
}
bool ActionGroup::isExclusive() const
{
return _group->isExclusive();
}
void ActionGroup::setVisible( bool b )
{
Action::setVisible(b);

View File

@ -100,6 +100,7 @@ public:
void setEnabled (bool);
void setDisabled (bool);
void setExclusive (bool);
bool isExclusive() const;
void setVisible (bool);
void setDropDownMenu(bool b) { _dropDown = b; }

View File

@ -1151,6 +1151,19 @@ Action * PythonGroupCommand::createAction(void)
Py::Int def(call2.apply(args));
defaultId = static_cast<int>(def);
}
// if the command is 'exclusive' then activate the default action
if (pcAction->isExclusive()) {
QList<QAction*> a = pcAction->actions();
if (defaultId >= 0 && defaultId < a.size()) {
QAction* qtAction = a[defaultId];
if (qtAction->isCheckable()) {
qtAction->blockSignals(true);
qtAction->setChecked(true);
qtAction->blockSignals(false);
}
}
}
}
catch(Py::Exception&) {
Base::PyGILStateLocker lock;