overrides QTextEdit insert methods

fixes Chatterino#635
prepares for future implementation of Chatterino#79

Was a little bit hard to find the right combination for now. Pasting images from clipboard surpasses the check for dragging images in canInsertFromMimeData OMGScoots
This commit is contained in:
TranRed 2019-06-09 17:21:31 +02:00 committed by pajlada
parent 99045e42da
commit 5c350de329
2 changed files with 24 additions and 0 deletions

View file

@ -228,6 +228,27 @@ void ResizingTextEdit::insertCompletion(const QString &completion)
this->setTextCursor(tc);
}
bool ResizingTextEdit::canInsertFromMimeData(const QMimeData *source) const
{
if (source->hasImage())
{
return false;
}
else if (source->hasFormat("text/plain"))
{
return true;
}
return false;
}
void ResizingTextEdit::insertFromMimeData(const QMimeData *source)
{
if (!source->hasImage())
{
insertPlainText(source->text());
}
}
QCompleter *ResizingTextEdit::getCompleter() const
{
return this->completer_;

View file

@ -30,6 +30,9 @@ protected:
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
bool canInsertFromMimeData(const QMimeData *source) const override;
void insertFromMimeData(const QMimeData *source) override;
private:
// hadSpace is set to true in case the "textUnderCursor" word was after a
// space