Bug 405541 - Cannot get keyboard shortcut to visibly appear in QQC2 MenuItem
Summary: Cannot get keyboard shortcut to visibly appear in QQC2 MenuItem
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kirigami
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: Master
Platform: Neon Linux
: NOR normal
Target Milestone: Not decided
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks: 405144
  Show dependency treegraph
 
Reported: 2019-03-16 21:40 UTC by Nate Graham
Modified: 2019-06-29 09:49 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Graham 2019-03-16 21:40:44 UTC
In trying to port a QQC1 menu in ELisa to QQC2, I ran into an issue of being unable to replicate the full functionality available in QQC1, with the menu items having keyboard shortcuts that appear on the right-side of their menu items.


Here's the original code (from https://cgit.kde.org/elisa.git/tree/src/qml/ApplicationMenu.qml:)

import QtQuick 2.7
import QtQuick.Controls 1.4

Menu {
    MenuItem {
        text: configureAction.text
        shortcut: configureAction.shortcut
        iconName: elisa.iconName(configureAction.icon)
        onTriggered: configureAction.trigger()
    }
}


And here's a QQC2 version:


import QtQuick 2.7
import QtQuick.Controls 2.5

Menu {
    MenuItem {
        text: configureAction.text
        icon.name: elisa.iconName(configureAction.icon)
        onTriggered: configureAction.trigger()
        visible: configureAction.text !== ""

        Shortcut {
            sequence: configureAction.shortcut
            context: Qt.ApplicationShortcut
            onActivated: configureAction.trigger()
        }
    }
}

With this, the shortcut works, but the does not visible appear in the menu itself.



Or consider the following alternative using Actions in the Menu


import QtQuick 2.7
import QtQuick.Controls 2.5
Menu {
    Action {
        text: configureAction.text
        shortcut: configureAction.shortcut
        icon.name: elisa.iconName(configureAction.icon)
        onTriggered: configureAction.trigger()
    }
}

With this, the shortcut neither works, nor visibly appears in the menu.


I feel like one or both of these should work.
Comment 1 Alexander Stippich 2019-06-29 09:49:58 UTC
Git commit 721c348d1a1e903fdeb034afa8e8c03487d67301 by Alexander Stippich.
Committed on 29/06/2019 at 09:49.
Pushed by astippich into branch 'master'.

Show shortcut in menu item when specified

Summary:
Show the shortcut as text for menu items when
they are given via an action

Reviewers: mart, ngraham, apol

Reviewed By: ngraham, apol

Subscribers: apol, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21944

M  +14   -0    org.kde.desktop/MenuItem.qml

https://commits.kde.org/qqc2-desktop-style/721c348d1a1e903fdeb034afa8e8c03487d67301