Before if the background of the delegate is not white, the gradient would paint

white, and look terrible. So, this fixes that by checking the background color and 
making the gradient that color.


svn path=/trunk/KDE/kdelibs/; revision=891038
This commit is contained in:
Jesse Lee Zamora 2008-12-01 01:14:35 +00:00
parent 7fca1acbb6
commit 0fd4c5e3b2

View File

@ -297,6 +297,8 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
painter->save(); painter->save();
painter->setPen(Qt::NoPen); painter->setPen(Qt::NoPen);
const QColor gradientColor =
KColorScheme(QPalette::Active).background(KColorScheme::NormalBackground).color();
if (option.direction == Qt::LeftToRight) { if (option.direction == Qt::LeftToRight) {
if ((titleRect.width() + 20) > option.rect.width() || if ((titleRect.width() + 20) > option.rect.width() ||
(subTitleRect.width() + 20) > option.rect.width()) { (subTitleRect.width() + 20) > option.rect.width()) {
@ -307,7 +309,7 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
gr.setStart(gradientRect.topLeft()); gr.setStart(gradientRect.topLeft());
gr.setFinalStop(gradientRect.topRight()); gr.setFinalStop(gradientRect.topRight());
gr.setColorAt(0.0, Qt::transparent); gr.setColorAt(0.0, Qt::transparent);
gr.setColorAt(0.7, Qt::white); gr.setColorAt(0.7, gradientColor);
painter->setBrush(QBrush(gr)); painter->setBrush(QBrush(gr));
painter->drawRect(gradientRect); painter->drawRect(gradientRect);
} }
@ -321,7 +323,7 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
gr.setStart(gradientRect.topRight()); gr.setStart(gradientRect.topRight());
gr.setFinalStop(gradientRect.topLeft()); gr.setFinalStop(gradientRect.topLeft());
gr.setColorAt(0.0, Qt::transparent); gr.setColorAt(0.0, Qt::transparent);
gr.setColorAt(0.6, Qt::white); gr.setColorAt(0.6, gradientColor);
painter->setBrush(QBrush(gr)); painter->setBrush(QBrush(gr));
painter->drawRect(gradientRect); painter->drawRect(gradientRect);
} }