mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Show image text overlay on hover
This commit is contained in:
parent
c9d03b793b
commit
ec14e5e556
1 changed files with 11 additions and 8 deletions
|
@ -34,7 +34,7 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client, const Event &event, co
|
||||||
setMaximumSize(max_width_, max_height_);
|
setMaximumSize(max_width_, max_height_);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setCursor(Qt::PointingHandCursor);
|
setCursor(Qt::PointingHandCursor);
|
||||||
setStyleSheet("background-color: blue");
|
setAttribute(Qt::WA_Hover, true);
|
||||||
|
|
||||||
QList<QString> url_parts = url_.toString().split("mxc://");
|
QList<QString> url_parts = url_.toString().split("mxc://");
|
||||||
|
|
||||||
|
@ -163,13 +163,16 @@ void ImageItem::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
painter.fillRect(QRect(0, 0, width_, height_), scaled_image_);
|
painter.fillRect(QRect(0, 0, width_, height_), scaled_image_);
|
||||||
|
|
||||||
// Bottom text section
|
if (underMouse()) {
|
||||||
painter.fillRect(QRect(0, height_ - bottom_height_, width_, bottom_height_),
|
// Bottom text section
|
||||||
QBrush(QColor(33, 33, 33, 128)));
|
painter.fillRect(QRect(0, height_ - bottom_height_, width_, bottom_height_),
|
||||||
|
QBrush(QColor(33, 33, 33, 128)));
|
||||||
|
|
||||||
QString elidedText = metrics.elidedText(text_, Qt::ElideRight, width_ - 10);
|
QString elidedText = metrics.elidedText(text_, Qt::ElideRight, width_ - 10);
|
||||||
|
|
||||||
painter.setFont(font);
|
font.setWeight(500);
|
||||||
painter.setPen(QPen(QColor("white")));
|
painter.setFont(font);
|
||||||
painter.drawText(QPoint(5, height_ - fontHeight / 2), elidedText);
|
painter.setPen(QPen(QColor("white")));
|
||||||
|
painter.drawText(QPoint(5, height_ - fontHeight / 2), elidedText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue