diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-09-18 13:08:00 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-09-18 13:08:00 (GMT) |
commit | b9b8a1cb6bc5a1b93373a7a634a23dcd785b3c31 (patch) | |
tree | 82358a4423e481118be7e01cd40a20920ba7d8c4 /src | |
parent | 169099b5e9c77c6633deb3c7bb949800a5f80ec2 (diff) | |
parent | faec535829a0e454a6784b0c5c37cb63e7da8f73 (diff) | |
download | Qt-b9b8a1cb6bc5a1b93373a7a634a23dcd785b3c31.zip Qt-b9b8a1cb6bc5a1b93373a7a634a23dcd785b3c31.tar.gz Qt-b9b8a1cb6bc5a1b93373a7a634a23dcd785b3c31.tar.bz2 |
Merge branch '4.5' of scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/qmenu_mac.mm | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 94df85c..d971ac2 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1303,6 +1303,11 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) do not support the signals: aboutToHide (), aboutToShow () and hovered (). It is not possible to display an icon in a native menu on Windows Mobile. + \section1 QMenu on Mac OS X with Qt build against Cocoa + + QMenu can be inserted only once in a menu/menubar. Subsequent insertions will + have no effect or will result in a disabled menu item. + See the \l{mainwindows/menus}{Menus} example for an example of how to use QMenuBar and QMenu in your application. diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 3f4cd43..4fc3d3d 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1424,7 +1424,15 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action) GetMenuItemProperty(action->menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(caused), 0, &caused); SetMenuItemProperty(data.submenuHandle, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), &caused); #else - [item setSubmenu:static_cast<NSMenu *>(action->action->menu()->macMenu())]; + NSMenu *subMenu = static_cast<NSMenu *>(action->action->menu()->macMenu()); + if ([subMenu supermenu] != nil) { + // The menu is already a sub-menu of another one. Cocoa will throw an exception, + // in such cases. For the time being, a new QMenu with same set of actions is the + // only workaround. + action->action->setEnabled(false); + } else { + [item setSubmenu:subMenu]; + } #endif } else { //respect some other items #ifndef QT_MAC_USE_COCOA @@ -1710,7 +1718,10 @@ QMenuBarPrivate::QMacMenuBarPrivate::syncAction(QMacMenuAction *action) GetMenuItemProperty(action->menu, 0, kMenuCreatorQt, kMenuPropertyQWidget, sizeof(caused), 0, &caused); SetMenuItemProperty(submenu, 0, kMenuCreatorQt, kMenuPropertyCausedQWidget, sizeof(caused), &caused); #else - [item setSubmenu:submenu]; + if ([submenu supermenu] != nil) + return; + else + [item setSubmenu:submenu]; #endif } #ifndef QT_MAC_USE_COCOA |