Skip to content

Commit 844578d

Browse files
committedOct 8, 2015
Fix line height and icon size on hipi
The icon will scale up but not down, the 2.10 behaviour is retained on 96dpi screens and the icon is scaled up if needed
1 parent d088e0b commit 844578d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed
 

‎src/gui/attributetable/qgsfeaturelistviewdelegate.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ void QgsFeatureListViewDelegate::setEditSelectionModel( QItemSelectionModel* edi
5252
QSize QgsFeatureListViewDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
5353
{
5454
Q_UNUSED( index )
55-
QSize size = QItemDelegate::sizeHint( option, index );
56-
size.setHeight( option.fontMetrics.height() );
57-
return size;
55+
int height = sIconSize;
56+
return QSize( option.rect.width(), qMax( height, option.fontMetrics.height() ) );
5857
}
5958

6059
void QgsFeatureListViewDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
@@ -81,6 +80,13 @@ void QgsFeatureListViewDelegate::paint( QPainter *painter, const QStyleOptionVie
8180
icon = QgsApplication::getThemePixmap( "/mIconDeselected.svg" );
8281
}
8382

83+
// Scale up the icon if needed
84+
if ( option.rect.height() > sIconSize )
85+
{
86+
icon = icon.scaledToHeight( option.rect.height(), Qt::SmoothTransformation );
87+
}
88+
89+
8490
// Text layout options
8591
QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );
8692

0 commit comments

Comments
 (0)
Please sign in to comment.