File: keysequencehelper.h

package info (click to toggle)
kdeclarative 5.116.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,072 kB
  • sloc: cpp: 8,161; sh: 21; makefile: 11
file content (67 lines) | stat: -rw-r--r-- 1,957 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
    SPDX-FileCopyrightText: 2014 David Edmundson <davidedmundson@kde.org>
    SPDX-FileCopyrightText: 2020 David Redondo <kde@david-redondo.de>

    SPDX-License-Identifier: LGPL-2.1-or-later
*/

#ifndef KEYSEQUENCEHELPER_H
#define KEYSEQUENCEHELPER_H

#include <KeySequenceRecorder>

#include <QKeySequence>
#include <QQuickItem>

class KeySequenceHelperPrivate;
class QQuickWindow;

class KeySequenceHelper : public KeySequenceRecorder
{
    Q_OBJECT

    Q_PROPERTY(
        ShortcutTypes checkAgainstShortcutTypes READ checkAgainstShortcutTypes WRITE setCheckAgainstShortcutTypes NOTIFY checkAgainstShortcutTypesChanged)

public:
    enum ShortcutType {
        None = 0x00, //!< No checking for conflicts
        StandardShortcuts = 0x01, //!< Check against standard shortcuts. @see KStandardShortcut
        GlobalShortcuts = 0x02, //!< Check against global shortcuts. @see KGlobalAccel
    };
    Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType)
    Q_FLAG(ShortcutTypes)

    /**
     * Constructor.
     */
    explicit KeySequenceHelper(QObject *parent = nullptr);

    /**
     * Destructs the widget.
     */
    ~KeySequenceHelper() override;

    Q_INVOKABLE bool isKeySequenceAvailable(const QKeySequence &keySequence) const;

    ShortcutTypes checkAgainstShortcutTypes();
    void setCheckAgainstShortcutTypes(ShortcutTypes types);

    Q_INVOKABLE static QKeySequence fromString(const QString &str = QString());
    Q_INVOKABLE static bool keySequenceIsEmpty(const QKeySequence &keySequence);
    Q_INVOKABLE static QString keySequenceNativeText(const QKeySequence &keySequence);
    Q_INVOKABLE static QWindow *renderWindow(QQuickWindow *quickWindow);

Q_SIGNALS:
    void checkAgainstShortcutTypesChanged();

private:
    friend class KeySequenceHelperPrivate;
    KeySequenceHelperPrivate *const d;

    Q_DISABLE_COPY(KeySequenceHelper)
};

Q_DECLARE_OPERATORS_FOR_FLAGS(KeySequenceHelper::ShortcutTypes)

#endif // KEYSEQUENCEHELPER_H