@@ -128,13 +128,14 @@ QSizeF QgsLayerTreeModelLegendNode::drawSymbolText( const QgsLegendSettings &set
128
128
129
129
// -------------------------------------------------------------------------
130
130
131
-
132
131
QgsSymbolLegendNode::QgsSymbolLegendNode ( QgsLayerTreeLayer *nodeLayer, const QgsLegendSymbolItem &item, QObject *parent )
133
132
: QgsLayerTreeModelLegendNode( nodeLayer, parent )
134
133
, mItem( item )
135
134
, mSymbolUsesMapUnits( false )
136
- , mIconSize( 16 , 16 )
137
135
{
136
+ const int iconSize = QgsLayerTreeModel::scaleIconSize ( 16 );
137
+ mIconSize = QSize ( iconSize, iconSize );
138
+
138
139
updateLabel ();
139
140
connect ( qobject_cast<QgsVectorLayer *>( nodeLayer->layer () ), &QgsVectorLayer::symbolFeatureCountMapChanged, this , &QgsSymbolLegendNode::updateLabel );
140
141
connect ( nodeLayer, &QObject::destroyed, this , [ = ]() { mLayerNode = nullptr ; } );
@@ -160,19 +161,21 @@ QSize QgsSymbolLegendNode::minimumIconSize() const
160
161
161
162
QSize QgsSymbolLegendNode::minimumIconSize ( QgsRenderContext *context ) const
162
163
{
163
- QSize minSz ( 16 , 16 );
164
+ const int iconSize = QgsLayerTreeModel::scaleIconSize ( 16 );
165
+ const int largeIconSize = QgsLayerTreeModel::scaleIconSize ( 512 );
166
+ QSize minSz ( iconSize, iconSize );
164
167
if ( mItem .symbol () && mItem .symbol ()->type () == QgsSymbol::Marker )
165
168
{
166
169
minSz = QgsImageOperation::nonTransparentImageRect (
167
- QgsSymbolLayerUtils::symbolPreviewPixmap ( mItem .symbol (), QSize ( 512 , 512 ), 0 ,
170
+ QgsSymbolLayerUtils::symbolPreviewPixmap ( mItem .symbol (), QSize ( largeIconSize, largeIconSize ), 0 ,
168
171
context ).toImage (),
169
172
minSz,
170
173
true ).size ();
171
174
}
172
175
else if ( mItem .symbol () && mItem .symbol ()->type () == QgsSymbol::Line )
173
176
{
174
177
minSz = QgsImageOperation::nonTransparentImageRect (
175
- QgsSymbolLayerUtils::symbolPreviewPixmap ( mItem .symbol (), QSize ( minSz.width (), 512 ), 0 ,
178
+ QgsSymbolLayerUtils::symbolPreviewPixmap ( mItem .symbol (), QSize ( minSz.width (), largeIconSize ), 0 ,
176
179
context ).toImage (),
177
180
minSz,
178
181
true ).size ();
@@ -576,8 +579,8 @@ QVariant QgsRasterSymbolLegendNode::data( int role ) const
576
579
{
577
580
if ( role == Qt::DecorationRole )
578
581
{
579
- QSize iconSize ( 16 , 16 ); // TODO: configurable?
580
- QPixmap pix ( iconSize );
582
+ const int iconSize = QgsLayerTreeModel::scaleIconSize ( 16 ); // TODO: configurable?
583
+ QPixmap pix ( iconSize, iconSize );
581
584
pix.fill ( mColor );
582
585
return QIcon ( pix );
583
586
}
0 commit comments