2import QtQuick.Controls as QQC2
5import org.kde.private.kquickcontrols as KQuickControlsPrivate
10 property bool showClearButton: true
11 property bool showCancelButton: false
12 property alias modifierOnlyAllowed: helper.modifierOnlyAllowed
13 property alias modifierlessAllowed: helper.modifierlessAllowed
14 property alias multiKeyShortcutsAllowed: helper.multiKeyShortcutsAllowed
15 property alias keySequence: helper.currentKeySequence
28 property alias checkForConflictsAgainst: helper.checkAgainstShortcutTypes
30 property string __previousSequence: ""
38 signal captureFinished()
47 signal keySequenceModified()
53 function startCapturing() {
54 mainButton.checked = true;
57 KQuickControlsPrivate.KeySequenceHelper {
59 onGotKeySequence: keySequence => {
60 if (!isKeySequenceAvailable(keySequence)) {
61 currentKeySequence = root.__previousSequence;
63 mainButton.checked =
false;
64 root.captureFinished();
65 root.keySequenceModified();
69 KQuickControlsPrivate.TranslationContext {
71 domain:
"kdeclarative6"
77 icon.name:
"configure"
85 const keySequence = helper.currentKeySequence;
86 const text = helper.keySequenceIsEmpty(keySequence)
88 ? _tr.i18nc(
"What the user inputs now will be taken as the new shortcut",
"Input")
89 : _tr.i18nc(
"No shortcut defined",
"None"))
95 : helper.keySequenceNativeText(keySequence).replace(
'&',
'&&');
97 return " " + text + (helper.isRecording ?
" ... " :
" ");
100 Accessible.description: _tr.i18n(
"Click on the button, then enter the shortcut like you would in the program.\nExample for Ctrl+A: hold the Ctrl key and press A.")
103 visible: mainButton.hovered
104 text: mainButton.Accessible.description
109 root.__previousSequence = helper.keySequenceNativeText(root.keySequence)
110 helper.window = helper.renderWindow(parent.Window.window)
111 mainButton.forceActiveFocus()
112 helper.startRecording()
113 }
else if (helper.isRecording) {
114 helper.cancelRecording()
120 mainButton.checked =
false
127 Layout.fillHeight:
true
128 Layout.preferredWidth: height
129 visible: root.showClearButton && !helper.isRecording
131 root.keySequence =
"";
132 root.keySequenceModified();
133 root.captureFinished();
136 enabled: !helper.keySequenceIsEmpty(helper.currentKeySequence)
140 icon.name:
Qt.application.layoutDirection ===
Qt.LeftToRight ?
"edit-clear-locationbar-rtl" :
"edit-clear-locationbar-ltr"
142 Accessible.name: _tr.i18nc(
"@info:tooltip",
"Clear Key Sequence")
145 visible: clearButton.hovered
146 text: clearButton.Accessible.name
151 Layout.fillHeight:
true
152 Layout.preferredWidth: height
153 onClicked: helper.cancelRecording()
154 visible: root.showCancelButton && helper.isRecording
156 icon.name:
"dialog-cancel"
158 Accessible.name: _tr.i18nc(
"@info:tooltip",
"Cancel Key Sequence Recording")
161 visible: parent.hovered
162 text: parent.Accessible.name