78 lines
3.7 KiB
Diff
78 lines
3.7 KiB
Diff
From 3ce5e752c66307f905fdf732b102a396d9248fbb Mon Sep 17 00:00:00 2001
|
|
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
|
|
Date: Mon, 7 Dec 2020 13:22:02 -0500
|
|
Subject: [PATCH 6/6] git checkout v5.15.0 --
|
|
src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
|
|
|
|
---
|
|
.../cocoa/qcocoacolordialoghelper.mm | 50 +++++++++----------
|
|
1 file changed, 25 insertions(+), 25 deletions(-)
|
|
|
|
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
|
|
index 5ad1f9d7bb..c9fa035d87 100644
|
|
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
|
|
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
|
|
@@ -180,34 +180,34 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
|
|
|
|
- (void)updateQtColor
|
|
{
|
|
- // Discard the color space and pass the color components to QColor. This
|
|
- // is a good option as long as QColor is color-unmanaged: we preserve the
|
|
- // exact RGB value from the color picker, which is predictable. Further,
|
|
- // painting with the color will reproduce the same color on-screen, as
|
|
- // long as the the same screen is used for selecting the color.
|
|
- NSColor *componentColor = [[mColorPanel color] colorUsingType:NSColorTypeComponentBased];
|
|
- switch (componentColor.colorSpace.colorSpaceModel)
|
|
- {
|
|
- case NSColorSpaceModelGray: {
|
|
- CGFloat white = 0, alpha = 0;
|
|
- [componentColor getWhite:&white alpha:&alpha];
|
|
- mQtColor.setRgbF(white, white, white, alpha);
|
|
- } break;
|
|
- case NSColorSpaceModelRGB: {
|
|
- CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
|
- [componentColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
- mQtColor.setRgbF(red, green, blue, alpha);
|
|
- } break;
|
|
- case NSColorSpaceModelCMYK: {
|
|
+ NSColor *color = [mColorPanel color];
|
|
+ NSString *colorSpaceName = [color colorSpaceName];
|
|
+ if (colorSpaceName == NSDeviceCMYKColorSpace) {
|
|
CGFloat cyan = 0, magenta = 0, yellow = 0, black = 0, alpha = 0;
|
|
- [componentColor getCyan:&cyan magenta:&magenta yellow:&yellow black:&black alpha:&alpha];
|
|
+ [color getCyan:&cyan magenta:&magenta yellow:&yellow black:&black alpha:&alpha];
|
|
mQtColor.setCmykF(cyan, magenta, yellow, black, alpha);
|
|
- } break;
|
|
- default:
|
|
- qWarning("QNSColorPanelDelegate: Unsupported color space model");
|
|
- break;
|
|
+ } else if (colorSpaceName == NSCalibratedRGBColorSpace || colorSpaceName == NSDeviceRGBColorSpace) {
|
|
+ CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
|
+ [color getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
+ mQtColor.setRgbF(red, green, blue, alpha);
|
|
+ } else if (colorSpaceName == NSNamedColorSpace) {
|
|
+ NSColor *tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
+ CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
|
+ [tmpColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
+ mQtColor.setRgbF(red, green, blue, alpha);
|
|
+ } else {
|
|
+ NSColorSpace *colorSpace = [color colorSpace];
|
|
+ if ([colorSpace colorSpaceModel] == NSCMYKColorSpaceModel && [color numberOfComponents] == 5){
|
|
+ CGFloat components[5];
|
|
+ [color getComponents:components];
|
|
+ mQtColor.setCmykF(components[0], components[1], components[2], components[3], components[4]);
|
|
+ } else {
|
|
+ NSColor *tmpColor = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
|
|
+ CGFloat red = 0, green = 0, blue = 0, alpha = 0;
|
|
+ [tmpColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
+ mQtColor.setRgbF(red, green, blue, alpha);
|
|
+ }
|
|
}
|
|
-
|
|
if (mHelper)
|
|
emit mHelper->currentColorChanged(mQtColor);
|
|
}
|
|
--
|
|
2.21.0
|
|
|