diff options
author | Sakari Peltomäki <sakari.peltomaki@digia.com> | 2010-02-03 09:42:54 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2010-02-03 10:40:36 (GMT) |
commit | 7e46016d55a80e9d49797efe34779893d80b71e3 (patch) | |
tree | de7308dcf27a40a1cde85ee206f767d3b7414507 /src/plugins/imageformats | |
parent | 21a1613da90e7b3f0d2d2b03983e236a55db15b0 (diff) | |
download | Qt-7e46016d55a80e9d49797efe34779893d80b71e3.zip Qt-7e46016d55a80e9d49797efe34779893d80b71e3.tar.gz Qt-7e46016d55a80e9d49797efe34779893d80b71e3.tar.bz2 |
Proper Fav icon is not shown, for all the links default fav icon shown
Added two functions on QtIcoHandler(inherited from QImageIOHandler):
bool supports Option(ImageOption option) const
QVariant option(ImageOption option) const
implementation of these functions make possible to open fav.ico
eg. via web browser.
(if using fav.ico icons via webkit, browser should initialize
webcore::icondatabase using QWebSettings::enablePersistentStorage() )
Merge-request: 2150
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'src/plugins/imageformats')
-rw-r--r-- | src/plugins/imageformats/ico/qicohandler.cpp | 24 | ||||
-rw-r--r-- | src/plugins/imageformats/ico/qicohandler.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index b2351fa..4edb87a 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -53,6 +53,7 @@ #include <QtGui/QImage> #include <QtCore/QFile> #include <QtCore/QBuffer> +#include <qvariant.h> // These next two structs represent how the icon information is stored // in an ICO file. typedef struct @@ -772,6 +773,29 @@ QtIcoHandler::~QtIcoHandler() delete m_pICOReader; } +QVariant QtIcoHandler::option(ImageOption option) const +{ + if (option == Size) { + QIODevice *device = QImageIOHandler::device(); + qint64 oldPos = device->pos(); + ICONDIRENTRY iconEntry; + if (device->seek(oldPos + ICONDIR_SIZE + (m_currentIconIndex * ICONDIRENTRY_SIZE))) { + if (readIconDirEntry(device, &iconEntry)) { + device->seek(oldPos); + return QSize(iconEntry.bWidth, iconEntry.bHeight); + } + } + if (!device->isSequential()) + device->seek(oldPos); + } + return QVariant(); +} + +bool QtIcoHandler::supportsOption(ImageOption option) const +{ + return option == Size; +} + /*! * Verifies if some values (magic bytes) are set as expected in the header of the file. * If the magic bytes were found, it is assumed that the QtIcoHandler can read the file. diff --git a/src/plugins/imageformats/ico/qicohandler.h b/src/plugins/imageformats/ico/qicohandler.h index b9ef27e..394a5eb 100644 --- a/src/plugins/imageformats/ico/qicohandler.h +++ b/src/plugins/imageformats/ico/qicohandler.h @@ -62,6 +62,9 @@ public: static bool canRead(QIODevice *device); + bool supportsOption(ImageOption option) const; + QVariant option(ImageOption option) const; + private: int m_currentIconIndex; ICOReader *m_pICOReader; |