1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

fixed offset issue with icons in settings list

This commit is contained in:
Michael Zanetti
2011-08-14 22:37:55 +02:00
parent a887232fff
commit f2e76803cc
2 changed files with 6 additions and 4 deletions

View File

@@ -44,9 +44,11 @@ void SettingsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
} }
#endif #endif
QRect iconRect = option.rect.adjusted( 23, 6, -option.rect.width() + option.decorationSize.width() + 7, -option.rect.height() + option.decorationSize.height() + 2 - 12 );
int horizontalOffset = ( option.rect.width() - option.decorationSize.width() ) /2;
QRect iconRect = option.rect.adjusted( horizontalOffset, 6, -horizontalOffset, -option.rect.height() + 6 + option.decorationSize.height() );
QPixmap avatar = index.data( Qt::DecorationRole ).value<QIcon>().pixmap( iconRect.size() ); QPixmap avatar = index.data( Qt::DecorationRole ).value<QIcon>().pixmap( iconRect.size() );
painter->drawPixmap( iconRect, avatar.scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) ); painter->drawPixmap( iconRect, avatar );
QRect textRect = option.rect.adjusted( 6, iconRect.height() + 8, -6, 0 ); QRect textRect = option.rect.adjusted( 6, iconRect.height() + 8, -6, 0 );
QString text = painter->fontMetrics().elidedText( index.data( Qt::DisplayRole ).toString(), Qt::ElideRight, textRect.width() ); QString text = painter->fontMetrics().elidedText( index.data( Qt::DisplayRole ).toString(), Qt::ElideRight, textRect.width() );

View File

@@ -58,8 +58,8 @@
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
<width>48</width> <width>32</width>
<height>48</height> <height>32</height>
</size> </size>
</property> </property>
<property name="movement"> <property name="movement">