drop icon engine plugins support

no double-caching of the pixmap (QPixmap::load() inserts into
QPixmapCache) and one less global static factory for plugins, no
functional change

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-05-25 01:28:53 +03:00
parent 80ff16d461
commit 9e638071f3
18 changed files with 23 additions and 612 deletions

View file

@ -560,7 +560,6 @@ katie_generate_obsolete(QHBoxLayout QtGui qboxlayout.h)
katie_generate_obsolete(QHelpEvent QtGui qevent.h)
katie_generate_obsolete(QHideEvent QtGui qevent.h)
katie_generate_obsolete(QHoverEvent QtGui qevent.h)
katie_generate_obsolete(QIconEnginePluginV2 QtGui qiconengineplugin.h)
katie_generate_obsolete(QIconEngineV2 QtGui qiconengine.h)
katie_generate_obsolete(QImageIOPlugin QtGui qimageiohandler.h)
katie_generate_obsolete(QIncompatibleFlag QtCore qglobal.h)

View file

@ -458,8 +458,6 @@ include/katie/QtGui/QHideEvent
include/katie/QtGui/QHoverEvent
include/katie/QtGui/QIcon
include/katie/QtGui/QIconEngine
include/katie/QtGui/QIconEnginePlugin
include/katie/QtGui/QIconEnginePluginV2
include/katie/QtGui/QIconEngineV2
include/katie/QtGui/QIdentityProxyModel
include/katie/QtGui/QImage
@ -768,7 +766,6 @@ include/katie/QtGui/qguiplatformplugin.h
include/katie/QtGui/qheaderview.h
include/katie/QtGui/qicon.h
include/katie/QtGui/qiconengine.h
include/katie/QtGui/qiconengineplugin.h
include/katie/QtGui/qidentityproxymodel.h
include/katie/QtGui/qimage.h
include/katie/QtGui/qimageiohandler.h

View file

