summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoamenubar.mm
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2013-08-09 14:09:06 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-13 19:48:15 +0200
commit8c3b31182cbf53aad8d1979f612eefb93a548940 (patch)
tree9391745d67b20b8bcf104e9a411e6216e0a088eb /src/plugins/platforms/cocoa/qcocoamenubar.mm
parent1dcdc506f34bfa0d9adc6d07587a4a71dbda455b (diff)
Cocoa: Allow to hide menu items in menubar
Task-number: QTBUG-32899 Change-Id: I423ac2d636306303d39e973f19032c9004957095 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoamenubar.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index 8d1ca88b8e..ddfa9fff96 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -149,15 +149,17 @@ void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items())
cocoaMenu->syncMenuItem(item);
- // If the NSMenu has no visble items, or only separators, we should hide it
- // on the menubar. This can happen after syncing the menu items since they
- // can be moved to other menus.
BOOL shouldHide = YES;
- for (NSMenuItem *item in [cocoaMenu->nsMenu() itemArray])
- if (![item isSeparatorItem] && ![item isHidden]) {
- shouldHide = NO;
- break;
- }
+ if (cocoaMenu->isVisible()) {
+ // If the NSMenu has no visble items, or only separators, we should hide it
+ // on the menubar. This can happen after syncing the menu items since they
+ // can be moved to other menus.
+ for (NSMenuItem *item in [cocoaMenu->nsMenu() itemArray])
+ if (![item isSeparatorItem] && ![item isHidden]) {
+ shouldHide = NO;
+ break;
+ }
+ }
[cocoaMenu->nsMenuItem() setHidden:shouldHide];
}