summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-05-13 19:36:51 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-07-07 11:49:27 +0200
commitd7fc2fb5c666e58facfa15e64551a80dfda2c9d2 (patch)
tree4140e6e5cebb26a7820dd31f92286f504422d371 /src/widgets
parent7ad5c5346f3298d90f12531231cd021768f1fb26 (diff)
macOS: Remove QMenu indirection via QPlatformNativeInterface
Task-number: QTBUG-83252 Change-Id: I0c750d2b1912ced343d96ea0ca081c3319be2889 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qmenu_mac.mm32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index 81a98f2d14..67919de9ae 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -40,6 +40,10 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
+#include <qtwidgetsglobal.h>
+
+QT_USE_NAMESPACE
+
#include "qmenu.h"
#if QT_CONFIG(menubar)
#include "qmenubar.h"
@@ -52,6 +56,8 @@
#include <QtGui/QWindow>
#include <qpa/qplatformnativeinterface.h>
+using namespace QPlatformInterface::Private;
+
QT_BEGIN_NAMESPACE
#if QT_CONFIG(menu)
@@ -84,12 +90,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
NSMenu *QMenu::toNSMenu()
{
Q_D(QMenu);
- // Call into the cocoa platform plugin: qMenuToNSMenu(platformMenu())
- QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenutonsmenu");
- if (function) {
- typedef void* (*QMenuToNSMenuFunction)(QPlatformMenu *platformMenu);
- return reinterpret_cast<NSMenu *>(reinterpret_cast<QMenuToNSMenuFunction>(function)(d->createPlatformMenu()));
- }
+ if (auto *cocoaPlatformMenu = dynamic_cast<QCocoaMenu *>(d->createPlatformMenu()))
+ return cocoaPlatformMenu->nsMenu();
+
return nil;
}
@@ -104,12 +107,8 @@ NSMenu *QMenu::toNSMenu()
void QMenu::setAsDockMenu()
{
Q_D(QMenu);
- // Call into the cocoa platform plugin: setDockMenu(platformMenu())
- QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("setdockmenu");
- if (function) {
- typedef void (*SetDockMenuFunction)(QPlatformMenu *platformMenu);
- reinterpret_cast<SetDockMenuFunction>(function)(d->createPlatformMenu());
- }
+ if (auto *cocoaPlatformMenu = dynamic_cast<QCocoaMenu *>(d->createPlatformMenu()))
+ cocoaPlatformMenu->setAsDockMenu();
}
@@ -161,12 +160,9 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
*/
NSMenu *QMenuBar::toNSMenu()
{
- // Call into the cocoa platform plugin: qMenuBarToNSMenu(platformMenuBar())
- QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("qmenubartonsmenu");
- if (function) {
- typedef void* (*QMenuBarToNSMenuFunction)(QPlatformMenuBar *platformMenuBar);
- return reinterpret_cast<NSMenu *>(reinterpret_cast<QMenuBarToNSMenuFunction>(function)(platformMenuBar()));
- }
+ if (auto *cocoaMenuBar = dynamic_cast<QCocoaMenuBar *>(platformMenuBar()))
+ return cocoaMenuBar->nsMenu();
+
return nil;
}
#endif // QT_CONFIG(menubar)