]> git.sur5r.net Git - minitube/commitdiff
Draw title on hover when playlist is in minimode
authorFlavio <flavio@odisseo.local>
Tue, 17 Dec 2013 09:38:49 +0000 (10:38 +0100)
committerFlavio <flavio@odisseo.local>
Tue, 17 Dec 2013 09:38:49 +0000 (10:38 +0100)
src/playlistitemdelegate.cpp

index b68134743031d38aa27a40bc9f1e7df79912999f..295eba8e403ea5c98498e3f6e055137528a70cd7 100644 (file)
@@ -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();