From fcaa312616cb30cec6df1708d890bb7ca2ebd05f Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Thu, 17 Nov 2022 10:09:23 +0100 Subject: [PATCH] Gui: ActionGroup also get its tooltip title updated --- src/Gui/Action.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index acebae6c9a..5280ac6b4b 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -330,11 +330,15 @@ int ActionGroup::checkedAction() const void ActionGroup::setCheckedAction(int i) { - QAction* a = _group->actions()[i]; - a->setChecked(true); - this->setIcon(a->icon()); - if (!this->_isMode) this->setToolTip(a->toolTip()); - this->setProperty("defaultAction", QVariant(i)); + auto acts = groupAction()->actions(); + QAction* act = acts.at(index); + act->setChecked(true); + this->setIcon(act->icon()); + + if (!this->_isMode) { + this->setToolTip(act->toolTip(), act->text()); + } + this->setProperty("defaultAction", QVariant(index)); } /** @@ -357,21 +361,9 @@ void ActionGroup::onActivated (QAction* a) { int index = _group->actions().indexOf(a); - // Calling QToolButton::setIcon() etc. has no effect if it has QAction set. - // We have to change the QAction icon instead -#if 0 - QList widgets = a->associatedWidgets(); - for (QList::iterator it = widgets.begin(); it != widgets.end(); ++it) { - QMenu* menu = qobject_cast(*it); - if (menu) { - QToolButton* button = qobject_cast(menu->parent()); - if (button) { - button->setIcon(a->icon()); - button->setText(a->text()); - button->setToolTip(a->toolTip()); - this->setProperty("defaultAction", QVariant(index)); - } - } + this->setIcon(act->icon()); + if (!this->_isMode) { + this->setToolTip(act->toolTip(), act->text()); } #endif this->setIcon(a->icon());