summary refs log tree commit diff
path: root/src/timeline/InputBar.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-03-21 23:15:09 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-03-21 23:15:09 +0100
commite52f90a9418156ad958d515e056f508c45f1bbee (patch)
treecec1060e3d2b3ab43f34fb5b04fd622e89c632ab /src/timeline/InputBar.cpp
parentFix potential crash if there is no image format pasted (diff)
downloadnheko-e52f90a9418156ad958d515e056f508c45f1bbee.tar.xz
Properly fix image uploads without image/* format
Diffstat (limited to 'src/timeline/InputBar.cpp')
-rw-r--r--src/timeline/InputBar.cpp11
1 files 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<QImage>(md->imageData()).save(&buffer, "PNG");
+            QMimeData d;
+            d.setData(QStringLiteral("image/png"), ba);
+            startUploadFromMimeData(d, image.first());
         } else {
             startUploadFromMimeData(*md, image.first());
         }