From d89b9b3abef6db5005cfee48d243f3db67385c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 12 Nov 2011 22:39:01 +0100 Subject: [PATCH] Do not stretch icons but use the smaller one with padding Thanks to Iceweasel for providing a maximum icon of 48x48 which looks really bad when upscaled to 128x128. Orig icon is placed in the center of a new pixmap in requested size. --- tabbox/declarative.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tabbox/declarative.cpp b/tabbox/declarative.cpp index e1a3cf9fb4..f7a9c989df 100644 --- a/tabbox/declarative.cpp +++ b/tabbox/declarative.cpp @@ -77,6 +77,14 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize } *size = s; QPixmap icon = client->icon(s); + if (s.width() > icon.width() || s.height() > icon.height()) { + // icon is smaller than what we requested - QML would scale it which looks bad + QPixmap temp(s); + temp.fill(Qt::transparent); + QPainter p(&temp); + p.drawPixmap(s.width()/2 - icon.width()/2, s.height()/2 - icon.height()/2, icon); + icon = temp; + } if (parts.size() > 2) { KIconEffect *effect = KIconLoader::global()->iconEffect(); KIconLoader::States state = KIconLoader::DefaultState;