OS X: Ensure system tray icon is prepared even when menu bar is hidden

On OS X 10.11 (El Capitan) the system menu bar can be automatically
hidden, in which case the menu bar height is reported to be 0 when
using the menuBarHeight API.

This resulted in failing to prepare an image for the system tray
icon item, making the tray item "invisible".

Instead we now use the [[NSStatusBar systemStatusBar] thickness]
API, which returns the correct height regardless of the menu bar
being hidden or not.

Task-number: QTBUG-48960
Change-Id: I208fb8df13754964a6f254cadfbff06dd56c6bab
Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com>
This commit is contained in:
Tor Arne Vestbø 2016-01-15 14:15:51 +01:00 committed by Timur Pocheptsov
parent 465e93aa95
commit 30bff91c39

View File

@ -198,7 +198,7 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
// current OS X versions is 22 points. Provide some future-proofing
// by deriving the icon height from the menu height.
const int padding = 4;
const int menuHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
const int menuHeight = [[NSStatusBar systemStatusBar] thickness];
const int maxImageHeight = menuHeight - padding;
// Select pixmap based on the device pixel height. Ideally we would use