KDeclarative

KeySequenceItem.qml
1 import QtQuick 2.0
2 import QtQuick.Controls 2.12
3 import QtQuick.Layouts 1.1
4 
5 import org.kde.private.kquickcontrols 2.0 as KQuickControlsPrivate
6 
7 RowLayout {
8  property alias showClearButton: clearButton.visible
9  property alias modifierlessAllowed: _helper.modifierlessAllowed
10  property alias multiKeyShortcutsAllowed: _helper.multiKeyShortcutsAllowed
11  property alias keySequence: _helper.keySequence
12 
18  signal captureFinished()
19 
20 
24  function startCapturing() {
25  mainButton.checked = true
26  }
27 
28  KQuickControlsPrivate.KeySequenceHelper {
29  id: _helper
30 
31  onCaptureFinished: {
32  mainButton.checked = false;
33  parent.captureFinished();
34  }
35  }
36 
37  KQuickControlsPrivate.TranslationContext {
38  id: _tr
39  domain: "kdeclarative5"
40  }
41 
42  Button
43  {
44  id: mainButton
45 
46  icon.name: "configure"
47 
48  property string shortcut
49  checkable: true
50  focus: checked
51 
52  hoverEnabled: true
53 
54  text: _helper.shortcutDisplay
55 
56  ToolTip.visible: hovered
57  ToolTip.delay: 1000
58  ToolTip.text: _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.")
59  ToolTip.timeout: 5000
60 
61  onCheckedChanged: {
62  if (checked) {
63  mainButton.forceActiveFocus()
64  _helper.captureKeySequence()
65  }
66  }
67 
68  onFocusChanged: {
69  if (!focus) {
70  mainButton.checked = false
71  }
72  }
73 
74  Keys.onPressed: {
75  _helper.keyPressed(event.key, event.modifiers);
76  event.accepted = true;
77  }
78  Keys.onReleased: {
79  _helper.keyReleased(event.key, event.modifiers);
80  event.accepted = true;
81  }
82  }
83 
84  Button {
85  id: clearButton
86  Layout.fillHeight: true
87  Layout.preferredWidth: height
88  onClicked: _helper.clearKeySequence();
89 
90  //icon name determines the direction of the arrow, NOT the direction of the app layout
91  icon.name: Qt.application.layoutDirection == Qt.LeftToRight ? "edit-clear-locationbar-rtl" : "edit-clear-locationbar-ltr"
92  }
93 }
int timeout
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 3 2020 22:38:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.