1 | // Copyright (C) 2017 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICKACTION_P_P_H |
5 | #define QQUICKACTION_P_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtCore/private/qobject_p.h> |
19 | #include <QtCore/qvariant.h> |
20 | #include <QtCore/qstring.h> |
21 | #if QT_CONFIG(shortcut) |
22 | # include <QtGui/qkeysequence.h> |
23 | #endif |
24 | #include <QtQuick/private/qquickitemchangelistener_p.h> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | class QShortcutEvent; |
29 | class QQuickActionGroup; |
30 | |
31 | class QQuickActionPrivate : public QObjectPrivate, public QQuickItemChangeListener |
32 | { |
33 | Q_DECLARE_PUBLIC(QQuickAction) |
34 | |
35 | public: |
36 | static QQuickActionPrivate *get(QQuickAction *action) |
37 | { |
38 | return action->d_func(); |
39 | } |
40 | |
41 | #if QT_CONFIG(shortcut) |
42 | QVariant shortcut() const; |
43 | void setShortcut(const QVariant &shortcut); |
44 | #endif |
45 | |
46 | void setEnabled(bool enable); |
47 | |
48 | bool watchItem(QQuickItem *item); |
49 | bool unwatchItem(QQuickItem *item); |
50 | |
51 | void registerItem(QQuickItem *item); |
52 | void unregisterItem(QQuickItem *item); |
53 | |
54 | void itemVisibilityChanged(QQuickItem *item) override; |
55 | void itemDestroyed(QQuickItem *item) override; |
56 | |
57 | bool handleShortcutEvent(QObject *object, QShortcutEvent *event); |
58 | |
59 | void trigger(QObject*, bool doToggle); |
60 | |
61 | #if QT_CONFIG(shortcut) |
62 | class ShortcutEntry |
63 | { |
64 | public: |
65 | explicit ShortcutEntry(QObject *target); |
66 | ~ShortcutEntry(); |
67 | |
68 | QObject *target() const; |
69 | int shortcutId() const; |
70 | |
71 | void grab(const QKeySequence &vshortcut, bool enabled); |
72 | void ungrab(); |
73 | |
74 | void setEnabled(bool enabled); |
75 | |
76 | private: |
77 | int m_shortcutId = 0; |
78 | QObject *m_target = nullptr; |
79 | }; |
80 | |
81 | ShortcutEntry *findShortcutEntry(QObject *target) const; |
82 | void updateDefaultShortcutEntry(); |
83 | #endif // QT_CONFIG(shortcut) |
84 | |
85 | bool explicitEnabled = false; |
86 | bool enabled = true; |
87 | bool checked = false; |
88 | bool checkable = false; |
89 | QString text; |
90 | QQuickIcon icon; |
91 | #if QT_CONFIG(shortcut) |
92 | QKeySequence keySequence; |
93 | QVariant vshortcut; |
94 | ShortcutEntry *defaultShortcutEntry = nullptr; |
95 | QList<ShortcutEntry *> shortcutEntries; |
96 | #endif |
97 | QQuickActionGroup *group = nullptr; |
98 | }; |
99 | |
100 | QT_END_NAMESPACE |
101 | |
102 | #endif // QQUICKACTION_P_P_H |
103 | |