diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-03-23 14:09:03 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-03-23 17:36:52 +0100 |
commit | c14f3deca91eb6e7ab23f5f73004f4f824b97d95 (patch) | |
tree | 1770fd7d40346694ab36466859477ee4efbfe55c /src/plugins | |
parent | 9ff75d4ea11c78ad4acaf5f51e119b5039595837 (diff) |
Fix deprecation warnings from NSColor(Space) with macOS 10.14 SDK
The support for handling color spaces by names is deprecated in
recent AppKit versions, and should be replaced by using
NSColor.type, and operations on the type-specific properties of
the color.
Merge the two implementations from qcoregraphics.mm and
qcocoacolordialoghelper.mm, which also fixes the inconsistent
interpretation of color components as device dependent (in
qcoregraphics) or generic (in qcocoacolordialoghelper). We now
always populate the QColor with device independent components.
Change-Id: Id79c609736ff1962bebe4bd7158781a6d1b4475e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index c9fa035d87..ff08a306c4 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -44,6 +44,7 @@ #include "qcocoacolordialoghelper.h" #include "qcocoahelpers.h" #include "qcocoaeventdispatcher.h" +#include "private/qcoregraphics_p.h" #import <AppKit/AppKit.h> @@ -181,33 +182,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); - (void)updateQtColor { NSColor *color = [mColorPanel color]; - NSString *colorSpaceName = [color colorSpaceName]; - if (colorSpaceName == NSDeviceCMYKColorSpace) { - CGFloat cyan = 0, magenta = 0, yellow = 0, black = 0, alpha = 0; - [color getCyan:&cyan magenta:&magenta yellow:&yellow black:&black alpha:&alpha]; - mQtColor.setCmykF(cyan, magenta, yellow, black, alpha); - } 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); - } - } + mQtColor = qt_mac_toQColor(color); if (mHelper) emit mHelper->currentColorChanged(mQtColor); } |