From 91ec8261ab58061ca9e935c4e6a7f1c4a359cc27 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Mon, 12 Sep 2011 12:31:35 +0200 Subject: [PATCH] Cocoa: Enable native menus. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix menu duplication bug: make QCocoaMenu::addAction do nothing before the native menu has ben created. Change-Id: Ifca192421f2073264de9f5faeb053008ecb8532e Reviewed-on: http://codereview.qt-project.org/5135 Reviewed-by: Qt Sanity Bot Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 8 ++++---- src/plugins/platforms/cocoa/qmenu_mac.mm | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index e3e2042..bb17c8e 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -83,6 +83,8 @@ QCocoaIntegration::QCocoaIntegration() { mPool = new QCocoaAutoReleasePool; + qApp->setAttribute(Qt::AA_DontUseNativeMenuBar, false); + QNSApplication *cocoaApplication = [QNSApplication sharedApplication]; // Applications launched from plain executables (without an app @@ -166,14 +168,12 @@ QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const QPlatformMenu *QCocoaIntegration::createPlatformMenu(QMenu *menu) const { - // return new QCocoaMenu(menu); - return 0; + return new QCocoaMenu(menu); } QPlatformMenuBar *QCocoaIntegration::createPlatformMenuBar(QMenuBar *menuBar) const { - //return new QCocoaMenuBar(menuBar); - return 0; + return new QCocoaMenuBar(menuBar); } QPlatformNativeInterface *QCocoaIntegration::nativeInterface() const diff --git a/src/plugins/platforms/cocoa/qmenu_mac.mm b/src/plugins/platforms/cocoa/qmenu_mac.mm index 7ca546d..cfedf06 100644 --- a/src/plugins/platforms/cocoa/qmenu_mac.mm +++ b/src/plugins/platforms/cocoa/qmenu_mac.mm @@ -466,6 +466,9 @@ QCocoaMenu::~QCocoaMenu() void QCocoaMenu::addAction(QAction *a, QAction *before) { + if (menu == 0) + return; + QCocoaMenuAction *action = new QCocoaMenuAction; action->action = a; action->ignore_accel = 0; -- 2.7.4