Skip to content

Commit 76b0932

Browse files
committedMay 8, 2019
[ui] Fix marker sizing for the filled marker widget
1 parent 65ec9cd commit 76b0932

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
 

‎src/gui/symbology/qgssymbollayerwidget.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -968,23 +968,27 @@ QgsFilledMarkerSymbolLayerWidget::QgsFilledMarkerSymbolLayerWidget( QgsVectorLay
968968
if ( vectorLayer() )
969969
mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
970970

971-
QSize size = lstNames->iconSize();
972-
double markerSize = DEFAULT_POINT_SIZE * 2;
973-
const auto shapes { QgsSimpleMarkerSymbolLayerBase::availableShapes() };
971+
int size = lstNames->iconSize().width();
972+
size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( QStringLiteral( "XXX" ) ) ) ) );
973+
lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
974+
lstNames->setIconSize( QSize( size, size ) );
975+
976+
double markerSize = size * 0.8;
977+
const auto shapes = QgsSimpleMarkerSymbolLayerBase::availableShapes();
974978
for ( QgsSimpleMarkerSymbolLayerBase::Shape shape : shapes )
975979
{
976-
if ( !QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( shape ) )
977-
continue;
978-
979980
QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
981+
lyr->setSizeUnit( QgsUnitTypes::RenderPixels );
980982
lyr->setColor( QColor( 200, 200, 200 ) );
981983
lyr->setStrokeColor( QColor( 0, 0, 0 ) );
982-
QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderMillimeters, size );
984+
QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderPixels, QSize( size, size ) );
983985
QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
984986
item->setData( Qt::UserRole, static_cast< int >( shape ) );
985987
item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
986988
delete lyr;
987989
}
990+
// show at least 3 rows
991+
lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
988992

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

0 commit comments

Comments
 (0)
Please sign in to comment.