From c87c492ada478ced8f06fb003d21f0e0a3c9f707 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Sat, 15 May 2021 11:26:20 +0200 Subject: [PATCH] [Gui] ActionGroup can declared being a "Mode" action This will essentially not update the tooltip when an action is checked as it isn't suitable As example, view DrawStyle command where the group tooltip is better than the selected action tooltip Only UserEditMode is implemented in this commit, should be pushed to DrawStyle and maybe other after merge --- src/Gui/Action.cpp | 6 +++--- src/Gui/Action.h | 2 ++ src/Gui/CommandStd.cpp | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index 9fea44fa97..a8fa8503c3 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -227,7 +227,7 @@ void Action::setMenuRole(QAction::MenuRole menuRole) * to the command object. */ ActionGroup::ActionGroup ( Command* pcCmd,QObject * parent) - : Action(pcCmd, parent), _group(0), _dropDown(false),_external(false),_toggle(false) + : Action(pcCmd, parent), _group(0), _dropDown(false),_external(false),_toggle(false),_isMode(false) { _group = new QActionGroup(this); connect(_group, SIGNAL(triggered(QAction*)), this, SLOT(onActivated (QAction*))); @@ -336,7 +336,7 @@ void ActionGroup::setCheckedAction(int i) QAction* a = _group->actions()[i]; a->setChecked(true); this->setIcon(a->icon()); - this->setToolTip(a->toolTip()); + if (!this->_isMode) this->setToolTip(a->toolTip()); this->setProperty("defaultAction", QVariant(i)); } @@ -378,7 +378,7 @@ void ActionGroup::onActivated (QAction* a) } #endif this->setIcon(a->icon()); - this->setToolTip(a->toolTip()); + if (!this->_isMode) this->setToolTip(a->toolTip()); this->setProperty("defaultAction", QVariant(index)); _pcCmd->invoke(index, Command::TriggerChildAction); } diff --git a/src/Gui/Action.h b/src/Gui/Action.h index 5aa6f2c313..d50deb8cb0 100644 --- a/src/Gui/Action.h +++ b/src/Gui/Action.h @@ -107,6 +107,7 @@ public: void setExclusive (bool); bool isExclusive() const; void setVisible (bool); + void setIsMode(bool b) { _isMode = b; } void setDropDownMenu(bool b) { _dropDown = b; } QAction* addAction(QAction*); @@ -126,6 +127,7 @@ protected: bool _dropDown; bool _external; bool _toggle; + bool _isMode; }; // -------------------------------------------------------------------- diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index 2ee06da8cb..a0ae9fdea4 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -850,6 +850,7 @@ Gui::Action * StdCmdUserEditMode::createAction(void) { Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); pcAction->setDropDownMenu(true); + pcAction->setIsMode(true); applyCommandData(this->className(), pcAction); for (auto const &uem : Gui::Application::Instance->listUserEditModes()) {