diff --git a/CHANGELOG.md b/CHANGELOG.md index aaaf842b..f28d192e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Minor: Added a link to accounts page in settings to "You need to be logged in to send messages" message. (#2862) - Minor: Switch to Twitch v2 emote API for animated emote support. (#2863) - Bugfix: Fixed FFZ emote links for global emotes (#2807, #2808) +- Bugfix: Fixed pasting text with URLs included (#1688, #2855) - Bugfix: Fix reconnecting when IRC write connection is lost (#1831, #2356, #2850) - Bugfix: Fixed bit emotes not loading in some rare cases. (#2856) diff --git a/src/widgets/helper/ResizingTextEdit.cpp b/src/widgets/helper/ResizingTextEdit.cpp index b89a45f4..56c60a72 100644 --- a/src/widgets/helper/ResizingTextEdit.cpp +++ b/src/widgets/helper/ResizingTextEdit.cpp @@ -5,6 +5,7 @@ #include "singletons/Settings.hpp" #include +#include namespace chatterino { @@ -264,14 +265,33 @@ bool ResizingTextEdit::canInsertFromMimeData(const QMimeData *source) const void ResizingTextEdit::insertFromMimeData(const QMimeData *source) { - if (source->hasImage() || source->hasUrls()) + if (source->hasImage()) { this->imagePasted.invoke(source); + return; } - else + else if (source->hasUrls()) { - insertPlainText(source->text()); + 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()); } QCompleter *ResizingTextEdit::getCompleter() const