mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
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:
parent
99045e42da
commit
5c350de329
2 changed files with 24 additions and 0 deletions
|
@ -228,6 +228,27 @@ void ResizingTextEdit::insertCompletion(const QString &completion)
|
||||||
this->setTextCursor(tc);
|
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
|
QCompleter *ResizingTextEdit::getCompleter() const
|
||||||
{
|
{
|
||||||
return this->completer_;
|
return this->completer_;
|
||||||
|
|
|
@ -30,6 +30,9 @@ protected:
|
||||||
void focusInEvent(QFocusEvent *event) override;
|
void focusInEvent(QFocusEvent *event) override;
|
||||||
void focusOutEvent(QFocusEvent *event) override;
|
void focusOutEvent(QFocusEvent *event) override;
|
||||||
|
|
||||||
|
bool canInsertFromMimeData(const QMimeData *source) const override;
|
||||||
|
void insertFromMimeData(const QMimeData *source) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// hadSpace is set to true in case the "textUnderCursor" word was after a
|
// hadSpace is set to true in case the "textUnderCursor" word was after a
|
||||||
// space
|
// space
|
||||||
|
|
Loading…
Reference in a new issue