From cefe5fe71945c89b7b65c6ed2cb127a404cf62f5 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 22 Jul 2019 02:38:44 +0200 Subject: Fix copy and pasting image from clipboard If the QMimeData contains an image, it actually has a mime type of application/x-qt-image. At least in some cases accessing the image/* data returns a 0 length array. Accessing the data via ->imageData works however. So we use that as our accessor and pass it to the preview dialog. --- src/TextInputWidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/TextInputWidget.cpp') diff --git a/src/TextInputWidget.cpp b/src/TextInputWidget.cpp index 1ae26c2d..f723c01a 100644 --- a/src/TextInputWidget.cpp +++ b/src/TextInputWidget.cpp @@ -306,8 +306,9 @@ FilteredTextEdit::insertFromMimeData(const QMimeData *source) const auto audio = formats.filter("audio/", Qt::CaseInsensitive); const auto video = formats.filter("video/", Qt::CaseInsensitive); - if (!image.empty()) { - showPreview(source, image); + if (source->hasImage()) { + QImage img = qvariant_cast(source->imageData()); + previewDialog_.setPreview(img, image.front()); } else if (!audio.empty()) { showPreview(source, audio); } else if (!video.empty()) { -- cgit 1.5.1