Apple: Use automatic rendering mode for icon engine
When requesting symbol icons the OS automatically chooses a rendering mode per icon. Most icons use the monochrome rendering mode by default, but some of them use the hierarchical. We don't want to override this choice by always using hierarchical, as that doesn't match the look of most icons in the system and may be surprising to the user. We still want to support tinted icons, based on the QPalette. For iOS this is easy via [UIImage withTintColor:] but for macOS we have to do an extra render pass. Unfortunately we can't use configurationWithPaletteColors with a single color, as for the hierarchical icons this will produce a different looking icon than if we tint the entire icon. [ChangeLog][macOS/iOS] The Apple icon engine, used for theme icons on macOS and iOS, will now use the default rendering mode for icons, typically monochrome, instead of always using hierarchical icons. Change-Id: I9e66d848222e8ed0f7f20897454f27446bf0fd81 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 9f392c09a1d30e48494b4df0e2f5f531c7e4ec4b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit e266949979624172bae7484b48c530cf48f8eb9d)
This commit is contained in:
parent
e38834a020
commit
7e2b84b8be
@ -362,17 +362,23 @@ auto *configuredImage(const NSImage *image, const QColor &color)
|
||||
auto *config = [NSImageSymbolConfiguration configurationWithPointSize:48
|
||||
weight:NSFontWeightRegular
|
||||
scale:NSImageSymbolScaleLarge];
|
||||
if (@available(macOS 12, *)) {
|
||||
auto *primaryColor = [NSColor colorWithSRGBRed:color.redF()
|
||||
green:color.greenF()
|
||||
blue:color.blueF()
|
||||
alpha:color.alphaF()];
|
||||
|
||||
auto *colorConfig = [NSImageSymbolConfiguration configurationWithHierarchicalColor:primaryColor];
|
||||
config = [config configurationByApplyingConfiguration:colorConfig];
|
||||
}
|
||||
NSImage *configuredImage = [image imageWithSymbolConfiguration:config];
|
||||
|
||||
return [image imageWithSymbolConfiguration:config];
|
||||
auto *primaryColor = [NSColor colorWithSRGBRed:color.redF()
|
||||
green:color.greenF()
|
||||
blue:color.blueF()
|
||||
alpha:color.alphaF()];
|
||||
|
||||
NSImage *tintedImage = [NSImage imageWithSize:configuredImage.size flipped:NO
|
||||
drawingHandler:^BOOL(NSRect) {
|
||||
[primaryColor set];
|
||||
NSRect imageRect = {NSZeroPoint, configuredImage.size};
|
||||
[configuredImage drawInRect:imageRect];
|
||||
NSRectFillUsingOperation(imageRect, NSCompositingOperationSourceIn);
|
||||
return YES;
|
||||
}];
|
||||
return tintedImage;
|
||||
}
|
||||
#elif defined(QT_PLATFORM_UIKIT)
|
||||
auto *configuredImage(const UIImage *image, const QColor &color)
|
||||
@ -381,16 +387,12 @@ auto *configuredImage(const UIImage *image, const QColor &color)
|
||||
weight:UIImageSymbolWeightRegular
|
||||
scale:UIImageSymbolScaleLarge];
|
||||
|
||||
if (@available(iOS 15, *)) {
|
||||
auto *primaryColor = [UIColor colorWithRed:color.redF()
|
||||
green:color.greenF()
|
||||
blue:color.blueF()
|
||||
alpha:color.alphaF()];
|
||||
auto *primaryColor = [UIColor colorWithRed:color.redF()
|
||||
green:color.greenF()
|
||||
blue:color.blueF()
|
||||
alpha:color.alphaF()];
|
||||
|
||||
auto *colorConfig = [UIImageSymbolConfiguration configurationWithHierarchicalColor:primaryColor];
|
||||
config = [config configurationByApplyingConfiguration:colorConfig];
|
||||
}
|
||||
return [image imageByApplyingSymbolConfiguration:config];
|
||||
return [[image imageByApplyingSymbolConfiguration:config] imageWithTintColor:primaryColor];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user