macOS: Pass on QIcon as NSImage if possible, instead of going via QPixmap
The QIcon can be turned into a NSImage directly, with all the supported representations that the icon contains. This allows macOS to choose the best representation for whatever context it's rendering the NSImage in, and will likely do a better job of scaling it if none of the sizes fit target context. This fixes e.g. application window icons not taking retina screens into account. Change-Id: Idbd97cae4ef50cc0dd3f38c355cfceec007e0d19 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
bee3d0fc13
commit
059c3ae66a
@ -472,13 +472,7 @@ QList<QCocoaWindow *> *QCocoaIntegration::popupWindowStack()
|
||||
|
||||
void QCocoaIntegration::setApplicationIcon(const QIcon &icon) const
|
||||
{
|
||||
NSImage *image = nil;
|
||||
if (!icon.isNull()) {
|
||||
NSSize size = [[[NSApplication sharedApplication] dockTile] size];
|
||||
QPixmap pixmap = icon.pixmap(size.width, size.height);
|
||||
image = [NSImage imageFromQImage:pixmap.toImage()];
|
||||
}
|
||||
[[NSApplication sharedApplication] setApplicationIconImage:image];
|
||||
NSApp.applicationIconImage = [NSImage imageFromQIcon:icon];
|
||||
}
|
||||
|
||||
void QCocoaIntegration::beep() const
|
||||
|
@ -894,13 +894,10 @@ void QCocoaWindow::setWindowIcon(const QIcon &icon)
|
||||
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if (icon.isNull()) {
|
||||
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
|
||||
[iconButton setImage:[workspace iconForFile:m_view.window.representedFilename]];
|
||||
} else {
|
||||
QPixmap pixmap = icon.pixmap(QSize(22, 22));
|
||||
iconButton.image = [NSImage imageFromQImage:pixmap.toImage()];
|
||||
}
|
||||
if (icon.isNull())
|
||||
iconButton.image = [NSWorkspace.sharedWorkspace iconForFile:m_view.window.representedFilename];
|
||||
else
|
||||
iconButton.image = [NSImage imageFromQIcon:icon];
|
||||
}
|
||||
|
||||
void QCocoaWindow::setAlertState(bool enabled)
|
||||
|
Loading…
Reference in New Issue
Block a user