KDeclarative

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
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 void updateKeySequence(const QKeySequence &keySequence);
46
47 Q_INVOKABLE void showQuestionDialog(const QString &title, const QString &text);
48 Q_INVOKABLE void showErrorDialog(const QString &title, const QString &text);
49
50 ShortcutTypes checkAgainstShortcutTypes();
51 void setCheckAgainstShortcutTypes(ShortcutTypes types);
52
53 Q_INVOKABLE static bool keySequenceIsEmpty(const QKeySequence &keySequence);
54 Q_INVOKABLE static QString keySequenceNativeText(const QKeySequence &keySequence);
55 Q_INVOKABLE static QWindow *renderWindow(QQuickWindow *quickWindow);
56
58 void checkAgainstShortcutTypesChanged();
59 void questionDialogAccepted();
60 void questionDialogRejected();
61
62private:
63 friend class KeySequenceHelperPrivate;
64 KeySequenceHelperPrivate *const d;
65
66 Q_DISABLE_COPY(KeySequenceHelper)
67};
68
69Q_DECLARE_OPERATORS_FOR_FLAGS(KeySequenceHelper::ShortcutTypes)
70
71#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 Sat Dec 21 2024 17:05:54 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.