From: Ivailo Monev Date: Tue, 29 Aug 2023 15:48:34 +0000 (+0300) Subject: fix DnD retrieval of some image formats X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=b3e52cdee4c2d7746c14300402a5906436565980;p=kde%2FKatie.git fix DnD retrieval of some image formats with the introduction of QImageWriter::formatForMimeType() and the related QImageReader and QImageWriter methods the assumption that the image format (plugin name) equals everything after the slash can be dismissed and properly handled Signed-off-by: Ivailo Monev --- diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index caa7c7a49..da3a4b9cb 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -336,7 +336,7 @@ bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData bool foundFormat = data->hasFormat(mimeType); if (!foundFormat) { - QStringList imageFormats = imageWriteMimeFormats(); + const QStringList imageFormats = imageWriteMimeFormats(); if (mimeType == QLatin1String("application/x-qt-image")) { // check all supported image formats foreach (const QString &it, imageFormats) { diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp index 0f6064a71..f3d76c507 100644 --- a/src/gui/kernel/qdnd_x11.cpp +++ b/src/gui/kernel/qdnd_x11.cpp @@ -1963,7 +1963,7 @@ QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type req QImage image = qvariant_cast(o->data->imageData()); QBuffer buf(&result); buf.open(QBuffer::WriteOnly); - image.save(&buf, mimetype.mid(mimetype.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper()); + image.save(&buf, QImageWriter::formatForMimeType(mimetype.toLatin1())); } return result; }