From 8f23a6be1069455e609e8bea7527726c24bebb36 Mon Sep 17 00:00:00 2001 From: Pasi Matilainen Date: Thu, 2 Feb 2012 08:18:50 +0200 Subject: Fix incorrect state of show/hide menu items in Mac application menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Hide ", "Hide Others" and "Show All" menu items in Mac application menu are always enabled, and do not get disabled correctly. Fix by turning on autoenable for the menu in qt_menu.nib, and by implementing menu item validation in QCocoaMenuLoader. Task-number: QTBUG-10705 Change-Id: Ic181dfa26a71acad0067f5269c72517b50b17362 Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qcocoamenuloader_mac.mm | 12 ++++++++++++ src/gui/kernel/qcocoamenuloader_mac_p.h | 1 + src/gui/mac/qt_menu.nib/keyedobjects.nib | Bin 5560 -> 5560 bytes 3 files changed, 13 insertions(+) diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm index ce30ad2..2a2fb50 100644 --- a/src/gui/kernel/qcocoamenuloader_mac.mm +++ b/src/gui/kernel/qcocoamenuloader_mac.mm @@ -260,5 +260,17 @@ QT_USE_NAMESPACE { [NSApp orderFrontCharacterPalette:sender]; } + +- (BOOL)validateMenuItem:(NSMenuItem*)menuItem +{ + if ([menuItem action] == @selector(hide:) + || [menuItem action] == @selector(hideOtherApplications:) + || [menuItem action] == @selector(unhideAllApplications:)) { + return [NSApp validateMenuItem:menuItem]; + } else { + return [menuItem isEnabled]; + } +} + @end #endif // QT_MAC_USE_COCOA diff --git a/src/gui/kernel/qcocoamenuloader_mac_p.h b/src/gui/kernel/qcocoamenuloader_mac_p.h index 3be399f..a4a139f 100644 --- a/src/gui/kernel/qcocoamenuloader_mac_p.h +++ b/src/gui/kernel/qcocoamenuloader_mac_p.h @@ -89,6 +89,7 @@ - (IBAction)qtDispatcherToQAction:(id)sender; - (void)qtUpdateMenubar; - (void)orderFrontCharacterPalette:(id)sender; +- (BOOL)validateMenuItem:(NSMenuItem*)menuItem; @end #endif // QT_MAC_USE_COCOA diff --git a/src/gui/mac/qt_menu.nib/keyedobjects.nib b/src/gui/mac/qt_menu.nib/keyedobjects.nib index 3edb0ed..67207ca 100644 Binary files a/src/gui/mac/qt_menu.nib/keyedobjects.nib and b/src/gui/mac/qt_menu.nib/keyedobjects.nib differ -- cgit v0.12