From 0fd4c5e3b24b2ef456e863da36b5ae7a00b055e1 Mon Sep 17 00:00:00 2001 From: Jesse Lee Zamora Date: Mon, 1 Dec 2008 01:14:35 +0000 Subject: [PATCH] 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 --- delegate.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/delegate.cpp b/delegate.cpp index a42bd2afa..fa399d77c 100644 --- a/delegate.cpp +++ b/delegate.cpp @@ -297,6 +297,8 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->save(); painter->setPen(Qt::NoPen); + const QColor gradientColor = + KColorScheme(QPalette::Active).background(KColorScheme::NormalBackground).color(); if (option.direction == Qt::LeftToRight) { if ((titleRect.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.setFinalStop(gradientRect.topRight()); gr.setColorAt(0.0, Qt::transparent); - gr.setColorAt(0.7, Qt::white); + gr.setColorAt(0.7, gradientColor); painter->setBrush(QBrush(gr)); painter->drawRect(gradientRect); } @@ -321,7 +323,7 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, gr.setStart(gradientRect.topRight()); gr.setFinalStop(gradientRect.topLeft()); gr.setColorAt(0.0, Qt::transparent); - gr.setColorAt(0.6, Qt::white); + gr.setColorAt(0.6, gradientColor); painter->setBrush(QBrush(gr)); painter->drawRect(gradientRect); }