Dropping images now works on the whole split :)

This commit is contained in:
Mm2PL 2020-02-08 16:41:01 +01:00
parent d53bfbfdf2
commit a929053c4b
No known key found for this signature in database
GPG key ID: 1C400DA5602DE62E
4 changed files with 27 additions and 27 deletions

View file

@ -25,7 +25,6 @@ ResizingTextEdit::ResizingTextEdit()
[this] { this->completionInProgress_ = false; });
this->setFocusPolicy(Qt::ClickFocus);
setAcceptDrops(true);
}
QSize ResizingTextEdit::sizeHint() const
@ -280,29 +279,6 @@ void ResizingTextEdit::insertFromMimeData(const QMimeData *source)
}
}
void ResizingTextEdit::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasImage() || event->mimeData()->hasUrls())
{
event->acceptProposedAction();
}
else
{
QTextEdit::dragEnterEvent(event);
}
}
void ResizingTextEdit::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasImage() || event->mimeData()->hasUrls())
{
this->imagePasted.invoke(event->mimeData());
}
else
{
QTextEdit::dropEvent(event);
}
}
QCompleter *ResizingTextEdit::getCompleter() const
{
return this->completer_;

View file

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

View file

@ -211,6 +211,7 @@ Split::Split(QWidget *parent)
[this](const QMimeData *source) {
upload(source, this->getChannel(), *this->input_->ui_.textEdit);
});
setAcceptDrops(true);
}
Split::~Split()
@ -689,6 +690,29 @@ void Split::reloadChannelAndSubscriberEmotes()
}
}
void Split::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasImage() || event->mimeData()->hasUrls())
{
event->acceptProposedAction();
}
else
{
BaseWidget::dragEnterEvent(event);
}
}
void Split::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasImage() || event->mimeData()->hasUrls())
{
this->input_->ui_.textEdit->imagePasted.invoke(event->mimeData());
}
else
{
BaseWidget::dropEvent(event);
}
}
template <typename Iter, typename RandomGenerator>
static Iter select_randomly(Iter start, Iter end, RandomGenerator &g)
{

View file

@ -86,6 +86,9 @@ protected:
void leaveEvent(QEvent *event) override;
void focusInEvent(QFocusEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
private:
void channelNameUpdated(const QString &newChannelName);
void handleModifiers(Qt::KeyboardModifiers modifiers);