| 1 | --- src/gui/widgets/qmenu.cpp.orig |
| 2 | +++ src/gui/widgets/qmenu.cpp |
| 3 | @@ -2387,7 +2387,7 @@ void QMenu::changeEvent(QEvent *e) |
| 4 | if (d->tornPopup) // torn-off menu |
| 5 | d->tornPopup->setEnabled(isEnabled()); |
| 6 | d->menuAction->setEnabled(isEnabled()); |
| 7 | -#ifdef Q_WS_MAC |
| 8 | +#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) |
| 9 | if (d->mac_menu) |
| 10 | d->setMacMenuEnabled(isEnabled()); |
| 11 | #endif |
| 12 | --- src/gui/widgets/qmenu_mac.mm.orig |
| 13 | +++ src/gui/widgets/qmenu_mac.mm |
| 14 | @@ -1554,6 +1554,7 @@ QMenuPrivate::syncSeparatorsCollapsible(bool collapse) |
| 15 | |
| 16 | |
| 17 | |
| 18 | +#ifndef QT_MAC_USE_COCOA |
| 19 | /*! |
| 20 | \internal |
| 21 | */ |
| 22 | @@ -1567,26 +1568,16 @@ void QMenuPrivate::setMacMenuEnabled(bool enable) |
| 23 | for (int i = 0; i < mac_menu->actionItems.count(); ++i) { |
| 24 | QMacMenuAction *menuItem = mac_menu->actionItems.at(i); |
| 25 | if (menuItem && menuItem->action && menuItem->action->isEnabled()) { |
| 26 | -#ifndef QT_MAC_USE_COCOA |
| 27 | // Only enable those items which contains an enabled QAction. |
| 28 | // i == 0 -> the menu itself, hence i + 1 for items. |
| 29 | EnableMenuItem(mac_menu->menu, i + 1); |
| 30 | -#else |
| 31 | - [menuItem->menuItem setEnabled:true]; |
| 32 | -#endif |
| 33 | } |
| 34 | } |
| 35 | } else { |
| 36 | -#ifndef QT_MAC_USE_COCOA |
| 37 | DisableAllMenuItems(mac_menu->menu); |
| 38 | -#else |
| 39 | - NSMenu *menu = mac_menu->menu; |
| 40 | - for (NSMenuItem *item in [menu itemArray]) { |
| 41 | - [item setEnabled:false]; |
| 42 | - } |
| 43 | -#endif |
| 44 | } |
| 45 | } |
| 46 | +#endif |
| 47 | |
| 48 | /*! |
| 49 | \internal |
| 50 | @@ -1744,6 +1735,7 @@ QMenuBarPrivate::QMacMenuBarPrivate::syncAction(QMacMenuAction *action) |
| 51 | [item setSubmenu: submenu]; |
| 52 | [submenu setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(action->action->text()))]; |
| 53 | syncNSMenuItemVisiblity(item, visible); |
| 54 | + syncNSMenuItemEnabled(item, action->action->isEnabled()); |
| 55 | #endif |
| 56 | if (release_submenu) { //no pointers to it |
| 57 | #ifndef QT_MAC_USE_COCOA |
| 58 | @@ -1846,6 +1838,7 @@ OSMenuRef QMenuBarPrivate::macMenu() |
| 59 | return 0; |
| 60 | } else if (!mac_menubar->menu) { |
| 61 | mac_menubar->menu = qt_mac_create_menu(q); |
| 62 | + [mac_menubar->menu setAutoenablesItems:NO]; |
| 63 | ProcessSerialNumber mine, front; |
| 64 | if (GetCurrentProcess(&mine) == noErr && GetFrontProcess(&front) == noErr) { |
| 65 | if (!qt_mac_no_menubar_merge && !mac_menubar->apple_menu) { |
| 66 | --- src/gui/widgets/qmenu_p.h.orig |
| 67 | +++ src/gui/widgets/qmenu_p.h |
| 68 | @@ -327,7 +327,9 @@ public: |
| 69 | } |
| 70 | } *mac_menu; |
| 71 | OSMenuRef macMenu(OSMenuRef merge); |
| 72 | +#ifndef QT_MAC_USE_COCOA |
| 73 | void setMacMenuEnabled(bool enable = true); |
| 74 | +#endif |
| 75 | void syncSeparatorsCollapsible(bool collapsible); |
| 76 | static QHash<OSMenuRef, OSMenuRef> mergeMenuHash; |
| 77 | static QHash<OSMenuRef, QMenuMergeList*> mergeMenuItemsHash; |