QmlDesigner: Make shortcut accessible from the MenuItem

The shortcut property is accessible directly for the MenuItem.

Change-Id: I6d956859411a02dcd9c9610cfa4ccffb2e7867e7
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Ali Kianian
2023-09-12 09:40:16 +03:00
parent 92363e1a49
commit 251e1cca4c

View File

@@ -9,6 +9,8 @@ import StudioTheme 1.0 as StudioTheme
T.MenuItem { T.MenuItem {
id: control id: control
property alias shortcut: itemAction.shortcut
property StudioTheme.ControlStyle style: StudioTheme.Values.controlStyle property StudioTheme.ControlStyle style: StudioTheme.Values.controlStyle
property int labelSpacing: control.style.contextMenuLabelSpacing property int labelSpacing: control.style.contextMenuLabelSpacing
@@ -22,7 +24,9 @@ T.MenuItem {
padding: 0 padding: 0
spacing: 0 spacing: 0
horizontalPadding: control.style.contextMenuHorizontalPadding horizontalPadding: control.style.contextMenuHorizontalPadding
action: Action {} action: Action {
id: itemAction
}
contentItem: Item { contentItem: Item {
Text { Text {
@@ -39,14 +43,14 @@ T.MenuItem {
id: shortcutLabel id: shortcutLabel
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: shortcut.nativeText text: shortcutObserver.nativeText
font: control.font font: control.font
color: textLabel.color color: textLabel.color
Shortcut { Shortcut {
id: shortcut id: shortcutObserver
property int shortcutWorkaround: control.action.shortcut ?? 0 property int shortcutWorkaround: control.shortcut ?? 0
sequence: shortcut.shortcutWorkaround sequence: shortcutObserver.shortcutWorkaround
} }
} }
} }