From 4289f7c0fd4e12d1aa39cdc7b272198693e8a3cb Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Wed, 1 Nov 2023 01:37:24 +0000 Subject: [PATCH] sync: from linuxdeepin/qt5integration Synchronize source files from linuxdeepin/qt5integration. Source-pull-request: https://github.com/linuxdeepin/qt5integration/pull/203 --- .reuse/dep5 | 2 +- .syncexclude | 11 +++++++++++ imageformatplugins/dci/qdciiohandler.cpp | 15 +++++++++++++-- imageformatplugins/svg/qsvgiohandler.cpp | 22 ++++++++++++++-------- 4 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 .syncexclude diff --git a/.reuse/dep5 b/.reuse/dep5 index 05bffec..df9b681 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -36,7 +36,7 @@ Copyright: None License: CC0-1.0 # ignore git -Files: .git* +Files: .git* .syncexclude Copyright: None License: CC0-1.0 diff --git a/.syncexclude b/.syncexclude new file mode 100644 index 0000000..7b42c60 --- /dev/null +++ b/.syncexclude @@ -0,0 +1,11 @@ +# Paths that will be exclude from synchronize workflow +# Please use relative path which use project directory as root +# Notice that +# * .git +# * debian +# * archlinux +# * .obs +# * .github +# are always ignored +linglong.yaml +conanfile.py diff --git a/imageformatplugins/dci/qdciiohandler.cpp b/imageformatplugins/dci/qdciiohandler.cpp index f7c1761..548b1f3 100644 --- a/imageformatplugins/dci/qdciiohandler.cpp +++ b/imageformatplugins/dci/qdciiohandler.cpp @@ -11,6 +11,7 @@ #include "qvariant.h" #include "qbuffer.h" #include "qdebug.h" +#include #include @@ -95,7 +96,6 @@ QDciIOHandler::QDciIOHandler() } - QDciIOHandler::~QDciIOHandler() { delete d; @@ -120,6 +120,17 @@ QByteArray QDciIOHandler::name() const return "dci"; } +static inline qreal devicePixelRatio() +{ + qreal ratio = 1.0; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + if (qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) +#endif + ratio = qApp->devicePixelRatio(); + + return ratio; +} + bool QDciIOHandler::read(QImage *image) { if (d->readDone || d->load(device())) { @@ -128,7 +139,7 @@ bool QDciIOHandler::read(QImage *image) if (finalSize > 0) { DDciIconPalette palette(QColor::Invalid, d->backColor); - *image = d->icon.pixmap(1.0, finalSize, d->current, palette).toImage(); + *image = d->icon.pixmap(devicePixelRatio(), finalSize, d->current, palette).toImage(); } d->readDone = true; return true; diff --git a/imageformatplugins/svg/qsvgiohandler.cpp b/imageformatplugins/svg/qsvgiohandler.cpp index f71b946..420ecd7 100644 --- a/imageformatplugins/svg/qsvgiohandler.cpp +++ b/imageformatplugins/svg/qsvgiohandler.cpp @@ -10,6 +10,7 @@ #include "qvariant.h" #include "qbuffer.h" #include "qdebug.h" +#include #include @@ -71,20 +72,17 @@ bool QSvgIOHandlerPrivate::load(QIODevice *device) return loaded; } - QSvgIOHandler::QSvgIOHandler() : d(new QSvgIOHandlerPrivate(this)) { } - QSvgIOHandler::~QSvgIOHandler() { delete d; } - bool QSvgIOHandler::canRead() const { if (!device()) @@ -103,12 +101,21 @@ bool QSvgIOHandler::canRead() const return false; } - QByteArray QSvgIOHandler::name() const { return "svg"; } +static inline qreal devicePixelRatio() +{ + qreal ratio = 1.0; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + if (qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) +#endif + ratio = qApp->devicePixelRatio(); + + return ratio; +} bool QSvgIOHandler::read(QImage *image) { @@ -140,6 +147,8 @@ bool QSvgIOHandler::read(QImage *image) bounds = t.mapRect(bounds); } if (!finalSize.isEmpty()) { + qreal ratio = devicePixelRatio(); + finalSize *= ratio; if (bounds.isEmpty() && d->backColor.alpha() == 0) { *image = d->r.toImage(finalSize); } else { @@ -150,6 +159,7 @@ bool QSvgIOHandler::read(QImage *image) d->r.render(&p, bounds); p.end(); } + image->setDevicePixelRatio(ratio); } d->readDone = true; return true; @@ -158,7 +168,6 @@ bool QSvgIOHandler::read(QImage *image) return false; } - QVariant QSvgIOHandler::option(ImageOption option) const { switch(option) { @@ -187,7 +196,6 @@ QVariant QSvgIOHandler::option(ImageOption option) const return QVariant(); } - void QSvgIOHandler::setOption(ImageOption option, const QVariant & value) { switch(option) { @@ -208,7 +216,6 @@ void QSvgIOHandler::setOption(ImageOption option, const QVariant & value) } } - bool QSvgIOHandler::supportsOption(ImageOption option) const { switch(option) @@ -226,7 +233,6 @@ bool QSvgIOHandler::supportsOption(ImageOption option) const return false; } - bool QSvgIOHandler::canRead(QIODevice *device) { QByteArray buf = device->peek(8);