From b3670edba4bb46389b0005f506c524ea132aac69 Mon Sep 17 00:00:00 2001 From: Pasi Matilainen Date: Thu, 2 Feb 2012 08:18:50 +0200 Subject: [PATCH] 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 (cherry picked from commit 8f23a6be1069455e609e8bea7527726c24bebb36) --- .../platforms/cocoa/qcocoamenuloader.h | 1 + .../platforms/cocoa/qcocoamenuloader.mm | 12 ++++++++++++ .../cocoa/qt_menu.nib/keyedobjects.nib | Bin 5560 -> 5560 bytes 3 files changed, 13 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.h b/src/plugins/platforms/cocoa/qcocoamenuloader.h index 128792410b..b0d61fa541 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.h +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.h @@ -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); diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm index 4993937b91..2fdc28de1e 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm @@ -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 diff --git a/src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nib b/src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nib index 3edb0ed2ebfc57fa56eb94365f09d3855531e550..67207ca62836fa2c75630f5a7004fb5dc4757c3d 100644 GIT binary patch delta 2843 zcmai0dvp}#6~FhJnVkscsKbFlbe@!A1%Wav{@uw0EBQC+Jq2*;b+qVzPcz|=eH3iQYi)F#vL06w@S z&Hj|pF;F0_v9fej(yTdbhB@wOxf6#q27-ZbyJ{>5$2wKR@vKflId80w z@H^QJfnZsjj8^FJr3(VVxw>vzTUmAm`Ob)i4MR03n6aRs$$nTA2v$d%Q+V}+uC6rc z#lqxk+t7B?HI3*}A{26XFRkl;&Bq@pESQ6^Is2NjjmeG}J zvvbe;^K=im0X&JzmoM{7-j`=^&tJg{?Vv#fbm)L(5C;Ry1tXH`k_Z9a-)ZWqW~WM; z+oUQ@wcX$&_#}l7;)AWeQZ9*7ES26Aa=Uv~o2wd5w%w2b-y0NT9IS*@aG$kSDo7C1 zUYu@t2z=CL9dWfqjjI~f+J-+4li)U34L=FF`xA#~q`H&RF|U-rhwdH*pUp2Cx$^c+ zijx$54XlNAu-;KMo!_=Npsw(Dbi|@fw&-4sY6MeZ18n3)yI>P+hDYHstHL!R;e|#B z!4e3Q9!>B|*aofe1Uw1bVTUari8hoE;T~e;kLaCd{x!JToVN-0X;^#>$TP4TTHsj% z+5>xGAMB^>D~*b1bF-@P{%I-DJnpIUM@HM2HRd}6(?~EOIN)$O=&(5i&l6B9!TlOu zq~Dj|u$3?8CDPMuT4}`0b7RLN@N&xW75F_l{t;falev+bo%w4N?RCojDE!HB`!oCn zj=^zw1Ky-&3wB1@sRyW?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