1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 15:47:38 +02:00

* Fixed playlist column-alignment.

This commit is contained in:
Christian Muehlhaeuser
2014-08-17 04:10:12 +02:00
parent 905be88d57
commit f44a85ff3c

View File

@@ -575,18 +575,24 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem&
painter->setPen( QColor( "#000000" ) ); painter->setPen( QColor( "#000000" ) );
QRect r = rect.adjusted( 32, 6, -32, -6 ); QRect r = rect.adjusted( 32, 6, -32, -6 );
int margin = 8; const int margin = 8;
QRect numberRect = QRect( r.x(), r.y(), (double)r.width() * 0.1, r.height() );
QRect titleRect = QRect( numberRect.x() + numberRect.width(), r.y(), (double)r.width() * 0.4, r.height() );
QRect artistRect = QRect( titleRect.x() + titleRect.width(), r.y(), (double)r.width() * 0.4, r.height() );
QRect extraRect = QRect( artistRect.x() + artistRect.width(), r.y(), (double)r.width() * 0.1, r.height() );
QFont f = painter->font(); QFont f = painter->font();
f.setPointSize( 11 ); f.setPointSize( 11 );
f.setWeight( QFont::DemiBold ); f.setWeight( QFont::DemiBold );
painter->setFont( f ); painter->setFont( f );
QFontMetrics fm( painter->font() );
const int numberWidth = fm.width( "00" ) + 32;
const int durationWidth = fm.width( "00:00" ) + 32;
const int remWidth = r.width() - numberWidth - durationWidth;
QRect numberRect = QRect( r.x(), r.y(), numberWidth, r.height() );
QRect titleRect = QRect( numberRect.x() + numberRect.width(), r.y(), (double)remWidth * 0.5, r.height() );
QRect artistRect = QRect( titleRect.x() + titleRect.width(), r.y(), (double)remWidth * 0.5, r.height() );
QRect extraRect = QRect( artistRect.x() + artistRect.width(), r.y(), durationWidth, r.height() );
// draw title // draw title
painter->setOpacity( 1 ); painter->setOpacity( 1 );
QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, titleRect.width() - margin ); QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, titleRect.width() - margin );
@@ -609,7 +615,8 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem&
if ( item->isPlaying() ) if ( item->isPlaying() )
{ {
int h = extraRect.height() / 2; int h = extraRect.height() / 2;
painter->drawPixmap( extraRect.adjusted( extraRect.width() - h - 4, h / 2, -4, -h / 2 ), ImageRegistry::instance()->pixmap( RESPATH "images/play.svg", QSize( extraRect.height() / 2, extraRect.height() / 2 ) ) ); QRect playIconRect = extraRect.adjusted( extraRect.width() - h - 8, h / 2, -8, -h / 2 );
painter->drawPixmap( playIconRect, ImageRegistry::instance()->pixmap( RESPATH "images/play.svg", playIconRect.size() ) );
painter->save(); painter->save();
painter->setPen( Qt::transparent ); painter->setPen( Qt::transparent );