Kirigami-addons

keysequencehelper.h
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{
22 QML_ELEMENT
23
25 ShortcutTypes checkAgainstShortcutTypes READ checkAgainstShortcutTypes WRITE setCheckAgainstShortcutTypes NOTIFY checkAgainstShortcutTypesChanged)
26
27public:
28 enum ShortcutType {
29 None = 0x00, //!< No checking for conflicts
30 StandardShortcuts = 0x01, //!< Check against standard shortcuts. @see KStandardShortcut
31 GlobalShortcuts = 0x02, //!< Check against global shortcuts. @see KGlobalAccel
32 };
33 Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType)
34 Q_FLAG(ShortcutTypes)
35
36 /**
37 * Constructor.
38 */
39 explicit KeySequenceHelper(QObject *parent = nullptr);
40
41 /**
42 * Destructs the widget.
43 */
44 ~KeySequenceHelper() override;
45
46 Q_INVOKABLE bool isKeySequenceAvailable(const QKeySequence &keySequence) const;
47
48 ShortcutTypes checkAgainstShortcutTypes();
49 void setCheckAgainstShortcutTypes(ShortcutTypes types);
50
51 Q_INVOKABLE static bool keySequenceIsEmpty(const QKeySequence &keySequence);
52 Q_INVOKABLE static QString keySequenceNativeText(const QKeySequence &keySequence);
53 Q_INVOKABLE static QWindow *renderWindow(QQuickWindow *quickWindow);
54
56 void checkAgainstShortcutTypesChanged();
57 void errorOccurred(const QString &title, const QString &message);
58 void showStealStandardShortcutDialog(const QString &title, const QString &message, const QKeySequence &key);
59
60private:
61 friend class KeySequenceHelperPrivate;
62 KeySequenceHelperPrivate *const d;
63
64 Q_DISABLE_COPY(KeySequenceHelper)
65};
66
67Q_DECLARE_OPERATORS_FOR_FLAGS(KeySequenceHelper::ShortcutTypes)
68
69#endif // KEYSEQUENCEHELPER_H
Q_FLAG(...)
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.