761 |
761 |
762 QMacMenuAction::~QMacMenuAction() |
762 QMacMenuAction::~QMacMenuAction() |
763 { |
763 { |
764 #ifdef QT_MAC_USE_COCOA |
764 #ifdef QT_MAC_USE_COCOA |
765 [menu release]; |
765 [menu release]; |
766 if (action) { |
766 // Update the menu item if this action still owns it. For some items |
|
767 // (like 'Quit') ownership will be transferred between all menu bars... |
|
768 if (action && action.data() == reinterpret_cast<QAction *>([menuItem tag])) { |
767 QAction::MenuRole role = action->menuRole(); |
769 QAction::MenuRole role = action->menuRole(); |
768 // Check if the item is owned by Qt, and should be hidden to keep it from causing |
770 // Check if the item is owned by Qt, and should be hidden to keep it from causing |
769 // problems. Do it for everything but the quit menu item since that should always |
771 // problems. Do it for everything but the quit menu item since that should always |
770 // be visible. |
772 // be visible. |
771 if (role > QAction::ApplicationSpecificRole && role < QAction::QuitRole) { |
773 if (role > QAction::ApplicationSpecificRole && role < QAction::QuitRole) { |
772 [menuItem setHidden:YES]; |
774 [menuItem setHidden:YES]; |
773 } else if (role == QAction::TextHeuristicRole |
775 } else if (role == QAction::TextHeuristicRole |
774 && menuItem != [getMenuLoader() quitMenuItem]) { |
776 && menuItem != [getMenuLoader() quitMenuItem]) { |
775 [menuItem setHidden:YES]; |
777 [menuItem setHidden:YES]; |
776 } |
778 } |
777 } |
779 [menuItem setTag:nil]; |
778 [menuItem setTag:nil]; |
780 } |
779 [menuItem release]; |
781 [menuItem release]; |
780 #endif |
782 #endif |
781 } |
783 } |
782 |
784 |
783 #ifndef QT_MAC_USE_COCOA |
785 #ifndef QT_MAC_USE_COCOA |
1189 #else |
1191 #else |
1190 [menu addItem:newItem]; |
1192 [menu addItem:newItem]; |
1191 #endif |
1193 #endif |
1192 } |
1194 } |
1193 |
1195 |
1194 QWidget *widget = qmenu ? qmenu->widgetItems.value(qmenu->actions.indexOf(action->action)) : 0; |
1196 QWidget *widget = qmenu ? qmenu->widgetItems.value(action->action) : 0; |
1195 if (widget) { |
1197 if (widget) { |
1196 #ifndef QT_MAC_USE_COCOA |
1198 #ifndef QT_MAC_USE_COCOA |
1197 ChangeMenuAttributes(action->menu, kMenuAttrDoNotCacheImage, 0); |
1199 ChangeMenuAttributes(action->menu, kMenuAttrDoNotCacheImage, 0); |
1198 attr = kMenuItemAttrCustomDraw; |
1200 attr = kMenuItemAttrCustomDraw; |
1199 SetMenuItemProperty(action->menu, index, kMenuCreatorQt, kMenuPropertyWidgetActionWidget, |
1201 SetMenuItemProperty(action->menu, index, kMenuCreatorQt, kMenuPropertyWidgetActionWidget, |