KDeclarative

keysequencehelper.h
1 /*
2  SPDX-FileCopyrightText: 2014 David Edmundson <[email protected]>
3  SPDX-FileCopyrightText: 2020 David Redondo <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7 
8 #ifndef KEYSEQUENCEHELPER_H
9 #define KEYSEQUENCEHELPER_H
10 
11 #include <KeySequenceRecorder>
12 
13 #include <QQuickItem>
14 #include <QKeySequence>
15 
16 class KeySequenceHelperPrivate;
17 class QQuickWindow;
18 
19 class KeySequenceHelper : public KeySequenceRecorder
20 {
21  Q_OBJECT
22 
23  Q_PROPERTY(
24  ShortcutTypes checkAgainstShortcutTypes
25  READ checkAgainstShortcutTypes
26  WRITE setCheckAgainstShortcutTypes
27  NOTIFY checkAgainstShortcutTypesChanged
28  )
29 
30 public:
31 
32  enum ShortcutType {
33  None = 0x00,
34  StandardShortcuts = 0x01,
35  GlobalShortcuts = 0x02
36  };
37  Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType)
38  Q_FLAG(ShortcutTypes)
39 
43  explicit KeySequenceHelper(QObject *parent = nullptr);
44 
48  virtual ~KeySequenceHelper();
49 
50  Q_INVOKABLE bool isKeySequenceAvailable(const QKeySequence &keySequence) const;
51  // FIXME why can't qml call the inherited method?
52  Q_INVOKABLE void startRecording() {KeySequenceRecorder::startRecording();}
53 
54  ShortcutTypes checkAgainstShortcutTypes();
55  void setCheckAgainstShortcutTypes(ShortcutTypes types);
56 
57  Q_INVOKABLE static bool keySequenceIsEmpty(const QKeySequence &keySequence);
58  Q_INVOKABLE static QString keySequenceNativeText(const QKeySequence &keySequence);
59  Q_INVOKABLE static QWindow* renderWindow(QQuickWindow *quickWindow);
60 
61 
62 Q_SIGNALS:
63  void checkAgainstShortcutTypesChanged();
64 
65 private:
66  friend class KeySequenceHelperPrivate;
67  KeySequenceHelperPrivate *const d;
68 
69  Q_DISABLE_COPY(KeySequenceHelper)
70 };
71 
72 Q_DECLARE_OPERATORS_FOR_FLAGS(KeySequenceHelper::ShortcutTypes)
73 
74 
75 #endif // KEYSEQUENCEHELPER_H
Q_SIGNALSQ_SIGNALS
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
void Q_INVOKABLE startRecording()
Q_DISABLE_COPY(Class)
Q_INVOKABLEQ_INVOKABLE
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 25 2021 22:44:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.