mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
If hover over ImageLayoutElement show the preview of image
This commit is contained in:
parent
d4a6defed6
commit
f002d44370
1 changed files with 24 additions and 1 deletions
|
@ -1217,9 +1217,32 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto imageLayoutElement =
|
||||
dynamic_cast<const ImageLayoutElement *>(hoverLayoutElement);
|
||||
|
||||
if (imageLayoutElement && imageLayoutElement->pixmap()) {
|
||||
QBuffer buffer;
|
||||
const int width = imageLayoutElement->pixmap()->width();
|
||||
const int height = imageLayoutElement->pixmap()->height();
|
||||
imageLayoutElement->pixmap()->save(&buffer, "PNG");
|
||||
|
||||
// FIXME: Image inside of imageLayoutElement is not always the biggest
|
||||
// FIXME: Inject image directly into tooltipWidget without base64 bs
|
||||
// FIXME: Gifs are not animated
|
||||
// FIXME: No way to opt-out
|
||||
|
||||
tooltipWidget->setText(
|
||||
QString("<img src='data:image/png;base64,%1' /><br/>%2x%3<br/>%4")
|
||||
.arg(QString(buffer.data().toBase64()))
|
||||
.arg(imageLayoutElement->pixmap()->width())
|
||||
.arg(imageLayoutElement->pixmap()->height())
|
||||
.arg(tooltip));
|
||||
} else {
|
||||
tooltipWidget->setText(tooltip);
|
||||
}
|
||||
|
||||
tooltipWidget->moveTo(this, event->globalPos());
|
||||
tooltipWidget->setWordWrap(isLinkValid);
|
||||
tooltipWidget->setText(tooltip);
|
||||
tooltipWidget->adjustSize();
|
||||
tooltipWidget->show();
|
||||
tooltipWidget->raise();
|
||||
|
|
Loading…
Reference in a new issue