@@ -31,7 +31,9 @@ QSize QgsPluginItemDelegate::sizeHint( const QStyleOptionViewItem & option, cons
31
31
{
32
32
Q_UNUSED ( option );
33
33
Q_UNUSED ( index );
34
- return QSize ( 20 , 20 );
34
+ // Calculate row height, adds some 20% padding
35
+ int pixelsHigh = int (QApplication::fontMetrics ().height () * 1.2 );
36
+ return QSize ( pixelsHigh, pixelsHigh );
35
37
}
36
38
37
39
@@ -40,6 +42,7 @@ void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem
40
42
painter->save ();
41
43
painter->setRenderHint ( QPainter::SmoothPixmapTransform );
42
44
QStyle *style = QApplication::style ();
45
+ int pixelsHigh = QApplication::fontMetrics ().height ();
43
46
44
47
// Draw the background
45
48
style->drawPrimitive ( QStyle::PE_PanelItemViewItem, &option, painter, NULL );
@@ -66,7 +69,7 @@ void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem
66
69
if ( !iconPixmap.isNull () )
67
70
{
68
71
int iconSize = option.rect .height ();
69
- painter->drawPixmap ( option.rect .left () + 24 , option.rect .top (), iconSize, iconSize, iconPixmap );
72
+ painter->drawPixmap ( option.rect .left () + pixelsHigh , option.rect .top (), iconSize, iconSize, iconPixmap );
70
73
}
71
74
72
75
// Draw the text
@@ -92,8 +95,7 @@ void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem
92
95
font.setBold ( true );
93
96
painter->setFont ( font );
94
97
}
95
-
96
- painter->drawText ( option.rect .left () + 48 , option.rect .bottom () - 3 , index .data ( Qt::DisplayRole ).toString () );
98
+ painter->drawText ( option.rect .left () + int ( pixelsHigh * 2.3 ), option.rect .bottom () - int ( pixelsHigh / 6 ), index .data ( Qt::DisplayRole ).toString () );
97
99
98
100
painter->restore ();
99
101
}
0 commit comments