diff --git a/src/widgets/helper/ResizingTextEdit.cpp b/src/widgets/helper/ResizingTextEdit.cpp index b89a45f4354..cadd3872e74 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,32 @@ 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; + } + } + + if (hasUploadable) + { + this->imagePasted.invoke(source); + return; + } } + + insertPlainText(source->text()); } QCompleter *ResizingTextEdit::getCompleter() const