Tint icon by selection color if selected, consistent with Dolphin.

This commit is contained in:
Eike Hein 2013-04-13 16:05:04 +02:00
parent 15428f1910
commit f979fab6c8

View file

@ -37,6 +37,7 @@
#include <KDirModel>
#include <KGlobalSettings>
#include <KIcon>
#include <KIconEffect>
#include <KStringHandler>
#include <KFileItemDelegate>
@ -1053,7 +1054,16 @@ void IconView::paintItem(QPainter *painter, const QStyleOptionViewItemV4 &option
const QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
const QRect ir = QStyle::alignedRect(option.direction, Qt::AlignTop | Qt::AlignHCenter,
option.decorationSize, r);
icon.paint(painter, ir);
if (selected) {
const QColor color = option.palette.brush(QPalette::Normal, QPalette::Highlight).color();
QImage image = icon.pixmap(ir.size()).toImage();
KIconEffect::colorize(image, color, 0.8f);
painter->drawPixmap(ir, QPixmap::fromImage(image));
} else {
icon.paint(painter, ir);
}
const QRect tr = r.adjusted(0, ir.bottom() - r.top() + 2, 0, 0);