@ -153,7 +153,6 @@ incmap = {
'QHelpEvent': 'qevent.h',
'QHideEvent': 'qevent.h',
'QHoverEvent': 'qevent.h',
'QIconEnginePluginV2': 'qiconengineplugin.h',
'QIconEngineV2': 'qiconengine.h',
'QImageIOPlugin': 'qimageiohandler.h',
'QInputEvent': 'qevent.h',

View file

@ -231,8 +231,6 @@ classlist = [
"QIPv6Address",
"QIcon",
"QIconEngine",
"QIconEnginePlugin",
"QIconEnginePluginV2",
"QIconEngineV2",
"QIdentityProxyModel",
"QImage",

View file

@ -81,7 +81,6 @@ set(GUI_PUBLIC_HEADERS
QHeaderView
QIcon
QIconEngine
QIconEnginePlugin
QIdentityProxyModel
QImage
QImageIOHandler
@ -283,7 +282,6 @@ set(GUI_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/image/qicon_p.h
${CMAKE_CURRENT_SOURCE_DIR}/image/qiconloader_p.h
${CMAKE_CURRENT_SOURCE_DIR}/image/qiconengine.h
${CMAKE_CURRENT_SOURCE_DIR}/image/qiconengineplugin.h
${CMAKE_CURRENT_SOURCE_DIR}/image/qimage.h
${CMAKE_CURRENT_SOURCE_DIR}/image/qimage_p.h
${CMAKE_CURRENT_SOURCE_DIR}/image/qimageiohandler.h
@ -637,7 +635,6 @@ set(GUI_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/image/qpixmapcache.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image/qpixmapdata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image/qiconengine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image/qiconengineplugin.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image/qmovie.cpp
# Built-in image format support
${CMAKE_CURRENT_SOURCE_DIR}/image/qppmhandler.cpp

View file

@ -22,7 +22,6 @@
#include "qicon.h"
#include "qicon_p.h"
#include "qiconengine.h"
#include "qiconengineplugin.h"
#include "qiconloader_p.h"
#include "qapplication.h"
#include "qstyleoption.h"
@ -422,10 +421,7 @@ bool QPixmapIconEngine::write(QDataStream &out) const
engine scales pixmaps down if required, but never up, and it uses
the current style to calculate a disabled appearance. By using
custom icon engines, you can customize every aspect of generated
icons. With QIconEnginePluginV2 it is possible to register different
icon engines for different file suffixes, making it possible for
third parties to provide additional icon engines to those included
with Qt.
icons.
\note Since Qt 4.2, an icon engine that supports SVG is included.
@ -723,29 +719,8 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
if (fileName.isEmpty())
return;
if (!d) {
const QFileInfo info(fileName);
const QString suffix = info.suffix().toLower();
if (suffix == QLatin1String("png")) {
d = new QIconPrivate();
d->engine = new QPixmapIconEngine();
}
#if !defined (QT_NO_LIBRARY)
if (!d && !suffix.isEmpty()) {
if (QIconEnginePlugin *plugin = qobject_cast<QIconEnginePlugin*>(iconloader()->instance(suffix))) {
if (QIconEngine *engine = plugin->create(fileName)) {
d = new QIconPrivate();
d->engine = engine;
}
}
}
#endif
// ...then fall back to the default engine
if (!d) {
d = new QIconPrivate();
d->engine = new QPixmapIconEngine();
}
d = new QIconPrivate();
d->engine = new QPixmapIconEngine();
} else {
detach();
}
@ -957,14 +932,6 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon)
QIconEngine *engine = new QIconLoaderEngine();
icon.d->engine = engine;
engine->read(s);
#if !defined (QT_NO_LIBRARY)
} else if (QIconEnginePlugin *plugin = qobject_cast<QIconEnginePlugin*>(iconloader()->instance(key))) {
if (QIconEngine *engine= plugin->create()) {
icon.d = new QIconPrivate();
icon.d->engine = engine;
engine->read(s);
}
#endif
}
return s;
}

View file

@ -43,8 +43,6 @@ QT_BEGIN_NAMESPACE
The paint(), pixmap(), and addPixmap() functions are all virtual, and can
therefore be reimplemented in subclasses of QIconEngine.
\sa QIconEnginePlugin
*/
/*!

View file

@ -1,74 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtGui module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qiconengineplugin.h"
#include "qiconengine.h"
QT_BEGIN_NAMESPACE
/*!
\class QIconEnginePlugin
\brief The QIconEnginePlugin class provides an abstract base for custom QIconEngine plugins.
\ingroup plugins
The icon engine plugin is a simple plugin interface that makes it easy to
create custom icon engines that can be loaded dynamically into applications
through QIcon. QIcon uses the file or resource name's suffix to determine
what icon engine to use.
Writing a icon engine plugin is achieved by subclassing this base class,
reimplementing the pure virtual functioncreate() and exporting the class
with the Q_EXPORT_PLUGIN() macro.
*/
/*!
\fn QIconEngine* QIconEnginePlugin::create(const QString& filename)
Creates and returns a QIconEngine object for the icon with the given
\a filename.
\sa keys()
*/
/*!
Constructs a icon engine plugin with the given \a parent. This is invoked
automatically by the Q_EXPORT_PLUGIN() macro.
*/
QIconEnginePlugin::QIconEnginePlugin(QObject *parent)
: QObject(parent)
{
}
/*!
Destroys the icon engine plugin.
You never have to call this explicitly. Qt destroys a plugin
automatically when it is no longer used.
*/
QIconEnginePlugin::~QIconEnginePlugin()
{
}
QT_END_NAMESPACE
#include "moc_qiconengineplugin.h"

View file

@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the QtGui module of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QICONENGINEPLUGIN_H
#define QICONENGINEPLUGIN_H
#include <QtCore/qplugin.h>
QT_BEGIN_NAMESPACE
class QIconEngine;
class Q_GUI_EXPORT QIconEnginePlugin : public QObject
{
Q_OBJECT
public:
QIconEnginePlugin(QObject *parent = nullptr);
~QIconEnginePlugin();
virtual QIconEngine *create(const QString &filename = QString()) = 0;
};
typedef QIconEnginePlugin QIconEnginePluginV2;
QT_END_NAMESPACE
#endif // QICONENGINEPLUGIN_H

View file

@ -28,15 +28,15 @@
#include "qguicommon_p.h"
#include "qcore_unix_p.h"
#include <QtGui/QIconEnginePlugin>
#include <QtGui/QPixmapCache>
#include <QtGui/QIconEngine>
#include <QtGui/QStyleOption>
#include <QtCore/QList>
#include <QtCore/QHash>
#include <QtCore/QDir>
#include <QtCore/QSettings>
#include <QtGui/QPainter>
#include <QtGui/QImageReader>
#include <QtGui/QPixmapCache>
#include <QtGui/QIconEngine>
#include <QtGui/QStyleOption>
#include <limits.h>
@ -47,8 +47,8 @@ Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance)
/* Theme to use in last resort, if the theme does not have the icon, neither the parents */
static const QString fallbackTheme = QLatin1String("hicolor");
QIconLoader::QIconLoader() :
m_themeKey(1), m_supportsSvg(false)
QIconLoader::QIconLoader()
: m_themeKey(1), m_supportsSvg(false)
{
Q_ASSERT(qApp);
@ -56,8 +56,7 @@ QIconLoader::QIconLoader() :
if (m_systemTheme.isEmpty())
m_systemTheme = fallbackTheme;
#ifndef QT_NO_LIBRARY
if (iconloader()->keys().contains(QLatin1String("svg")))
m_supportsSvg = true;
m_supportsSvg = QImageReader::supportedImageFormats().contains("svg");
#endif //QT_NO_LIBRARY
}
@ -188,7 +187,7 @@ QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName,
const QString pngPath = subDir + iconName + QLatin1String(".png");
const QStatInfo pnginfo(pngPath);
if (pnginfo.isFile()) {
PixmapEntry *iconEntry = new PixmapEntry;
QIconLoaderEngineEntry *iconEntry = new QIconLoaderEngineEntry();
iconEntry->dir = dirInfo;
iconEntry->filename = pngPath;
// Notice we ensure that pixmap entries always come before
@ -198,7 +197,7 @@ QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName,
const QString svgPath = subDir + iconName + QLatin1String(".svg");
const QStatInfo svginfo(svgPath);
if (svginfo.isFile()) {
ScalableEntry *iconEntry = new ScalableEntry;
QIconLoaderEngineEntry *iconEntry = new QIconLoaderEngineEntry();
iconEntry->dir = dirInfo;
iconEntry->filename = svgPath;
entries.append(iconEntry);
@ -407,17 +406,21 @@ QString QIconLoaderEngine::iconName() const
return m_iconName;
}
QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
QPixmap QIconLoaderEngineEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
{
Q_UNUSED(state);
// Ensure that basePixmap is lazily initialized before generating the
// key, otherwise the cache key is not unique
if (basePixmap.isNull())
basePixmap.load(filename);
if (basePixmap.isNull()) {
QImageReader baseReader(filename);
QSize baseSize(size);
baseSize.scale(size, Qt::KeepAspectRatio);
baseReader.setScaledSize(baseSize);
basePixmap = QPixmap::fromImage(baseReader.read());
}
int actualSize = qMin(size.width(), size.height());
QString key = QLatin1String("$qt_theme_")
+ HexString<qint64>(basePixmap.cacheKey())
+ HexString<int>(mode)
@ -436,15 +439,6 @@ QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State st
return cachedPixmap;
}
QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
{
if (svgIcon.isNull())
svgIcon = QIcon(filename);
// Simply reuse svg icon engine
return svgIcon.pixmap(size, mode, state);
}
QPixmap QIconLoaderEngine::pixmap(const QSize &size, QIcon::Mode mode,
QIcon::State state)
{
@ -463,7 +457,3 @@ QString QIconLoaderEngine::key() const
QT_END_NAMESPACE
#endif //QT_NO_ICON

View file

@ -65,26 +65,13 @@ struct QIconDirInfo
class QIconLoaderEngineEntry
{
public:
virtual ~QIconLoaderEngineEntry() {}
virtual QPixmap pixmap(const QSize &size,
QIcon::Mode mode,
QIcon::State state) = 0;
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
QPixmap basePixmap;
QString filename;
QIconDirInfo dir;
};
struct ScalableEntry : public QIconLoaderEngineEntry
{
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
QIcon svgIcon;
};
struct PixmapEntry : public QIconLoaderEngineEntry
{
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
QPixmap basePixmap;
};
typedef QList<QIconLoaderEngineEntry*> QThemeIconEntries;
class QIconLoaderEngine : public QIconEngine

View file

@ -81,7 +81,6 @@ inline static QImage replaceColors(const QImage &source, const QMap<QRgb, QRgb>
Q_GLOBAL_STATIC(QWidget, globalStyleInfoWidget)
#if !defined(QT_NO_LIBRARY)
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, iconloader, (QString::fromLatin1("/iconengines")))
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, imageloader, (QString::fromLatin1("/imageformats")))
#endif

View file

@ -13,11 +13,6 @@ include_directories(
# place the plugins in a sub-directory the leading of which can be used as plugin path,
# this makes testing without installation possible and is relied upon in the exec script
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/iconengines")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/iconengines")
add_subdirectory(iconengines/svgiconengine)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/imageformats")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/imageformats")
add_subdirectory(imageformats/svg)

View file

@ -1,25 +0,0 @@
set(QSVGICONPLUGIN_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/qsvgiconengine.h
)
set(QSVGICONPLUGIN_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/svgiconplugin.cpp
${CMAKE_CURRENT_SOURCE_DIR}/qsvgiconengine.cpp
)
katie_setup_target(qsvgiconplugin ${QSVGICONPLUGIN_SOURCES} ${QSVGICONPLUGIN_HEADERS})
add_library(qsvgiconplugin MODULE ${qsvgiconplugin_SOURCES})
target_link_libraries(qsvgiconplugin KtCore KtGui KtSvg)
set_target_properties(qsvgiconplugin PROPERTIES
OUTPUT_NAME svg
PREFIX ""
)
katie_setup_plugin(qsvgiconplugin)
install(
TARGETS qsvgiconplugin
DESTINATION ${KATIE_PLUGINS_PATH}/iconengines
COMPONENT Runtime
)

View file

@ -1,262 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the plugins of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qsvgiconengine.h"
#include "qpainter.h"
#include "qpixmap.h"
#include "qsvgrenderer.h"
#include "qpixmapcache.h"
#include "qstyle.h"
#include "qapplication.h"
#include "qstyleoption.h"
#include "qfileinfo.h"
#include <QtCore/qatomic.h>
#include "qdebug.h"
QT_BEGIN_NAMESPACE
class QSvgIconEnginePrivate : public QSharedData
{
public:
QSvgIconEnginePrivate()
: svgBuffers(0), addedPixmaps(0)
{ stepSerialNum(); }
~QSvgIconEnginePrivate()
{ delete addedPixmaps; delete svgBuffers; }
inline static int hashKey(QIcon::Mode mode, QIcon::State state)
{ return (((mode)<<4)|state); }
inline QString pmcKey(const QSize &size, QIcon::Mode mode, QIcon::State state) const
{ return QLatin1String("$qt_svgicon_")
+ QString::number(serialNum, 16).append(QLatin1Char('_'))
+ QString::number((((((size.width()<<11)|size.height())<<11)|mode)<<4)|state, 16); }
inline void stepSerialNum()
{ serialNum = lastSerialNum.fetchAndAddRelaxed(1); }
void loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state);
QHash<int, QString> svgFiles;
QHash<int, QByteArray> *svgBuffers;
QHash<int, QPixmap> *addedPixmaps;
int serialNum;
static QAtomicInt lastSerialNum;
};
QAtomicInt QSvgIconEnginePrivate::lastSerialNum;
QSvgIconEngine::QSvgIconEngine()
: d(new QSvgIconEnginePrivate)
{
}
QSvgIconEngine::QSvgIconEngine(const QSvgIconEngine &other)
: QIconEngine(other), d(new QSvgIconEnginePrivate)
{
d->svgFiles = other.d->svgFiles;
if (other.d->svgBuffers)
d->svgBuffers = new QHash<int, QByteArray>(*other.d->svgBuffers);
if (other.d->addedPixmaps)
d->addedPixmaps = new QHash<int, QPixmap>(*other.d->addedPixmaps);
}
QSvgIconEngine::~QSvgIconEngine()
{
}
QSize QSvgIconEngine::actualSize(const QSize &size, QIcon::Mode mode,
QIcon::State state)
{
if (d->addedPixmaps) {
QPixmap pm = d->addedPixmaps->value(d->hashKey(mode, state));
if (!pm.isNull() && pm.size() == size)
return size;
}
QPixmap pm = pixmap(size, mode, state);
if (pm.isNull())
return QSize();
return pm.size();
}
void QSvgIconEnginePrivate::loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state)
{
QByteArray buf;
if (svgBuffers) {
buf = svgBuffers->value(hashKey(mode, state));
if (buf.isEmpty())
buf = svgBuffers->value(hashKey(QIcon::Normal, QIcon::Off));
}
if (!buf.isEmpty()) {
buf = qUncompress(buf);
renderer->load(buf);
} else {
QString svgFile = svgFiles.value(hashKey(mode, state));
if (svgFile.isEmpty())
svgFile = svgFiles.value(hashKey(QIcon::Normal, QIcon::Off));
if (!svgFile.isEmpty())
renderer->load(svgFile);
}
}
QPixmap QSvgIconEngine::pixmap(const QSize &size, QIcon::Mode mode,
QIcon::State state)
{
QPixmap pm;
QString pmckey(d->pmcKey(size, mode, state));
if (QPixmapCache::find(pmckey, pm))
return pm;
if (d->addedPixmaps) {
pm = d->addedPixmaps->value(d->hashKey(mode, state));
if (!pm.isNull() && pm.size() == size)
return pm;
}
QSvgRenderer renderer;
d->loadDataForModeAndState(&renderer, mode, state);
if (!renderer.isValid())
return pm;
QSize actualSize = renderer.defaultSize();
if (!actualSize.isNull())
actualSize.scale(size, Qt::KeepAspectRatio);
if (actualSize.isEmpty())
return QPixmap();
QImage img(actualSize, QImage::Format_ARGB32_Premultiplied);
img.fill(0x00000000);
QPainter p(&img);
renderer.render(&p);
p.end();
pm = QPixmap::fromImage(img);
QStyleOption opt(0);
opt.palette = QApplication::palette();
QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt);
if (!generated.isNull())
pm = generated;
if (!pm.isNull())
QPixmapCache::insert(pmckey, pm);
return pm;
}
void QSvgIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode,
QIcon::State state)
{
if (!d->addedPixmaps)
d->addedPixmaps = new QHash<int, QPixmap>;
d->stepSerialNum();
d->addedPixmaps->insert(d->hashKey(mode, state), pixmap);
}
void QSvgIconEngine::addFile(const QString &fileName, const QSize &,
QIcon::Mode mode, QIcon::State state)
{
if (!fileName.isEmpty()) {
QString abs = QFileInfo(fileName).absoluteFilePath();
if (abs.endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)
|| abs.endsWith(QLatin1String(".svgz"), Qt::CaseInsensitive)
|| abs.endsWith(QLatin1String(".svg.gz"), Qt::CaseInsensitive))
{
QSvgRenderer renderer(abs);
if (renderer.isValid()) {
d->stepSerialNum();
d->svgFiles.insert(d->hashKey(mode, state), abs);
}
} else {
QPixmap pm(abs);
if (!pm.isNull())
addPixmap(pm, mode, state);
}
}
}
void QSvgIconEngine::paint(QPainter *painter, const QRect &rect,
QIcon::Mode mode, QIcon::State state)
{
painter->drawPixmap(rect, pixmap(rect.size(), mode, state));
}
QString QSvgIconEngine::key() const
{
return QLatin1String("svg");
}
QIconEngine *QSvgIconEngine::clone() const
{
return new QSvgIconEngine(*this);
}
bool QSvgIconEngine::read(QDataStream &in)
{
d = new QSvgIconEnginePrivate;
d->svgBuffers = new QHash<int, QByteArray>;
int isCompressed;
in >> isCompressed >> *d->svgBuffers;
if (!isCompressed) {
foreach(int key, d->svgBuffers->keys())
d->svgBuffers->insert(key, qCompress(d->svgBuffers->value(key)));
}
int hasAddedPixmaps;
in >> hasAddedPixmaps;
if (hasAddedPixmaps) {
d->addedPixmaps = new QHash<int, QPixmap>;
in >> *d->addedPixmaps;
}
return true;
}
bool QSvgIconEngine::write(QDataStream &out) const
{
QHash<int, QByteArray> svgBuffers;
if (d->svgBuffers)
svgBuffers = *d->svgBuffers;
foreach(int key, d->svgFiles.keys()) {
QByteArray buf;
QFile f(d->svgFiles.value(key));
if (f.open(QIODevice::ReadOnly))
buf = f.readAll();
buf = qCompress(buf);
svgBuffers.insert(key, buf);
}
out << 1 << svgBuffers;
if (d->addedPixmaps)
out << (int)1 << *d->addedPixmaps;
else
out << (int)0;
return true;
}
QT_END_NAMESPACE

