about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/macos-sdk-10.12/0006-git-checkout-v5.15.0-src-plugins-platforms-cocoa-qco.patch
blob: b5c634aff76bcf70ae1d7fb42b65af38bb8d91e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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