From b6389bb6d4a85d1096cf3001b889364e8f31cac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 13 Sep 2011 14:34:03 +0200 Subject: Fixed tst_QIcon::task184901_badCache(). QIcon has not been moved to QtGui after all, re-introduce QtWidgets-dependent code path. Task-number: QTBUG-21402 Change-Id: I61c37babaeceadf7d53c10736bcc847758adaf1b Reviewed-on: http://codereview.qt-project.org/4775 Reviewed-by: Qt Sanity Bot Reviewed-by: Lars Knoll --- src/widgets/kernel/qicon.cpp | 60 ++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'src/widgets/kernel/qicon.cpp') diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp index ec8740b7ef..bb9f56b715 100644 --- a/src/widgets/kernel/qicon.cpp +++ b/src/widgets/kernel/qicon.cpp @@ -54,7 +54,7 @@ #include "qcache.h" #include "qdebug.h" #include "private/qguiplatformplugin_p.h" -#include "qguiapplication.h" +#include "qapplication.h" #ifdef Q_WS_MAC #include @@ -264,37 +264,37 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St actualSize.scale(size, Qt::KeepAspectRatio); // #### Qt5 no idea what this really does, but we need to remove the QApp and style references -// QString key = QLatin1Literal("qt_") -// % HexString(pm.cacheKey()) -// % HexString(pe->mode) -// % HexString(QApplication::palette().cacheKey()) -// % HexString(actualSize.width()) -// % HexString(actualSize.height()); - -// if (mode == QIcon::Active) { -// if (QPixmapCache::find(key % HexString(mode), pm)) -// return pm; // horray -// if (QPixmapCache::find(key % HexString(QIcon::Normal), pm)) { -// QStyleOption opt(0); -// opt.palette = QApplication::palette(); -// QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); -// if (pm.cacheKey() == active.cacheKey()) -// return pm; -// } -// } - -// if (!QPixmapCache::find(key % HexString(mode), pm)) { + QString key = QLatin1Literal("qt_") + % HexString(pm.cacheKey()) + % HexString(pe->mode) + % HexString(QApplication::palette().cacheKey()) + % HexString(actualSize.width()) + % HexString(actualSize.height()); + + if (mode == QIcon::Active) { + if (QPixmapCache::find(key % HexString(mode), pm)) + return pm; // horray + if (QPixmapCache::find(key % HexString(QIcon::Normal), pm)) { + QStyleOption opt(0); + opt.palette = QApplication::palette(); + QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); + if (pm.cacheKey() == active.cacheKey()) + return pm; + } + } + + if (!QPixmapCache::find(key % HexString(mode), pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); -// if (pe->mode != mode && mode != QIcon::Normal) { -// QStyleOption opt(0); -// opt.palette = QApplication::palette(); -// QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt); -// if (!generated.isNull()) -// pm = generated; -// } -// QPixmapCache::insert(key % HexString(mode), pm); -// } + if (pe->mode != mode && mode != QIcon::Normal) { + QStyleOption opt(0); + opt.palette = QApplication::palette(); + QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt); + if (!generated.isNull()) + pm = generated; + } + QPixmapCache::insert(key % HexString(mode), pm); + } return pm; } -- cgit v1.2.3