If hover over ImageLayoutElement show the preview of image
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user