From acdbe4556ca139e977b129e4858f4ae599ad0d0e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 18 Oct 2012 19:41:56 +0200 Subject: [PATCH] for small sizes, paint icons in a standard size fixes blurry icons in the panel --- widgets/iconwidget.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/widgets/iconwidget.cpp b/widgets/iconwidget.cpp index e29ec0fe1..a2092a483 100644 --- a/widgets/iconwidget.cpp +++ b/widgets/iconwidget.cpp @@ -810,16 +810,34 @@ QPixmap IconWidgetPrivate::decoration(const QStyleOptionGraphicsItem *option, bo QIcon::Mode mode = option->state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled; QIcon::State state = option->state & QStyle::State_Open ? QIcon::On : QIcon::Off; + QSize finalSize(iconSize.toSize()); + //for small sizes, use a standard size + if (finalSize.width() < KIconLoader::SizeSmallMedium) { + finalSize = QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall); + } else if (finalSize.width() < KIconLoader::SizeMedium) { + finalSize = QSize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium); + } else if (finalSize.width() < KIconLoader::SizeLarge) { + finalSize = QSize(KIconLoader::SizeMedium, KIconLoader::SizeMedium); + } + if (iconSvg) { if (iconSvgElementChanged || iconSvgPixmap.size() != iconSize.toSize()) { - iconSvg->resize(iconSize); + //even the svg is returned at standard sizes because: + // * it may have a version optimized for that size + // * look aligned with other icons + iconSvg->resize(finalSize); iconSvgPixmap = iconSvg->pixmap(iconSvgElement); iconSvgElementChanged = false; } result = iconSvgPixmap; } else { - const QSize size = icon.actualSize(iconSize.toSize(), mode, state); - result = icon.pixmap(size, mode, state); + QSize size(iconSize.toSize()); + //the QIcon isn't filled with available sizes, return a near standard size for small pixmaps + if (!icon.availableSizes().isEmpty()) { + finalSize = icon.actualSize(iconSize.toSize(), mode, state); + } + + result = icon.pixmap(finalSize, mode, state); } if (usePressedEffect) {