From f2e76803cc9ea11af879ee4f09ed8e91849ed11b Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 14 Aug 2011 22:37:55 +0200 Subject: [PATCH] fixed offset issue with icons in settings list --- src/settingslistdelegate.cpp | 6 ++++-- src/stackedsettingsdialog.ui | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/settingslistdelegate.cpp b/src/settingslistdelegate.cpp index 032fe6d4f..43db82218 100644 --- a/src/settingslistdelegate.cpp +++ b/src/settingslistdelegate.cpp @@ -44,9 +44,11 @@ void SettingsListDelegate::paint(QPainter *painter, const QStyleOptionViewItem & } #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().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 ); QString text = painter->fontMetrics().elidedText( index.data( Qt::DisplayRole ).toString(), Qt::ElideRight, textRect.width() ); diff --git a/src/stackedsettingsdialog.ui b/src/stackedsettingsdialog.ui index e116e38c9..961b3d6b1 100644 --- a/src/stackedsettingsdialog.ui +++ b/src/stackedsettingsdialog.ui @@ -58,8 +58,8 @@ - 48 - 48 + 32 + 32