mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-10 00:04:23 -04:00
[ui] Fix marker sizing for the filled marker widget
This commit is contained in:
parent
65ec9cd146
commit
76b09328f6
@ -968,23 +968,27 @@ QgsFilledMarkerSymbolLayerWidget::QgsFilledMarkerSymbolLayerWidget( QgsVectorLay
|
|||||||
if ( vectorLayer() )
|
if ( vectorLayer() )
|
||||||
mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
|
mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
|
||||||
|
|
||||||
QSize size = lstNames->iconSize();
|
int size = lstNames->iconSize().width();
|
||||||
double markerSize = DEFAULT_POINT_SIZE * 2;
|
size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( QStringLiteral( "XXX" ) ) ) ) );
|
||||||
const auto shapes { QgsSimpleMarkerSymbolLayerBase::availableShapes() };
|
lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
|
||||||
|
lstNames->setIconSize( QSize( size, size ) );
|
||||||
|
|
||||||
|
double markerSize = size * 0.8;
|
||||||
|
const auto shapes = QgsSimpleMarkerSymbolLayerBase::availableShapes();
|
||||||
for ( QgsSimpleMarkerSymbolLayerBase::Shape shape : shapes )
|
for ( QgsSimpleMarkerSymbolLayerBase::Shape shape : shapes )
|
||||||
{
|
{
|
||||||
if ( !QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( shape ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
|
QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
|
||||||
|
lyr->setSizeUnit( QgsUnitTypes::RenderPixels );
|
||||||
lyr->setColor( QColor( 200, 200, 200 ) );
|
lyr->setColor( QColor( 200, 200, 200 ) );
|
||||||
lyr->setStrokeColor( QColor( 0, 0, 0 ) );
|
lyr->setStrokeColor( QColor( 0, 0, 0 ) );
|
||||||
QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderMillimeters, size );
|
QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderPixels, QSize( size, size ) );
|
||||||
QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
|
QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
|
||||||
item->setData( Qt::UserRole, static_cast< int >( shape ) );
|
item->setData( Qt::UserRole, static_cast< int >( shape ) );
|
||||||
item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
|
item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
|
||||||
delete lyr;
|
delete lyr;
|
||||||
}
|
}
|
||||||
|
// show at least 3 rows
|
||||||
|
lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
|
||||||
|
|
||||||
connect( lstNames, &QListWidget::currentRowChanged, this, &QgsFilledMarkerSymbolLayerWidget::setShape );
|
connect( lstNames, &QListWidget::currentRowChanged, this, &QgsFilledMarkerSymbolLayerWidget::setShape );
|
||||||
connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setSize );
|
connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setSize );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user