From: Flavio Date: Tue, 17 Dec 2013 09:38:49 +0000 (+0100) Subject: Draw title on hover when playlist is in minimode X-Git-Tag: 2.1.5~3 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ba3bcb81b1a97a000b4c954c0bf30f5108e852cf;p=minitube Draw title on hover when playlist is in minimode --- diff --git a/src/playlistitemdelegate.cpp b/src/playlistitemdelegate.cpp index b681347..295eba8 100644 --- a/src/playlistitemdelegate.cpp +++ b/src/playlistitemdelegate.cpp @@ -224,6 +224,27 @@ void PlaylistItemDelegate::paintBody( QPainter* painter, } + } else { + + bool isHovered = option.state & QStyle::State_MouseOver; + if (!isActive && isHovered) { + painter->setFont(smallerFont); + painter->setPen(Qt::white); + QString videoTitle = video->title(); + QString v = videoTitle; + const int flags = Qt::AlignTop | Qt::TextWordWrap; + QRect textBox(PADDING, PADDING, THUMB_WIDTH - PADDING*2, THUMB_HEIGHT - PADDING*2); + textBox = painter->boundingRect(textBox, flags, v); + while (textBox.height() > THUMB_HEIGHT && v.length() > 10) { + videoTitle.truncate(videoTitle.length() - 1); + v = videoTitle; + v = v.trimmed().append("..."); + textBox = painter->boundingRect(textBox, flags, v); + } + painter->fillRect(QRect(0, 0, THUMB_WIDTH, textBox.height() + PADDING*2), QColor(0, 0, 0, 128)); + painter->drawText(textBox, flags, v); + } + } painter->restore();