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.
This commit is contained in:
Martin Gräßlin 2011-11-12 22:39:01 +01:00
parent f27a00d8cd
commit d89b9b3abe

View file

@ -77,6 +77,14 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize
} }
*size = s; *size = s;
QPixmap icon = client->icon(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) { if (parts.size() > 2) {
KIconEffect *effect = KIconLoader::global()->iconEffect(); KIconEffect *effect = KIconLoader::global()->iconEffect();
KIconLoader::States state = KIconLoader::DefaultState; KIconLoader::States state = KIconLoader::DefaultState;