From 6f065530aeb55c977e2b9bfe048e893bd2389901 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Wed, 10 May 2017 13:12:50 +0300 Subject: [PATCH] Restrict inline image size to its minimum --- src/ImageItem.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ImageItem.cc b/src/ImageItem.cc index 514c28aa..667d84cf 100644 --- a/src/ImageItem.cc +++ b/src/ImageItem.cc @@ -33,7 +33,6 @@ ImageItem::ImageItem(QSharedPointer client, const events::MessageE , event_{event} , client_{client} { - setMaximumSize(max_width_, max_height_); setMouseTracking(true); setCursor(Qt::PointingHandCursor); setAttribute(Qt::WA_Hover, true); @@ -94,7 +93,7 @@ void ImageItem::scaleImage() height_ = image_.height() * min_aspect_ratio; } - setMinimumSize(width_, height_); + setFixedSize(width_, height_); scaled_image_ = image_.scaled(width_, height_, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } @@ -157,10 +156,10 @@ void ImageItem::paintEvent(QPaintEvent *event) if (image_.isNull()) { int height = fontHeight + 10; - setMinimumSize(max_width_, fontHeight + 10); - QString elidedText = metrics.elidedText(text_, Qt::ElideRight, max_width_ - 10); + setFixedSize(metrics.width(elidedText), fontHeight + 10); + painter.setFont(font); painter.setPen(QPen(QColor(66, 133, 244))); painter.drawText(QPoint(0, height / 2 + 2), elidedText);