Cocoa: Enable native menus.

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 <qt_sanity_bot@ovi.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
Morten Sorvig 2011-09-12 12:31:35 +02:00 committed by Qt by Nokia
parent f82431b61c
commit 91ec8261ab
2 changed files with 7 additions and 4 deletions

View File

@ -83,6 +83,8 @@ QCocoaIntegration::QCocoaIntegration()
{ {
mPool = new QCocoaAutoReleasePool; mPool = new QCocoaAutoReleasePool;
qApp->setAttribute(Qt::AA_DontUseNativeMenuBar, false);
QNSApplication *cocoaApplication = [QNSApplication sharedApplication]; QNSApplication *cocoaApplication = [QNSApplication sharedApplication];
// Applications launched from plain executables (without an app // Applications launched from plain executables (without an app
@ -166,14 +168,12 @@ QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const
QPlatformMenu *QCocoaIntegration::createPlatformMenu(QMenu *menu) const QPlatformMenu *QCocoaIntegration::createPlatformMenu(QMenu *menu) const
{ {
// return new QCocoaMenu(menu); return new QCocoaMenu(menu);
return 0;
} }
QPlatformMenuBar *QCocoaIntegration::createPlatformMenuBar(QMenuBar *menuBar) const QPlatformMenuBar *QCocoaIntegration::createPlatformMenuBar(QMenuBar *menuBar) const
{ {
//return new QCocoaMenuBar(menuBar); return new QCocoaMenuBar(menuBar);
return 0;
} }
QPlatformNativeInterface *QCocoaIntegration::nativeInterface() const QPlatformNativeInterface *QCocoaIntegration::nativeInterface() const

View File

@ -466,6 +466,9 @@ QCocoaMenu::~QCocoaMenu()
void QCocoaMenu::addAction(QAction *a, QAction *before) void QCocoaMenu::addAction(QAction *a, QAction *before)
{ {
if (menu == 0)
return;
QCocoaMenuAction *action = new QCocoaMenuAction; QCocoaMenuAction *action = new QCocoaMenuAction;
action->action = a; action->action = a;
action->ignore_accel = 0; action->ignore_accel = 0;