[components] Hook up Mnemonics

Currently in buttons and tabs the mnemonics were shown, but never
actually attached to do anything.

This copies code from QQC2-desktop-style and creates an explicit
shortcut.
This commit is contained in:
David Edmundson 2020-12-31 10:58:28 +00:00 committed by Mikel Johnson
parent c1560df1cc
commit 2c07c2a455
3 changed files with 21 additions and 0 deletions

View File

@ -32,6 +32,13 @@ T.Button {
Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl
Kirigami.MnemonicData.label: control.text
Shortcut {
//in case of explicit & the button manages it by itself
enabled: !(RegExp(/\&[^\&]/).test(control.text))
sequence: control.Kirigami.MnemonicData.sequence
onActivated: control.clicked()
}
PlasmaCore.ColorScope.inherit: flat
PlasmaCore.ColorScope.colorGroup: flat ? parent.PlasmaCore.ColorScope.colorGroup : PlasmaCore.Theme.ButtonColorGroup

View File

@ -27,6 +27,13 @@ T.TabButton {
Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl
Kirigami.MnemonicData.label: control.text
Shortcut {
//in case of explicit & the button manages it by itself
enabled: !(RegExp(/\&[^\&]/).test(control.text))
sequence: control.Kirigami.MnemonicData.sequence
onActivated: control.clicked()
}
contentItem: GridLayout {
columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1
PlasmaCore.IconItem {

View File

@ -32,6 +32,13 @@ T.ToolButton {
Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl
Kirigami.MnemonicData.label: control.text
Shortcut {
//in case of explicit & the button manages it by itself
enabled: !(RegExp(/\&[^\&]/).test(control.text))
sequence: control.Kirigami.MnemonicData.sequence
onActivated: control.clicked()
}
flat: true
PlasmaCore.ColorScope.inherit: flat