Skip to content

Commit

Permalink
Attempt to fix Chatterino#1688
Browse files Browse the repository at this point in the history
  • Loading branch information
Mm2PL committed Jun 3, 2021
1 parent 508fea6 commit 0aa053a
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/widgets/helper/ResizingTextEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "singletons/Settings.hpp"

#include <QMimeData>
#include <QMimeDatabase>

namespace chatterino {

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0aa053a

Please sign in to comment.