Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcuts no longer visible in context menus since Qt 5.10 #1978

Closed
bjorn opened this issue Jul 17, 2018 · 4 comments
Closed

Shortcuts no longer visible in context menus since Qt 5.10 #1978

bjorn opened this issue Jul 17, 2018 · 4 comments
Assignees
Labels
bug Broken behavior. qt issue Qt related issue.

Comments

@bjorn
Copy link
Member

bjorn commented Jul 17, 2018

In Qt 5.10, shortcuts are no longer shown by default in context menus. However, I'd generally prefer them to be there to make them discoverable. Several actions that are only available from context menus have shortcuts that are now completely hidden.

It seems the only way to fix this is to manually specify that the shortcut should be visible for each affected action. Setting setAttribute(Qt::AA_DontShowShortcutsInContextMenus, false) has no effect, since QAction is doing:

bool QAction::isShortcutVisibleInContextMenu() const
{
    Q_D(const QAction);
    if (d->shortcutVisibleInContextMenu == -1) {
        return !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus)
            && QGuiApplication::styleHints()->showShortcutsInContextMenus();
    }
    return d->shortcutVisibleInContextMenu;
}

And the style hints say they should not be visible.

@bjorn bjorn added the bug Broken behavior. label Jul 17, 2018
@mitchcurtis
Copy link
Contributor

Just saw this on IRC, and thought I'd share https://bugreports.qt.io/browse/QTBUG-69452 with you in case you weren't aware of it.

@bjorn
Copy link
Member Author

bjorn commented Jul 18, 2018

@mitchcurtis Ah, thanks for the reference! It didn't occur to me to look for an issue because the change in behavior was clearly intensional, but I think it is a little misguided and I hope they will reconsider, or at least provide an API for enabling the showing of shortcuts in all context menus.

@bjorn bjorn added the qt issue Qt related issue. label Dec 27, 2018
@bjorn
Copy link
Member Author

bjorn commented Dec 27, 2018

Unfortunately this issue persists in Qt 5.11 and Qt 5.12 (LTS). This means for now I'm going to stick to releasing against Qt 5.9, which may be a better choice in regards to stability anyway.

@bjorn bjorn self-assigned this May 13, 2022
@bjorn
Copy link
Member Author

bjorn commented May 13, 2022

Since Qt 5.13.1, shortcuts are again visible by default in context menus, except on macOS, where they are deemed too out-of-place. I'll make it so that they're always shown when the "Tiled Fusion" style is selected, which is now possible using QGuiApplication::styleHints()->setShowShortcutsInContextMenus(true).

@bjorn bjorn closed this as completed in efd9ead May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior. qt issue Qt related issue.
Projects
None yet
Development

No branches or pull requests

2 participants