From bf7822fe956f24303563b040156f6c4abaf75df6 Mon Sep 17 00:00:00 2001 From: Ludovic Fauvet Date: Tue, 26 Jan 2010 14:26:46 +0100 Subject: [PATCH 1/1] Qt: more details on the icon view. Add album name and break long lines. Signed-off-by: Jean-Baptiste Kempf --- .../gui/qt4/components/playlist/icon_view.cpp | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/gui/qt4/components/playlist/icon_view.cpp b/modules/gui/qt4/components/playlist/icon_view.cpp index da4bf85094..f07b25f60a 100644 --- a/modules/gui/qt4/components/playlist/icon_view.cpp +++ b/modules/gui/qt4/components/playlist/icon_view.cpp @@ -25,16 +25,17 @@ #include "components/playlist/playlist_model.hpp" #include "input_manager.hpp" +#include #include #include #include -#include +#include #include "assert.h" #define RECT_SIZE 100 #define ART_SIZE 64 -#define OFFSET (100-64)/2 +#define OFFSET (RECT_SIZE-64)/2 #define ITEMS_SPACING 10 #define ART_RADIUS 5 @@ -77,12 +78,26 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt painter->drawPixmap( artRect, pix ); painter->setClipping( false ); - painter->setFont( QFont( "Verdana", 7 ) ); + QColor text = qApp->palette().text().color(); + QString title = qfu( input_item_GetTitleFbName( currentItem->inputItem() ) ); + QString artist = qfu( input_item_GetArtist( currentItem->inputItem() ) ); + + painter->setPen( text ); + painter->setFont( QFont( "Verdana", 7, QFont::Bold ) ); + QFontMetrics fm = painter->fontMetrics(); + QRect titleRect = option.rect.adjusted( 1, ART_SIZE + 4, 0, -1 ); + titleRect.setHeight( fm.height() + 2 ); - QRect textRect = option.rect.adjusted( 1, ART_SIZE + 2, -1, -1 ); - painter->drawText( textRect, qfu( input_item_GetTitleFbName( currentItem->inputItem() ) ), + painter->drawText( titleRect, fm.elidedText( title, Qt::ElideRight, titleRect.width() ), QTextOption( Qt::AlignCenter ) ); + painter->setPen( text.lighter( 240 ) ); + painter->setFont( QFont( "Verdana", 7 ) ); + fm = painter->fontMetrics(); + QRect artistRect = option.rect.adjusted( 1, ART_SIZE + 4 + titleRect.height(), -1, -1 ); + + painter->drawText( artistRect, fm.elidedText( artist, Qt::ElideRight, artistRect.width() ), + QTextOption( Qt::AlignCenter ) ); } QSize PlListViewItemDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const -- 2.39.2