Add Hotkey type for defining and displaying shortcuts
This commit is contained in:
parent
81d935c766
commit
c8cd2fb80e
3 changed files with 85 additions and 58 deletions
30
Hotkey.qml
Normal file
30
Hotkey.qml
Normal file
|
@ -0,0 +1,30 @@
|
|||
// SPDX-License-Identifier: Unlicense
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
// Define and display a shortcut to focus the given control.
|
||||
Label {
|
||||
required property Item control
|
||||
property alias sequence: shortcut.sequence
|
||||
|
||||
text: shortcut.nativeText
|
||||
visible: !control.activeFocus
|
||||
|
||||
color: 'gray'
|
||||
padding: 1
|
||||
leftPadding: 2*padding
|
||||
rightPadding: 2*padding
|
||||
|
||||
background: Rectangle {
|
||||
color: palette.base
|
||||
border { color: Qt.lighter(parent.color); width: 1 }
|
||||
opacity: 0.9
|
||||
radius: 2
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
id: shortcut
|
||||
onActivated: control.forceActiveFocus()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue