1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-22 17:01:51 +02:00

* Show album name in PlaylistLargeItemDelegate.

This commit is contained in:
Christian Muehlhaeuser 2012-12-04 05:45:55 +01:00
parent 595dcac264
commit 96b4a0a3ff

@ -113,10 +113,7 @@ PlaylistLargeItemDelegate::drawRichText( QPainter* painter, const QStyleOptionVi
QAbstractTextDocumentLayout::PaintContext context;
if ( option.state & QStyle::State_Selected )
context.palette.setColor( QPalette::Text, option.palette.color( QPalette::HighlightedText ) );
else
context.palette.setColor( QPalette::Text, painter->pen().color() );
context.palette.setColor( QPalette::Text, option.palette.text().color() );
painter->save();
painter->translate( rect.x(), y );
@ -141,8 +138,9 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
return;
const query_ptr q = item->query()->displayQuery();
QString artist = q->artist();
QString track = q->track();
const QString artist = q->artist();
const QString album = q->album();
const QString track = q->track();
unsigned int duration = q->duration();
QPixmap avatar;
QString lowerText;
@ -190,7 +188,6 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
QRect avatarRect = r.adjusted( option.rect.width() - r.left() - 12 - avatarSize.width(), ( option.rect.height() - avatarSize.height() ) / 2 - 5, 0, 0 );
avatarRect.setSize( avatarSize );
if ( !m_pixmaps.contains( index ) )
{
m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), pixmapRect.size(), TomahawkUtils::ScaledCover, false ) ) );
@ -216,7 +213,9 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
QFontMetrics smallBoldFontMetrics( smallBoldFont );
QFont smallFont = opt.font;
smallFont.setPointSize( TomahawkUtils::defaultFontSize() - 2 );
smallFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
QFont smallestFont = opt.font;
smallestFont.setPointSize( TomahawkUtils::defaultFontSize() - 2 );
r.adjust( pixmapRect.width() + 12, 1, - 16 - avatar.width(), 0 );
QRect leftRect = r.adjusted( 0, 0, -48, 0 );
@ -226,13 +225,20 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
QString text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() );
painter->drawText( leftRect, text, m_topOption );
painter->setFont( smallBoldFont );
text = painter->fontMetrics().elidedText( artist, Qt::ElideRight, leftRect.width() );
painter->drawText( leftRect.adjusted( 0, boldFontMetrics.height(), 0, 0 ), text, m_topOption );
painter->setFont( smallFont );
painter->setPen( Qt::gray );
QTextDocument textDoc;
if ( album.isEmpty() )
textDoc.setHtml( tr( "by <b>%1</b>" ).arg( artist ) );
else
textDoc.setHtml( tr( "by <b>%1</b> on <b>%2</b>" ).arg( artist ).arg( album ) );
textDoc.setDocumentMargin( 0 );
textDoc.setDefaultFont( painter->font() );
textDoc.setDefaultTextOption( m_topOption );
drawRichText( painter, opt, leftRect.adjusted( 0, boldFontMetrics.height() + 1, 0, 0 ), Qt::AlignTop, textDoc );
painter->setFont( smallestFont );
painter->setPen( Qt::gray );
textDoc.setHtml( lowerText );
textDoc.setDocumentMargin( 0 );
textDoc.setDefaultFont( painter->font() );
@ -241,7 +247,7 @@ PlaylistLargeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem&
if ( textDoc.idealWidth() > leftRect.width() )
textDoc.setHtml( item->query()->socialActionDescription( "Love", Query::Short ) );
drawRichText( painter, option, leftRect, Qt::AlignBottom, textDoc );
drawRichText( painter, opt, leftRect, Qt::AlignBottom, textDoc );
const int sourceIconSize = avatarRect.width() - 6;
if ( q->numResults() && !q->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) ).isNull() )