macOS: Restore fallback sizes when setting application or window icons

We removed this logic in 059c3ae66a under the assumption that the icon
would always provide a set of sizes, but for SVG icons this is not
the case.

Change-Id: Ib3cc5740bca32cf4068a71baf99b52fa536da2ca
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2020-04-17 17:08:21 +02:00
parent 164110f7bb
commit 86f228b819
2 changed files with 9 additions and 4 deletions

View File

@ -472,7 +472,9 @@ QList<QCocoaWindow *> *QCocoaIntegration::popupWindowStack()
void QCocoaIntegration::setApplicationIcon(const QIcon &icon) const void QCocoaIntegration::setApplicationIcon(const QIcon &icon) const
{ {
NSApp.applicationIconImage = [NSImage imageFromQIcon:icon]; // Fall back to a size that looks good on the highest resolution screen available
auto fallbackSize = NSApp.dockTile.size.width * qGuiApp->devicePixelRatio();
NSApp.applicationIconImage = [NSImage imageFromQIcon:icon withSize:fallbackSize];
} }
void QCocoaIntegration::beep() const void QCocoaIntegration::beep() const

View File

@ -904,10 +904,13 @@ void QCocoaWindow::setWindowIcon(const QIcon &icon)
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
if (icon.isNull()) if (icon.isNull()) {
iconButton.image = [NSWorkspace.sharedWorkspace iconForFile:m_view.window.representedFilename]; iconButton.image = [NSWorkspace.sharedWorkspace iconForFile:m_view.window.representedFilename];
else } else {
iconButton.image = [NSImage imageFromQIcon:icon]; // Fall back to a size that looks good on the highest resolution screen available
auto fallbackSize = iconButton.frame.size.height * qGuiApp->devicePixelRatio();
iconButton.image = [NSImage imageFromQIcon:icon withSize:fallbackSize];
}
} }
void QCocoaWindow::setAlertState(bool enabled) void QCocoaWindow::setAlertState(bool enabled)