Skip to content

Commit

Permalink
Gui: temporary fix of preference menu in macos
Browse files Browse the repository at this point in the history
QAction defaults menu role to TextHeuristicRole, which causes qt to
guess the menu role based on action title. And titles start with
'Config', 'Options', 'Settings', etc. will be considered as preference
menu. It seems some non-english translation causes the wrong action be
chosen as preference, such as 'Treeview actions'.

This commit just applied a temporary fix to default to QAction::NoRole
for GroupCommand. If there is ever some GroupCommand need to be a
system menu item on macos, we could add some command bit flag for that
purpose.

Fixes realthunder/FreeCAD_Assembly#388
  • Loading branch information
realthunder committed Dec 24, 2020
1 parent 6bdeffa commit 6f26068
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Gui/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,9 @@ void ActionGroup::addTo(QWidget *w)
// and adding this action to the widget doesn't work.
if (_dropDown) {
if (w->inherits("QMenu")) {
QMenu* menu = qobject_cast<QMenu*>(w);
menu = menu->addMenu(_action->text());
QMenu *menu = new QMenu(w);
QAction* action = qobject_cast<QMenu*>(w)->addMenu(menu);
action->setMenuRole(_action->menuRole());
menu->addActions(_group->actions());
}
else if (w->inherits("QToolBar")) {
Expand Down
1 change: 1 addition & 0 deletions src/Gui/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ Command *GroupCommand::addCommand(const char *name) {

Action * GroupCommand::createAction(void) {
ActionGroup* pcAction = new ActionGroup(this, getMainWindow());
pcAction->setMenuRole(QAction::NoRole);
pcAction->setDropDownMenu(true);
pcAction->setExclusive(false);
pcAction->setCheckable(true);
Expand Down
1 change: 1 addition & 0 deletions src/Gui/CommandStd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ Action * StdCmdDlgPreferences::createAction(void)
{
Action *pcAction = Command::createAction();
pcAction->setMenuRole(QAction::PreferencesRole);

return pcAction;
}

Expand Down

0 comments on commit 6f26068

Please sign in to comment.