From 8cf9811ec378b9903e3f64d027f625d9ab0ac7db Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 22 Jan 2014 11:01:14 +0100 Subject: Do not overwrite basePixmap of QIconLoader PixmapEntry Change-Id: I4799af1d9151ba4b0952369e9620d2fab2b002d9 Reviewed-by: David Sansome Reviewed-by: Jens Bache-Wiig --- src/gui/image/qiconloader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index d202d62957..9e979023cd 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -519,10 +519,11 @@ QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State st return cachedPixmap; } else { if (basePixmap.size() != actualSize) - basePixmap = basePixmap.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - cachedPixmap = basePixmap; + cachedPixmap = basePixmap.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + else + cachedPixmap = basePixmap; if (QGuiApplication *guiApp = qobject_cast(qApp)) - cachedPixmap = static_cast(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, basePixmap); + cachedPixmap = static_cast(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, cachedPixmap); QPixmapCache::insert(key, cachedPixmap); } return cachedPixmap; -- cgit v1.2.3 From 6e13f4b3e03a055bafc78037b0bf68d90fbbe98d Mon Sep 17 00:00:00 2001 From: Bastiaan Veelo Date: Sat, 16 Nov 2013 21:42:01 +0100 Subject: Load all available pixmaps in an icon file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the problem that only the first icon would be read from an .ico file with muliple icons of various sizes in it. Task-number: QTBUG-28267 Change-Id: I50daa89769054234e9ffc5246f59b46975948871 Reviewed-by: Gunnar Sletta Reviewed-by: Thorbjørn Lund Martsum --- src/gui/image/qicon.cpp | 56 ++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index c1a8cfaa1e..0a4b50bbea 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -43,6 +43,7 @@ #include "qicon_p.h" #include "qiconengine.h" #include "qiconengineplugin.h" +#include "qimagereader.h" #include "private/qfactoryloader_p.h" #include "private/qiconloader_p.h" #include "qpainter.h" @@ -365,37 +366,40 @@ void QPixmapIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon void QPixmapIconEngine::addFile(const QString &fileName, const QSize &_size, QIcon::Mode mode, QIcon::State state) { if (!fileName.isEmpty()) { - QSize size = _size; - QPixmap pixmap; - QString abs = fileName; if (fileName.at(0) != QLatin1Char(':')) abs = QFileInfo(fileName).absoluteFilePath(); - - for (int i = 0; i < pixmaps.count(); ++i) { - if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) { - QPixmapIconEngineEntry *pe = &pixmaps[i]; - if(size == QSize()) { - pixmap = QPixmap(abs); - size = pixmap.size(); - } - if (pe->size == QSize() && pe->pixmap.isNull()) { - pe->pixmap = QPixmap(pe->fileName); - // Reset the devicePixelRatio. The pixmap may be loaded from a @2x file, - // but be used as a 1x pixmap by QIcon. - pe->pixmap.setDevicePixelRatio(1.0); - pe->size = pe->pixmap.size(); - } - if(pe->size == size) { - pe->pixmap = pixmap; - pe->fileName = abs; - return; + QImageReader reader(abs); + + do { + QSize size = _size; + QPixmap pixmap; + + for (int i = 0; i < pixmaps.count(); ++i) { + if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) { + QPixmapIconEngineEntry *pe = &pixmaps[i]; + if (size == QSize()) { + pixmap.convertFromImage(reader.read()); + size = pixmap.size(); + } + if (pe->size == QSize() && pe->pixmap.isNull()) { + pe->pixmap = QPixmap(pe->fileName); + // Reset the devicePixelRatio. The pixmap may be loaded from a @2x file, + // but be used as a 1x pixmap by QIcon. + pe->pixmap.setDevicePixelRatio(1.0); + pe->size = pe->pixmap.size(); + } + if (pe->size == size) { + pe->pixmap = pixmap; + pe->fileName = abs; + return; + } } } - } - QPixmapIconEngineEntry e(abs, size, mode, state); - e.pixmap = pixmap; - pixmaps += e; + QPixmapIconEngineEntry e(abs, size, mode, state); + e.pixmap = pixmap; + pixmaps += e; + } while (reader.jumpToNextImage()); } } -- cgit v1.2.3 From 8bb5dba0cba4d953794124d7f1b33887d1b5bd8d Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sat, 1 Feb 2014 23:30:08 +0800 Subject: Doc: Fix broken links Change-Id: Ic275dfbf0b332fc34ea0fac1c31c4935ad961527 Reviewed-by: Frederik Gladhorn --- src/gui/image/qpictureformatplugin.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qpictureformatplugin.cpp b/src/gui/image/qpictureformatplugin.cpp index c87b9ba6ac..69c3d9ccec 100644 --- a/src/gui/image/qpictureformatplugin.cpp +++ b/src/gui/image/qpictureformatplugin.cpp @@ -79,8 +79,6 @@ QT_BEGIN_NAMESPACE Installs a QPictureIO picture I/O handler for the picture format \a format. Returns \c true on success. - - \sa keys() */ -- cgit v1.2.3