From cda9bf9ed52d378076d20afb4b57f0a825d8fa74 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 20 Sep 2015 15:47:11 +0200 Subject: [PATCH] + allow to set a default action for an exclusive group --- src/Gui/Action.cpp | 5 +++++ src/Gui/Action.h | 1 + src/Gui/Command.cpp | 13 +++++++++++++ 3 files changed, 19 insertions(+) diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index 371c89fe1..c71d18630 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -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); diff --git a/src/Gui/Action.h b/src/Gui/Action.h index 87ee898f5..c323dac35 100644 --- a/src/Gui/Action.h +++ b/src/Gui/Action.h @@ -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; } diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index 2cd85c39a..b79ce16cb 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -1151,6 +1151,19 @@ Action * PythonGroupCommand::createAction(void) Py::Int def(call2.apply(args)); defaultId = static_cast(def); } + + // if the command is 'exclusive' then activate the default action + if (pcAction->isExclusive()) { + QList 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;