From e52f90a9418156ad958d515e056f508c45f1bbee Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 21 Mar 2022 23:15:09 +0100 Subject: [PATCH] Properly fix image uploads without image/* format --- src/timeline/InputBar.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index bf8f926a..2d29dbbd 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -155,9 +155,16 @@ InputBar::insertMimeData(const QMimeData *md) if (md->hasImage()) { if (formats.contains(QStringLiteral("image/svg+xml"), Qt::CaseInsensitive)) { startUploadFromMimeData(*md, QStringLiteral("image/svg+xml")); - } else if (formats.contains(QStringLiteral("image/png"), Qt::CaseInsensitive) || - formats.empty()) { + } else if (formats.contains(QStringLiteral("image/png"), Qt::CaseInsensitive)) { startUploadFromMimeData(*md, QStringLiteral("image/png")); + } else if (image.empty()) { + QByteArray ba; + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + qvariant_cast(md->imageData()).save(&buffer, "PNG"); + QMimeData d; + d.setData(QStringLiteral("image/png"), ba); + startUploadFromMimeData(d, image.first()); } else { startUploadFromMimeData(*md, image.first()); }