Fixed Qt 5.3.2 tray icon with autohidden menu bar.

Also removed the old Qt 5.6.0 patch (only 5.6.2 is currently used).
This commit is contained in:
John Preston 2017-02-18 16:27:55 +03:00
parent 4232fa2f6e
commit 6e1b6e6e53
2 changed files with 19 additions and 12200 deletions

View file

@ -297,7 +297,7 @@ index e46eaff..c62db53 100644
}
return ret;
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
index 83c960d..3b9f8d4 100755
index 83c960d..03ae969 100755
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
@@ -102,7 +102,10 @@ QT_USE_NAMESPACE
@ -343,7 +343,7 @@ index 83c960d..3b9f8d4 100755
void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
{
if (!m_sys)
@@ -194,13 +214,17 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
@@ -194,13 +214,18 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
m_sys->item->icon = icon;
@ -351,11 +351,13 @@ index 83c960d..3b9f8d4 100755
+ // Patch: Nice macOS tray icon support.
+ //const bool menuVisible = m_sys->item->menu && m_sys->item->menuVisible;
CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
- CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
- const short scale = hgt - 4;
+ const int padding = 0;
+ const int menuHeight = [[NSStatusBar systemStatusBar] thickness];
+ const int maxImageHeight = menuHeight - padding;
+
+ // Patch: Nice macOS tray icon support.
+ const short scale = hgt * getDevicePixelRatio();
+ const short scale = maxImageHeight * getDevicePixelRatio();
QPixmap pm = m_sys->item->icon.pixmap(QSize(scale, scale),
- menuVisible ? QIcon::Selected : QIcon::Normal);
@ -364,7 +366,7 @@ index 83c960d..3b9f8d4 100755
if (pm.isNull()) {
pm = QPixmap(scale, scale);
pm.fill(Qt::transparent);
@@ -322,15 +346,13 @@ QT_END_NAMESPACE
@@ -322,15 +347,16 @@ QT_END_NAMESPACE
return self;
}
@ -374,18 +376,21 @@ index 83c960d..3b9f8d4 100755
{
- Q_UNUSED(notification);
- down = NO;
-
CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+ const int padding = 0;
+ const int menuHeight = [[NSStatusBar systemStatusBar] thickness];
+ const int maxImageHeight = menuHeight - padding;
- CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
- const short scale = hgt - 4;
-
- QPixmap pm = parent->icon.pixmap(QSize(scale, scale), QIcon::Normal);
+ const short scale = hgt * getDevicePixelRatio();
+ const short scale = maxImageHeight * getDevicePixelRatio();
+ QPixmap pm = parent->icon.pixmap(QSize(scale, scale),
+ parent->iconSelected ? QIcon::Selected : QIcon::Normal);
if (pm.isNull()) {
pm = QPixmap(scale, scale);
pm.fill(Qt::transparent);
@@ -338,9 +360,19 @@ QT_END_NAMESPACE
@@ -338,9 +364,19 @@ QT_END_NAMESPACE
NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage(pm));
[self setImage: nsaltimage];
[nsaltimage release];
@ -405,7 +410,7 @@ index 83c960d..3b9f8d4 100755
[self setNeedsDisplay:YES];
}
@@ -350,18 +382,9 @@ QT_END_NAMESPACE
@@ -350,18 +386,9 @@ QT_END_NAMESPACE
int clickCount = [mouseEvent clickCount];
[self setNeedsDisplay:YES];
@ -427,7 +432,7 @@ index 83c960d..3b9f8d4 100755
if (clickCount == 2) {
[self menuTrackingDone:nil];
@@ -380,6 +403,10 @@ QT_END_NAMESPACE
@@ -380,6 +407,10 @@ QT_END_NAMESPACE
{
Q_UNUSED(mouseEvent);
[self menuTrackingDone:nil];
@ -438,7 +443,7 @@ index 83c960d..3b9f8d4 100755
}
- (void)rightMouseDown:(NSEvent *)mouseEvent
@@ -391,6 +418,10 @@ QT_END_NAMESPACE
@@ -391,6 +422,10 @@ QT_END_NAMESPACE
{
Q_UNUSED(mouseEvent);
[self menuTrackingDone:nil];
@ -449,7 +454,7 @@ index 83c960d..3b9f8d4 100755
}
- (void)otherMouseDown:(NSEvent *)mouseEvent
@@ -405,7 +436,8 @@ QT_END_NAMESPACE
@@ -405,7 +440,8 @@ QT_END_NAMESPACE
}
-(void)drawRect:(NSRect)rect {

File diff suppressed because it is too large Load diff