Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qcocoamenuitem.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author James Turner <james.turner@kdab.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QCOCOAMENUITEM_H
6#define QCOCOAMENUITEM_H
7
8#include <qpa/qplatformmenu.h>
9#include <QtGui/QImage>
10
15
17
18enum {
26};
27
29
30class QCocoaMenu;
31
33{
34public:
36 {
37 parent = o;
38 }
39
41 {
42 return parent;
43 }
44
45private:
46 QPointer<QObject> parent;
47};
48
50{
51public:
54
55 void setText(const QString &text) override;
56 void setIcon(const QIcon &icon) override;
57 void setMenu(QPlatformMenu *menu) override;
58 void setVisible(bool isVisible) override;
59 void setIsSeparator(bool isSeparator) override;
60 void setFont(const QFont &font) override;
61 void setRole(MenuRole role) override;
62#ifndef QT_NO_SHORTCUT
63 void setShortcut(const QKeySequence& shortcut) override;
64#endif
65 void setCheckable(bool) override {}
66 void setChecked(bool isChecked) override;
67 void setEnabled(bool isEnabled) override;
68 void setIconSize(int size) override;
69
70 void setNativeContents(WId item) override;
71
72 inline QString text() const { return m_text; }
73 inline NSMenuItem * nsItem() { return m_native; }
74 NSMenuItem *sync();
75
76 void syncMerged();
77 void setParentEnabled(bool enabled);
78
79 inline bool isMerged() const { return m_merged; }
80 inline bool isEnabled() const { return m_enabled && m_parentEnabled; }
81 inline bool isSeparator() const { return m_isSeparator; }
82 inline bool isVisible() const { return m_isVisible; }
83
84 QCocoaMenu *menu() const { return m_menu; }
85 MenuRole effectiveRole() const;
87
88private:
89 QString mergeText();
90 QKeySequence mergeAccel();
91
92 NSMenuItem *m_native;
93 NSView *m_itemView;
94 QString m_text;
95 QIcon m_icon;
97 MenuRole m_role;
98 MenuRole m_detectedRole;
99#ifndef QT_NO_SHORTCUT
100 QKeySequence m_shortcut;
101#endif
102 int m_iconSize;
103 bool m_textSynced:1;
104 bool m_isVisible:1;
105 bool m_enabled:1;
106 bool m_parentEnabled:1;
107 bool m_isSeparator:1;
108 bool m_checked:1;
109 bool m_merged:1;
110};
111
113
114#endif
void setMenu(QPlatformMenu *menu) override
void setParentEnabled(bool enabled)
void setRole(MenuRole role) override
NSMenuItem * sync()
void setNativeContents(WId item) override
bool isVisible() const
QCocoaMenu * menu() const
void setCheckable(bool) override
bool isSeparator() const
void setIsSeparator(bool isSeparator) override
void setText(const QString &text) override
NSMenuItem * nsItem()
void setIcon(const QIcon &icon) override
void setShortcut(const QKeySequence &shortcut) override
QString text() const
void setFont(const QFont &font) override
void setEnabled(bool isEnabled) override
void setVisible(bool isVisible) override
void setChecked(bool isChecked) override
bool isMerged() const
bool isEnabled() const
void setIconSize(int size) override
MenuRole effectiveRole() const
void setMenuParent(QObject *o)
QObject * menuParent() const
\reentrant
Definition qfont.h:20
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
The QKeySequence class encapsulates a key sequence as used by shortcuts.
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qpointer.h:18
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
Combined button and popup list for selecting options.
QString qt_mac_applicationmenu_string(int type)
@ ServicesAppMenuItem
@ HideOthersAppMenuItem
@ ShowAllAppMenuItem
@ AboutAppMenuItem
@ HideAppMenuItem
@ PreferencesAppMenuItem
@ QuitAppMenuItem
#define Q_FORWARD_DECLARE_OBJC_CLASS(classname)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum type
QGraphicsItem * item