diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2017-10-19 10:51:55 +0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2017-12-19 21:42:31 +0000 |
commit | e996c74164f6a161c030d3aff1348b1ef7f5da6f (patch) | |
tree | 7bce68310b6220bddaa170b39c3124beda4602b0 /src/plugins/platforms/cocoa/qcocoamenu.h | |
parent | 8686f3a347ade668e9ea3130c971babe6623ede6 (diff) |
QCocoaMenu: Derive custom NSMenu class, make delegate a singleton
Out of the box, this saves one delegate instance per NSMenu. It
also weak-couples the NSMenu instance with its owning QCocoaMenu,
making it safer to inspect from the menu delegate.
In the future, this will be helpful for debugging by just overriding
any NSMenu method.
Change-Id: I7eb801009b97f6a8ee2003306c0e152621bbce54
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoamenu.h')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenu.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h index f5fa93cbb5..2b4cf0ef98 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.h +++ b/src/plugins/platforms/cocoa/qcocoamenu.h @@ -45,6 +45,8 @@ #include <qpa/qplatformmenu.h> #include "qcocoamenuitem.h" +Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QCocoaNSMenu)); + QT_BEGIN_NAMESPACE class QCocoaMenuBar; @@ -74,8 +76,7 @@ public: void setMinimumWidth(int width) override; void setFont(const QFont &font) override; - inline NSMenu *nsMenu() const - { return m_nativeMenu; } + NSMenu *nsMenu() const; inline bool isVisible() const { return m_visible; } @@ -101,7 +102,7 @@ private: void scheduleUpdate(); QList<QCocoaMenuItem *> m_menuItems; - NSMenu *m_nativeMenu; + QT_MANGLE_NAMESPACE(QCocoaNSMenu) *m_nativeMenu; NSMenuItem *m_attachedItem; int m_updateTimer; bool m_enabled:1; |