From 1514917196835887c4d4c93cf2522d1a70285c16 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 23 Nov 2009 17:03:38 +0100 Subject: Fixes: Fuzzy standard icons with Ubuntu Humanity theme Task: QTBUG-6121 RevBy: thorbjorn Details: This icon theme is a bit special in that it uses svg icons even for fixed size entries such as 16x16 icons. An optimization in the icon loader explicitly ignores svgs for such entries so we simply have to remove this check. In addition the actualSize had to be altered to never return a size bigger than the requested size. Otherwise certain menu elements will be bigger than intended. --- src/gui/image/qiconloader.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 15af7a2..ad9bdd0 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -249,21 +249,19 @@ QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName, const QIconDirInfo &dirInfo = subDirs.at(i); QString subdir = dirInfo.path; QDir currentDir(contentDir + subdir); - - if (dirInfo.type == QIconDirInfo::Scalable && m_supportsSvg && - currentDir.exists(iconName + svgext)) { - ScalableEntry *iconEntry = new ScalableEntry; - iconEntry->dir = dirInfo; - iconEntry->filename = currentDir.filePath(iconName + svgext); - entries.append(iconEntry); - - } else if (currentDir.exists(iconName + pngext)) { + if (currentDir.exists(iconName + pngext)) { PixmapEntry *iconEntry = new PixmapEntry; iconEntry->dir = dirInfo; iconEntry->filename = currentDir.filePath(iconName + pngext); // Notice we ensure that pixmap entries allways come before // scalable to preserve search order afterwards entries.prepend(iconEntry); + } else if (m_supportsSvg && + currentDir.exists(iconName + svgext)) { + ScalableEntry *iconEntry = new ScalableEntry; + iconEntry->dir = dirInfo; + iconEntry->filename = currentDir.filePath(iconName + svgext); + entries.append(iconEntry); } } @@ -444,10 +442,8 @@ QIconLoaderEngineEntry *QIconLoaderEngine::entryForSize(const QSize &size) /* * Returns the actual icon size. For scalable svg's this is equivalent - * to the requested size. Otherwise the closest match is returned. - * - * todo: the spec is a bit fuzzy in this area, but we should probably - * allow scaling down pixmap icons as well. + * to the requested size. Otherwise the closest match is returned but + * we can never return a bigger size than the requested size. * */ QSize QIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode, @@ -460,8 +456,10 @@ QSize QIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode, const QIconDirInfo &dir = entry->dir; if (dir.type == QIconDirInfo::Scalable) return size; - else - return QSize(dir.size, dir.size); + else { + int result = qMin(dir.size, qMin(size.width(), size.height())); + return QSize(result, result); + } } return QIconEngineV2::actualSize(size, mode, state); } -- cgit v0.12