StyleHelper: Fixing alphaBlendedColors

Change-Id: Ib2f5e37e213e221ecfcce876ed2f44013815ca46
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Thomas Hartmann
2016-07-28 10:25:51 +02:00
committed by Alessandro Portale
parent 4bdd1ffbf7
commit 80ca67e43f

View File

@@ -66,14 +66,14 @@ QColor StyleHelper::mergedColors(const QColor &colorA, const QColor &colorB, int
QColor StyleHelper::alphaBlendedColors(const QColor &colorA, const QColor &colorB) QColor StyleHelper::alphaBlendedColors(const QColor &colorA, const QColor &colorB)
{ {
const QRgb base = colorA.rgba(); const int alpha = colorB.alpha();
const QRgb overlay = colorB.rgba(); const int antiAlpha = 255 - alpha;
const qreal overlayIntensity = qAlpha(overlay) / 255.0;
return qRgba( return QColor(
qMin(qRed(base) + qRound(qRed(overlay) * overlayIntensity), 0xff), (colorA.red() * antiAlpha + colorB.red() * alpha) / 255,
qMin(qGreen(base) + qRound(qGreen(overlay) * overlayIntensity), 0xff), (colorA.green() * antiAlpha + colorB.green() * alpha) / 255,
qMin(qBlue(base) + qRound(qBlue(overlay) * overlayIntensity), 0xff), (colorA.blue() * antiAlpha + colorB.blue() * alpha) / 255
qMin(qAlpha(base) + qAlpha(overlay), 0xff)); );
} }
qreal StyleHelper::sidebarFontSize() qreal StyleHelper::sidebarFontSize()