1 | // Copyright (C) 2023 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 QQUICKNATIVEMENUITEM_P_H |
5 | #define QQUICKNATIVEMENUITEM_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/qobject.h> |
19 | #include <QtQuickTemplates2/private/qtquicktemplates2global_p.h> |
20 | #include <QtQuickTemplates2/private/qquickicon_p.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class QQuickAction; |
25 | class QQuickNativeIconLoader; |
26 | class QQuickMenu; |
27 | class QQuickMenuSeparator; |
28 | class QPlatformMenuItem; |
29 | |
30 | class Q_QUICKTEMPLATES2_EXPORT QQuickNativeMenuItem : public QObject |
31 | { |
32 | Q_OBJECT |
33 | |
34 | public: |
35 | static QQuickNativeMenuItem *createFromNonNativeItem( |
36 | QQuickMenu *parentMenu, QQuickItem *nonNativeItem); |
37 | ~QQuickNativeMenuItem(); |
38 | |
39 | QQuickAction *action() const; |
40 | QQuickMenu *subMenu() const; |
41 | QQuickMenuSeparator *separator() const; |
42 | QPlatformMenuItem *handle() const; |
43 | void sync(); |
44 | |
45 | QQuickIcon effectiveIcon() const; |
46 | QQuickNativeIconLoader *iconLoader() const; |
47 | void reloadIcon(); |
48 | |
49 | QString debugText() const; |
50 | |
51 | private Q_SLOTS: |
52 | void updateIcon(); |
53 | |
54 | private: |
55 | enum class Type { |
56 | Unknown, |
57 | // It's an Action or a MenuItem with an Action. |
58 | Action, |
59 | // It's a MenuItem without an Action. |
60 | MenuItem, |
61 | Separator, |
62 | SubMenu |
63 | }; |
64 | |
65 | explicit QQuickNativeMenuItem(QQuickMenu *parentMenu, QQuickItem *nonNativeItem, Type type); |
66 | |
67 | void addShortcut(); |
68 | void removeShortcut(); |
69 | |
70 | QQuickMenu *m_parentMenu = nullptr; |
71 | QQuickItem *m_nonNativeItem = nullptr; |
72 | Type m_type = Type::Unknown; |
73 | mutable QQuickNativeIconLoader *m_iconLoader = nullptr; |
74 | std::unique_ptr<QPlatformMenuItem> m_handle = nullptr; |
75 | int m_shortcutId = -1; |
76 | bool m_syncing = false; |
77 | }; |
78 | |
79 | QT_END_NAMESPACE |
80 | |
81 | #endif // QQUICKNATIVEMENUITEM_P_H |
82 |