Skip to content

Commit

Permalink
Fix line height and icon size on hipi
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
elpaso committed Oct 8, 2015
1 parent d088e0b commit 844578d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/gui/attributetable/qgsfeaturelistviewdelegate.cpp
Expand Up @@ -52,9 +52,8 @@ void QgsFeatureListViewDelegate::setEditSelectionModel( QItemSelectionModel* edi
QSize QgsFeatureListViewDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
Q_UNUSED( index )
QSize size = QItemDelegate::sizeHint( option, index );
size.setHeight( option.fontMetrics.height() );
return size;
int height = sIconSize;
return QSize( option.rect.width(), qMax( height, option.fontMetrics.height() ) );
}

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

// Scale up the icon if needed
if ( option.rect.height() > sIconSize )
{
icon = icon.scaledToHeight( option.rect.height(), Qt::SmoothTransformation );
}


// Text layout options
QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );

Expand Down

0 comments on commit 844578d

Please sign in to comment.