Skip to content

Commit 87ebaf4

Browse files
committed
[ui] Fix marker sizing for the filled marker widget
1 parent 253a882 commit 87ebaf4

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/gui/symbology/qgssymbollayerwidget.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -900,22 +900,27 @@ QgsFilledMarkerSymbolLayerWidget::QgsFilledMarkerSymbolLayerWidget( QgsVectorLay
900900
if ( vectorLayer() )
901901
mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
902902

903-
QSize size = lstNames->iconSize();
904-
double markerSize = DEFAULT_POINT_SIZE * 2;
905-
Q_FOREACH ( QgsSimpleMarkerSymbolLayerBase::Shape shape, QgsSimpleMarkerSymbolLayerBase::availableShapes() )
906-
{
907-
if ( !QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( shape ) )
908-
continue;
903+
int size = lstNames->iconSize().width();
904+
size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( QStringLiteral( "XXX" ) ) ) ) );
905+
lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
906+
lstNames->setIconSize( QSize( size, size ) );
909907

908+
double markerSize = size * 0.8;
909+
const auto shapes = QgsSimpleMarkerSymbolLayerBase::availableShapes();
910+
for ( QgsSimpleMarkerSymbolLayerBase::Shape shape : shapes )
911+
{
910912
QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
913+
lyr->setSizeUnit( QgsUnitTypes::RenderPixels );
911914
lyr->setColor( QColor( 200, 200, 200 ) );
912915
lyr->setStrokeColor( QColor( 0, 0, 0 ) );
913-
QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderMillimeters, size );
916+
QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderPixels, QSize( size, size ) );
914917
QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
915918
item->setData( Qt::UserRole, static_cast< int >( shape ) );
916919
item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
917920
delete lyr;
918921
}
922+
// show at least 3 rows
923+
lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
919924

920925
connect( lstNames, &QListWidget::currentRowChanged, this, &QgsFilledMarkerSymbolLayerWidget::setShape );
921926
connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setSize );

0 commit comments

Comments
 (0)