1/*
2 SPDX-FileCopyrightText: 2014 David Edmundson <davidedmundson@kde.org>
3 SPDX-FileCopyrightText: 2020 David Redondo <kde@david-redondo.de>
4
5 SPDX-License-Identifier: LGPL-2.1-or-later
6*/
7
8#ifndef KEYSEQUENCEHELPER_H
9#define KEYSEQUENCEHELPER_H
10
11#include <KKeySequenceRecorder>
12
13#include <QKeySequence>
14#include <QQuickItem>
15
16class KeySequenceHelperPrivate;
17class QQuickWindow;
18
19class KeySequenceHelper : public KKeySequenceRecorder
20{
21 Q_OBJECT
22
23 Q_PROPERTY(
24 ShortcutTypes checkAgainstShortcutTypes READ checkAgainstShortcutTypes WRITE setCheckAgainstShortcutTypes NOTIFY checkAgainstShortcutTypesChanged)
25
26public:
27 enum ShortcutType {
28 None = 0x00, //!< No checking for conflicts
29 StandardShortcuts = 0x01, //!< Check against standard shortcuts. @see KStandardShortcut
30 GlobalShortcuts = 0x02, //!< Check against global shortcuts. @see KGlobalAccel
31 };
32 Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType)
33 Q_FLAG(ShortcutTypes)
34
35 /**
36 * Constructor.
37 */
38 explicit KeySequenceHelper(QObject *parent = nullptr);
39
40 /**
41 * Destructs the widget.
42 */
43 ~KeySequenceHelper() override;
44
45 Q_INVOKABLE bool isKeySequenceAvailable(const QKeySequence &keySequence) const;
46
47 ShortcutTypes checkAgainstShortcutTypes();
48 void setCheckAgainstShortcutTypes(ShortcutTypes types);
49
50 Q_INVOKABLE static bool keySequenceIsEmpty(const QKeySequence &keySequence);
51 Q_INVOKABLE static QString keySequenceNativeText(const QKeySequence &keySequence);
52 Q_INVOKABLE static QWindow *renderWindow(QQuickWindow *quickWindow);
53
54Q_SIGNALS:
55 void checkAgainstShortcutTypesChanged();
56
57private:
58 friend class KeySequenceHelperPrivate;
59 KeySequenceHelperPrivate *const d;
60
61 Q_DISABLE_COPY(KeySequenceHelper)
62};
63
64Q_DECLARE_OPERATORS_FOR_FLAGS(KeySequenceHelper::ShortcutTypes)
65
66#endif // KEYSEQUENCEHELPER_H
67

source code of kdeclarative/src/qmlcontrols/kquickcontrols/private/keysequencehelper.h