diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-04-30 01:10:01 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-04-30 01:10:01 +0300 |
commit | ec14e5e55661ce24c75dfb58703cab52f744b0ae (patch) | |
tree | a86c926e0b8812347c39cec642cf60e19d87f898 /src/ImageItem.cc | |
parent | Add initial support for inline images (diff) | |
download | nheko-ec14e5e55661ce24c75dfb58703cab52f744b0ae.tar.xz |
Show image text overlay on hover
Diffstat (limited to '')
-rw-r--r-- | src/ImageItem.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/ImageItem.cc b/src/ImageItem.cc index 8298926d..0a2b62f2 100644 --- a/src/ImageItem.cc +++ b/src/ImageItem.cc @@ -34,7 +34,7 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client, const Event &event, co setMaximumSize(max_width_, max_height_); setMouseTracking(true); setCursor(Qt::PointingHandCursor); - setStyleSheet("background-color: blue"); + setAttribute(Qt::WA_Hover, true); 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_); - // Bottom text section - painter.fillRect(QRect(0, height_ - bottom_height_, width_, bottom_height_), - QBrush(QColor(33, 33, 33, 128))); + if (underMouse()) { + // Bottom text section + 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); - painter.setPen(QPen(QColor("white"))); - painter.drawText(QPoint(5, height_ - fontHeight / 2), elidedText); + font.setWeight(500); + painter.setFont(font); + painter.setPen(QPen(QColor("white"))); + painter.drawText(QPoint(5, height_ - fontHeight / 2), elidedText); + } } |