diff options
author | Liang Qi <liang.qi@qt.io> | 2016-11-26 12:56:04 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-11-26 12:56:04 +0100 |
commit | 51ef7e2e9877fbcc8ac0f7dc4d2f17b767b7e765 (patch) | |
tree | 5d93a54aa4245915d6fdc1dc3c8765d0dd2e8b6b /src/plugins | |
parent | cb2aafdaa09e992982eb3aac318cfde38e65b2ac (diff) | |
parent | 410b6b529cc6ee9236ee29fcdff4a03ad8670fe9 (diff) | |
download | qtsvg-51ef7e2e9877fbcc8ac0f7dc4d2f17b767b7e765.tar.gz |
Merge remote-tracking branch 'origin/5.7' into 5.8
Change-Id: I43247261a4dc8badc4ad4f4d2137cdbd499f29db
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/iconengines/svgiconengine/main.cpp | 16 | ||||
-rw-r--r-- | src/plugins/iconengines/svgiconengine/qsvgiconengine-nocompress.json | 3 | ||||
-rw-r--r-- | src/plugins/iconengines/svgiconengine/qsvgiconengine.h | 18 | ||||
-rw-r--r-- | src/plugins/iconengines/svgiconengine/svgiconengine.pro | 1 | ||||
-rw-r--r-- | src/plugins/imageformats/svg/main.cpp | 18 | ||||
-rw-r--r-- | src/plugins/imageformats/svg/qsvgiohandler.cpp | 13 | ||||
-rw-r--r-- | src/plugins/imageformats/svg/qsvgiohandler.h | 12 | ||||
-rw-r--r-- | src/plugins/imageformats/svg/svg-nocompress.json | 4 | ||||
-rw-r--r-- | src/plugins/imageformats/svg/svg.json | 2 |
9 files changed, 50 insertions, 37 deletions
diff --git a/src/plugins/iconengines/svgiconengine/main.cpp b/src/plugins/iconengines/svgiconengine/main.cpp index ebcdc82..cedeb7a 100644 --- a/src/plugins/iconengines/svgiconengine/main.cpp +++ b/src/plugins/iconengines/svgiconengine/main.cpp @@ -51,22 +51,16 @@ QT_BEGIN_NAMESPACE class QSvgIconPlugin : public QIconEnginePlugin { Q_OBJECT +#ifndef QT_NO_COMPRESS Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QIconEngineFactoryInterface" FILE "qsvgiconengine.json") +#else + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QIconEngineFactoryInterface" FILE "qsvgiconengine-nocompress.json") +#endif public: - QStringList keys() const; - QIconEngine *create(const QString &filename = QString()); + QIconEngine *create(const QString &filename = QString()) override; }; -QStringList QSvgIconPlugin::keys() const -{ - QStringList keys(QLatin1String("svg")); -#ifndef QT_NO_COMPRESS - keys << QLatin1String("svgz") << QLatin1String("svg.gz"); -#endif - return keys; -} - QIconEngine *QSvgIconPlugin::create(const QString &file) { QSvgIconEngine *engine = new QSvgIconEngine; diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine-nocompress.json b/src/plugins/iconengines/svgiconengine/qsvgiconengine-nocompress.json new file mode 100644 index 0000000..a3e1ac3 --- /dev/null +++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine-nocompress.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "svg" ] +} diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.h b/src/plugins/iconengines/svgiconengine/qsvgiconengine.h index 495a8b0..cf4f255 100644 --- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.h +++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.h @@ -54,21 +54,21 @@ public: QSvgIconEngine(const QSvgIconEngine &other); ~QSvgIconEngine(); void paint(QPainter *painter, const QRect &rect, - QIcon::Mode mode, QIcon::State state); + QIcon::Mode mode, QIcon::State state) override; QSize actualSize(const QSize &size, QIcon::Mode mode, - QIcon::State state); + QIcon::State state) override; QPixmap pixmap(const QSize &size, QIcon::Mode mode, - QIcon::State state); + QIcon::State state) override; void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, - QIcon::State state); + QIcon::State state) override; void addFile(const QString &fileName, const QSize &size, - QIcon::Mode mode, QIcon::State state); + QIcon::Mode mode, QIcon::State state) override; - QString key() const; - QIconEngine *clone() const; - bool read(QDataStream &in); - bool write(QDataStream &out) const; + QString key() const override; + QIconEngine *clone() const override; + bool read(QDataStream &in) override; + bool write(QDataStream &out) const override; private: QSharedDataPointer<QSvgIconEnginePrivate> d; diff --git a/src/plugins/iconengines/svgiconengine/svgiconengine.pro b/src/plugins/iconengines/svgiconengine/svgiconengine.pro index eb6847b..bfc739f 100644 --- a/src/plugins/iconengines/svgiconengine/svgiconengine.pro +++ b/src/plugins/iconengines/svgiconengine/svgiconengine.pro @@ -4,6 +4,7 @@ HEADERS += qsvgiconengine.h SOURCES += main.cpp \ qsvgiconengine.cpp OTHER_FILES += qsvgiconengine.json +OTHER_FILES += qsvgiconengine-nocompress.json QT += svg core-private gui-private PLUGIN_TYPE = iconengines diff --git a/src/plugins/imageformats/svg/main.cpp b/src/plugins/imageformats/svg/main.cpp index f18c1b4..f9fcfc3 100644 --- a/src/plugins/imageformats/svg/main.cpp +++ b/src/plugins/imageformats/svg/main.cpp @@ -53,22 +53,24 @@ QT_BEGIN_NAMESPACE class QSvgPlugin : public QImageIOPlugin { Q_OBJECT +#ifndef QT_NO_COMPRESS Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "svg.json") +#else + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "svg-nocompress.json") +#endif public: - QStringList keys() const; - Capabilities capabilities(QIODevice *device, const QByteArray &format) const; - QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const; + Capabilities capabilities(QIODevice *device, const QByteArray &format) const override; + QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override; }; -QStringList QSvgPlugin::keys() const -{ - return QStringList() << QLatin1String("svg") << QLatin1String("svgz"); -} - QImageIOPlugin::Capabilities QSvgPlugin::capabilities(QIODevice *device, const QByteArray &format) const { +#ifndef QT_NO_COMPRESS if (format == "svg" || format == "svgz") +#else + if (format == "svg") +#endif return Capabilities(CanRead); if (!format.isEmpty()) return 0; diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp index bb68fd9..88d37bc 100644 --- a/src/plugins/imageformats/svg/qsvgiohandler.cpp +++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp @@ -88,8 +88,10 @@ bool QSvgIOHandlerPrivate::load(QIODevice *device) const QByteArray &ba = buf->data(); res = r.load(QByteArray::fromRawData(ba.constData() + buf->pos(), ba.size() - buf->pos())); buf->seek(ba.size()); +#ifndef QT_NO_COMPRESS } else if (q->format() == "svgz") { res = r.load(device->readAll()); +#endif } else { xmlReader.setDevice(device); res = r.load(&xmlReader); @@ -125,10 +127,13 @@ bool QSvgIOHandler::canRead() const return true; // Will happen if we have been asked for the size QByteArray buf = device()->peek(8); +#ifndef QT_NO_COMPRESS if (buf.startsWith("\x1f\x8b")) { setFormat("svgz"); return true; - } else if (buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--")) { + } else +#endif + if (buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--")) { setFormat("svg"); return true; } @@ -257,7 +262,11 @@ bool QSvgIOHandler::supportsOption(ImageOption option) const bool QSvgIOHandler::canRead(QIODevice *device) { QByteArray buf = device->peek(8); - return buf.startsWith("\x1f\x8b") || buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--"); + return +#ifndef QT_NO_COMPRESS + buf.startsWith("\x1f\x8b") || +#endif + buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--"); } QT_END_NAMESPACE diff --git a/src/plugins/imageformats/svg/qsvgiohandler.h b/src/plugins/imageformats/svg/qsvgiohandler.h index 864031f..fdafa0a 100644 --- a/src/plugins/imageformats/svg/qsvgiohandler.h +++ b/src/plugins/imageformats/svg/qsvgiohandler.h @@ -57,13 +57,13 @@ class QSvgIOHandler : public QImageIOHandler public: QSvgIOHandler(); ~QSvgIOHandler(); - virtual bool canRead() const; - virtual QByteArray name() const; - virtual bool read(QImage *image); + bool canRead() const override; + QByteArray name() const override; + bool read(QImage *image) override; static bool canRead(QIODevice *device); - virtual QVariant option(ImageOption option) const; - virtual void setOption(ImageOption option, const QVariant & value); - virtual bool supportsOption(ImageOption option) const; + QVariant option(ImageOption option) const override; + void setOption(ImageOption option, const QVariant & value) override; + bool supportsOption(ImageOption option) const override; private: QSvgIOHandlerPrivate *d; diff --git a/src/plugins/imageformats/svg/svg-nocompress.json b/src/plugins/imageformats/svg/svg-nocompress.json new file mode 100644 index 0000000..3b5a653 --- /dev/null +++ b/src/plugins/imageformats/svg/svg-nocompress.json @@ -0,0 +1,4 @@ +{ + "Keys": [ "svg" ], + "MimeTypes": [ "image/svg+xml" ] +} diff --git a/src/plugins/imageformats/svg/svg.json b/src/plugins/imageformats/svg/svg.json index c8825d4..970914d 100644 --- a/src/plugins/imageformats/svg/svg.json +++ b/src/plugins/imageformats/svg/svg.json @@ -1,4 +1,4 @@ { "Keys": [ "svg", "svgz" ], - "MimeTypes": [ "image/svg+xml" ] + "MimeTypes": [ "image/svg+xml", "image/svg+xml-compressed" ] } |