summaryrefslogtreecommitdiff
path: root/Hotkey.qml
blob: 2dd333f93e35c77d5893db1781975d8d20ec7492 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()
    }
}