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;
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

View File

@ -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;