[vlc-commits] Qt4: in iconview, allways center the album art even if bold font has different size than normal

Ilkka Ollakka git at videolan.org
Sun Jan 23 23:51:10 CET 2011


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Mon Jan 24 00:50:53 2011 +0200| [2d3a9f2e32e94d8f215f8d2216e3b2280d4f033b] | committer: Ilkka Ollakka

Qt4: in iconview, allways center the album art even if bold font has different size than normal

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2d3a9f2e32e94d8f215f8d2216e3b2280d4f033b
---

 modules/gui/qt4/components/playlist/views.cpp |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/views.cpp b/modules/gui/qt4/components/playlist/views.cpp
index 9415b4a..bb7d5ad 100644
--- a/modules/gui/qt4/components/playlist/views.cpp
+++ b/modules/gui/qt4/components/playlist/views.cpp
@@ -82,6 +82,7 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
     QFontMetrics fm = painter->fontMetrics();
 
     int averagewidth = fm.averageCharWidth();
+    QSize rectSize = option.rect.size();
     int art_width = averagewidth * ICON_SCALER;
     int art_height = averagewidth * ICON_SCALER;
 
@@ -91,8 +92,8 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
 
     painter->save();
 
-    QRect artRect( option.rect.x() + averagewidth*2 + ( art_width - artPix.width() ) / 2,
-                   option.rect.y() + averagewidth + ( art_height - artPix.height() ) / 2,
+    QRect artRect( option.rect.x() + ( rectSize.width() - artPix.width() ) / 2,
+                   option.rect.y() - averagewidth*3 + ( rectSize.height() - artPix.height() ) / 2,
                    artPix.width(), artPix.height() );
 
     // Draw the drop shadow
@@ -137,9 +138,8 @@ void PlIconViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
     // Draw title
     font.setItalic( true );
 
-    fm = painter->fontMetrics();
-    QRect textRect = option.rect.adjusted( 1, art_height + 10, 0, -1 );
-    textRect.setHeight( fm.height() );
+    QRect textRect;
+    textRect.setRect( option.rect.x() , artRect.bottom() + fm.height()/2, option.rect.width(), fm.height() );
 
     painter->drawText( textRect,
                       fm.elidedText( title, Qt::ElideRight, textRect.width() ),



More information about the vlc-commits mailing list