diff options
| author | Timotej Lazar <timotej.lazar@araneo.si> | 2021-09-16 20:24:07 +0200 |
|---|---|---|
| committer | Timotej Lazar <timotej.lazar@araneo.si> | 2021-09-16 20:34:35 +0200 |
| commit | c8cd2fb80ecd64a9cfbed1caff9855794102b537 (patch) | |
| tree | deec046aac266ff3ab2f2a6588461041827ce7fd /Hotkey.qml | |
| parent | 81d935c766418df4221af905fbabe81e93a533f0 (diff) | |
Add Hotkey type for defining and displaying shortcuts
Diffstat (limited to 'Hotkey.qml')
| -rw-r--r-- | Hotkey.qml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Hotkey.qml b/Hotkey.qml new file mode 100644 index 0000000..2dd333f --- /dev/null +++ b/Hotkey.qml @@ -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() + } +} |
