Moved qt_mac_toQColor(CGColorRef) to qcocoahelpers.
Change-Id: I8f8feab3f2b88373bf9ad4d69b8de56b480910ac Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
7db24dd864
commit
ba1262187b
@ -80,6 +80,7 @@ NSRect qt_mac_toNSRect(const QRect &rect);
|
|||||||
QRect qt_mac_toQRect(const NSRect &rect);
|
QRect qt_mac_toQRect(const NSRect &rect);
|
||||||
|
|
||||||
QColor qt_mac_toQColor(const NSColor *color);
|
QColor qt_mac_toQColor(const NSColor *color);
|
||||||
|
QColor qt_mac_toQColor(CGColorRef color);
|
||||||
|
|
||||||
|
|
||||||
// Creates a mutable shape, it's the caller's responsibility to release.
|
// Creates a mutable shape, it's the caller's responsibility to release.
|
||||||
|
@ -225,6 +225,24 @@ QColor qt_mac_toQColor(const NSColor *color)
|
|||||||
return qtColor;
|
return qtColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor qt_mac_toQColor(CGColorRef color)
|
||||||
|
{
|
||||||
|
QColor qtColor;
|
||||||
|
CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(color));
|
||||||
|
const CGFloat *components = CGColorGetComponents(color);
|
||||||
|
if (model == kCGColorSpaceModelRGB) {
|
||||||
|
qtColor.setRgbF(components[0], components[1], components[2], components[3]);
|
||||||
|
} else if (model == kCGColorSpaceModelCMYK) {
|
||||||
|
qtColor.setCmykF(components[0], components[1], components[2], components[3]);
|
||||||
|
} else if (model == kCGColorSpaceModelMonochrome) {
|
||||||
|
qtColor.setRgbF(components[0], components[0], components[0], components[1]);
|
||||||
|
} else {
|
||||||
|
// Colorspace we can't deal with.
|
||||||
|
qWarning("Qt: qt_mac_toQColor: cannot convert from colorspace model: %d", model);
|
||||||
|
Q_ASSERT(false);
|
||||||
|
}
|
||||||
|
return qtColor;
|
||||||
|
}
|
||||||
|
|
||||||
// Use this method to keep all the information in the TextSegment. As long as it is ordered
|
// Use this method to keep all the information in the TextSegment. As long as it is ordered
|
||||||
// we are in OK shape, and we can influence that ourselves.
|
// we are in OK shape, and we can influence that ourselves.
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
#include "qcocoasystemsettings.h"
|
#include "qcocoasystemsettings.h"
|
||||||
|
|
||||||
|
#include "qcocoahelpers.h"
|
||||||
|
|
||||||
#include <QtCore/private/qcore_mac_p.h>
|
#include <QtCore/private/qcore_mac_p.h>
|
||||||
#include <QtGui/qfont.h>
|
#include <QtGui/qfont.h>
|
||||||
|
|
||||||
@ -48,30 +50,11 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QColor qt_mac_colorFromCGColor(CGColorRef cgcolor)
|
|
||||||
{
|
|
||||||
QColor pc;
|
|
||||||
CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(cgcolor));
|
|
||||||
const CGFloat *components = CGColorGetComponents(cgcolor);
|
|
||||||
if (model == kCGColorSpaceModelRGB) {
|
|
||||||
pc.setRgbF(components[0], components[1], components[2], components[3]);
|
|
||||||
} else if (model == kCGColorSpaceModelCMYK) {
|
|
||||||
pc.setCmykF(components[0], components[1], components[2], components[3]);
|
|
||||||
} else if (model == kCGColorSpaceModelMonochrome) {
|
|
||||||
pc.setRgbF(components[0], components[0], components[0], components[1]);
|
|
||||||
} else {
|
|
||||||
// Colorspace we can't deal with.
|
|
||||||
qWarning("Qt: qcolorFromCGColor: cannot convert from colorspace model: %d", model);
|
|
||||||
Q_ASSERT(false);
|
|
||||||
}
|
|
||||||
return pc;
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor qt_mac_colorForTheme(ThemeBrush brush)
|
QColor qt_mac_colorForTheme(ThemeBrush brush)
|
||||||
{
|
{
|
||||||
QCFType<CGColorRef> cgClr = 0;
|
QCFType<CGColorRef> cgClr = 0;
|
||||||
HIThemeBrushCreateCGColor(brush, &cgClr);
|
HIThemeBrushCreateCGColor(brush, &cgClr);
|
||||||
return qt_mac_colorFromCGColor(cgClr);
|
return qt_mac_toQColor(cgClr);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor qt_mac_colorForThemeTextColor(ThemeTextColor themeColor)
|
QColor qt_mac_colorForThemeTextColor(ThemeTextColor themeColor)
|
||||||
|
Loading…
Reference in New Issue
Block a user