View file

@ -1,61 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the plugins of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSVGICONENGINE_H
#define QSVGICONENGINE_H
#include <QtGui/qiconengine.h>
#include <QtCore/qshareddata.h>
QT_BEGIN_NAMESPACE
class QSvgIconEnginePrivate;
class QSvgIconEngine : public QIconEngine
{
public:
QSvgIconEngine();
QSvgIconEngine(const QSvgIconEngine &other);
~QSvgIconEngine();
void paint(QPainter *painter, const QRect &rect,
QIcon::Mode mode, QIcon::State state);
QSize actualSize(const QSize &size, QIcon::Mode mode,
QIcon::State state);
QPixmap pixmap(const QSize &size, QIcon::Mode mode,
QIcon::State state);
void addPixmap(const QPixmap &pixmap, QIcon::Mode mode,
QIcon::State state);
void addFile(const QString &fileName, const QSize &size,
QIcon::Mode mode, QIcon::State state);
QString key() const;
QIconEngine *clone() const;
bool read(QDataStream &in);
bool write(QDataStream &out) const;
private:
QSharedDataPointer<QSvgIconEnginePrivate> d;
};
QT_END_NAMESPACE
#endif // QSVGICONENGINE_H

View file

@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Copyright (C) 2016 Ivailo Monev
**
** This file is part of the plugins of the Katie Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qiconengineplugin.h"
#include "qstringlist.h"
#include "qsvgiconengine.h"
#include "qiodevice.h"
#include "qbytearray.h"
#include "qdebug.h"
QT_BEGIN_NAMESPACE
class QSvgIconPlugin : public QIconEnginePlugin
{
public:
QIconEngine *create(const QString &filename = QString()) final;
};
QIconEngine *QSvgIconPlugin::create(const QString &file)
{
QSvgIconEngine *engine = new QSvgIconEngine;
if (!file.isNull())
engine->addFile(file, QSize(), QIcon::Normal, QIcon::Off);
return engine;
}
Q_EXPORT_PLUGIN(QSvgIconPlugin)
QT_END_NAMESPACE

View file

@ -257,7 +257,6 @@ static const struct ClassTblData {
{ QLatin1String("QIPv6Address"), QLatin1String("QtNetwork/qhostaddress.h") },
{ QLatin1String("QIcon"), QLatin1String("QtGui/qicon.h") },
{ QLatin1String("QIconEngine"), QLatin1String("QtGui/qiconengine.h") },
{ QLatin1String("QIconEnginePlugin"), QLatin1String("QtGui/qiconengineplugin.h") },
{ QLatin1String("QIdentityProxyModel"), QLatin1String("QtGui/qidentityproxymodel.h") },
{ QLatin1String("QImage"), QLatin1String("QtGui/qimage.h") },
{ QLatin1String("QImageIOHandler"), QLatin1String("QtGui/qimageiohandler.h") },