Fix incorrect state of show/hide menu items in Mac application menu

The "Hide <app>", "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 <morten.sorvig@nokia.com>
(cherry picked from commit 8f23a6be1069455e609e8bea7527726c24bebb36)
This commit is contained in:
Pasi Matilainen 2012-02-02 08:18:50 +02:00 committed by Qt by Nokia
parent 73db181e83
commit b3670edba4
3 changed files with 13 additions and 0 deletions

View File

@ -88,6 +88,7 @@
- (IBAction)qtDispatcherToQAction:(id)sender;
- (void)qtUpdateMenubar;
- (void)orderFrontCharacterPalette:(id)sender;
- (BOOL)validateMenuItem:(NSMenuItem*)menuItem;
@end
void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader);

View File

@ -310,4 +310,16 @@ void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader)
{
[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