https://bugs.kde.org/show_bug.cgi?id=405541

            Bug ID: 405541
           Summary: Cannot get keyboard shortcut to visibly appear in QQC2
                    MenuItem
           Product: frameworks-kirigami
           Version: Master
          Platform: Neon Packages
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: notm...@gmail.com
          Reporter: n...@kde.org
  Target Milestone: Not decided

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.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to