From a9a985bde1568e6b34af41068f39514370d7156c Mon Sep 17 00:00:00 2001 From: pajlada Date: Sun, 25 Dec 2022 13:14:23 +0100 Subject: [PATCH] Only try to extract images if the image uploader is enabled (#4246) * Only try to extract images if the image uploader is enabled * Add changelog entry --- CHANGELOG.md | 1 + src/widgets/helper/ResizingTextEdit.cpp | 43 +++++++++++++------------ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0126c9fe4..8ab012294 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Bugfix: Fixed unnecessary saving of windows layout. (#4201) - Bugfix: Fixed Reply window missing selection clear behaviour between chat and input box. (#4218) - Bugfix: Fixed crash that could occur when changing Tab layout and utilizing multiple windows. (#4248) +- Bugfix: Fixed text sometimes not pasting properly when image uploader was disabled. (#4246) - Dev: Remove protocol from QApplication's Organization Domain (so changed from `https://www.chatterino.com` to `chatterino.com`). (#4256) - Dev: Ignore `WM_SHOWWINDOW` hide events, causing fewer attempted rescales. (#4198) - Dev: Migrated to C++ 20 (#4252, #4257) diff --git a/src/widgets/helper/ResizingTextEdit.cpp b/src/widgets/helper/ResizingTextEdit.cpp index c51458de2..5b0dcd861 100644 --- a/src/widgets/helper/ResizingTextEdit.cpp +++ b/src/widgets/helper/ResizingTextEdit.cpp @@ -286,31 +286,34 @@ bool ResizingTextEdit::canInsertFromMimeData(const QMimeData *source) const void ResizingTextEdit::insertFromMimeData(const QMimeData *source) { - if (source->hasImage()) + if (getSettings()->imageUploaderEnabled) { - this->imagePasted.invoke(source); - return; - } - - if (source->hasUrls()) - { - bool hasUploadable = false; - auto mimeDb = QMimeDatabase(); - for (const QUrl &url : source->urls()) - { - QMimeType mime = mimeDb.mimeTypeForUrl(url); - if (mime.name().startsWith("image")) - { - hasUploadable = true; - break; - } - } - - if (hasUploadable) + if (source->hasImage()) { this->imagePasted.invoke(source); return; } + + if (source->hasUrls()) + { + bool hasUploadable = false; + auto mimeDb = QMimeDatabase(); + for (const QUrl &url : source->urls()) + { + QMimeType mime = mimeDb.mimeTypeForUrl(url); + if (mime.name().startsWith("image")) + { + hasUploadable = true; + break; + } + } + + if (hasUploadable) + { + this->imagePasted.invoke(source); + return; + } + } } insertPlainText(source->text());