diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-09-13 14:34:03 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-15 09:11:35 +0200 |
commit | b6389bb6d4a85d1096cf3001b889364e8f31cac2 (patch) | |
tree | f6bce036c893d13af7717af4e9edfb3fb0de61ce /src/widgets | |
parent | d6f971c8547d7f0619b63f7e07f1c292e811b45f (diff) |
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 <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qicon.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
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 <private/qt_mac_p.h> @@ -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<quint64>(pm.cacheKey()) -// % HexString<uint>(pe->mode) -// % HexString<quint64>(QApplication::palette().cacheKey()) -// % HexString<uint>(actualSize.width()) -// % HexString<uint>(actualSize.height()); - -// if (mode == QIcon::Active) { -// if (QPixmapCache::find(key % HexString<uint>(mode), pm)) -// return pm; // horray -// if (QPixmapCache::find(key % HexString<uint>(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<uint>(mode), pm)) { + QString key = QLatin1Literal("qt_") + % HexString<quint64>(pm.cacheKey()) + % HexString<uint>(pe->mode) + % HexString<quint64>(QApplication::palette().cacheKey()) + % HexString<uint>(actualSize.width()) + % HexString<uint>(actualSize.height()); + + if (mode == QIcon::Active) { + if (QPixmapCache::find(key % HexString<uint>(mode), pm)) + return pm; // horray + if (QPixmapCache::find(key % HexString<uint>(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<uint>(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<uint>(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<uint>(mode), pm); + } return pm; } |