Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
11#include <QtCore/qpointer.h>
12
17
19
20enum {
28};
29
31
32class QCocoaMenu;
33
35{
36public:
38 {
39 parent = o;
40 }
41
43 {
44 return parent;
45 }
46
47private:
48 QPointer<QObject> parent;
49};
50
52{
53public:
56
57 void setText(const QString &text) override;
58 void setIcon(const QIcon &icon) override;
59 void setMenu(QPlatformMenu *menu) override;
60 void setVisible(bool isVisible) override;
61 void setIsSeparator(bool isSeparator) override;
62 void setFont(const QFont &font) override;
63 void setRole(MenuRole role) override;
64#ifndef QT_NO_SHORTCUT
65 void setShortcut(const QKeySequence& shortcut) override;
66#endif
67 void setCheckable(bool) override {}
68 void setChecked(bool isChecked) override;
69 void setEnabled(bool isEnabled) override;
70 void setIconSize(int size) override;
71
72 void setNativeContents(WId item) override;
73
74 inline QString text() const { return m_text; }
75 inline NSMenuItem * nsItem() { return m_native; }
76 NSMenuItem *sync();
77
78 void syncMerged();
79 void setParentEnabled(bool enabled);
80
81 inline bool isMerged() const { return m_merged; }
82 inline bool isEnabled() const { return m_enabled && m_parentEnabled; }
83 inline bool isSeparator() const { return m_isSeparator; }
84 inline bool isVisible() const { return m_isVisible; }
85
86 QCocoaMenu *menu() const { return m_menu; }
87 MenuRole effectiveRole() const;
89
90private:
91 QString mergeText();
92 QKeySequence mergeAccel();
93
94 NSMenuItem *m_native;
95 NSView *m_itemView;
96 QString m_text;
97 QIcon m_icon;
98 QPointer<QCocoaMenu> m_menu;
99 MenuRole m_role;
100 MenuRole m_detectedRole;
101#ifndef QT_NO_SHORTCUT
102 QKeySequence m_shortcut;
103#endif
104 int m_iconSize;
105 bool m_textSynced:1;
106 bool m_isVisible:1;
107 bool m_enabled:1;
108 bool m_parentEnabled:1;
109 bool m_isSeparator:1;
110 bool m_checked:1;
111 bool m_merged:1;
112};
113
115
116#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:22
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:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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