Skip to content

Commit 757cd7a

Browse files
nirvnnyalldawson
authored andcommitted
[svg markers] allow setting alpha value for fill and outline colors
1 parent ee72079 commit 757cd7a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/core/symbology-ng/qgssvgcache.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -620,14 +620,22 @@ void QgsSvgCache::replaceElemParams( QDomElement& elem, const QColor& fill, cons
620620
}
621621
QString key = keyValueSplit.at( 0 );
622622
QString value = keyValueSplit.at( 1 );
623-
if ( value.startsWith( "param(fill" ) )
623+
if ( value.startsWith( "param(fill)" ) )
624624
{
625625
value = fill.name();
626626
}
627+
else if ( value.startsWith( "param(fill-opacity)" ) )
628+
{
629+
value = fill.alphaF();
630+
}
627631
else if ( value.startsWith( "param(outline)" ) )
628632
{
629633
value = outline.name();
630634
}
635+
else if ( value.startsWith( "param(outline-opacity)" ) )
636+
{
637+
value = outline.alphaF();
638+
}
631639
else if ( value.startsWith( "param(outline-width)" ) )
632640
{
633641
value = QString::number( outlineWidth );
@@ -648,10 +656,18 @@ void QgsSvgCache::replaceElemParams( QDomElement& elem, const QColor& fill, cons
648656
{
649657
elem.setAttribute( attribute.name(), fill.name() );
650658
}
659+
else if ( value.startsWith( "param(fill-opacity)" ) )
660+
{
661+
elem.setAttribute( attribute.name(), fill.alphaF() );
662+
}
651663
else if ( value.startsWith( "param(outline)" ) )
652664
{
653665
elem.setAttribute( attribute.name(), outline.name() );
654666
}
667+
else if ( value.startsWith( "param(outline-opacity)" ) )
668+
{
669+
elem.setAttribute( attribute.name(), outline.alphaF() );
670+
}
655671
else if ( value.startsWith( "param(outline-width)" ) )
656672
{
657673
elem.setAttribute( attribute.name(), QString::number( outlineWidth ) );

src/gui/symbology-ng/qgssymbollayerv2widget.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1564,11 +1564,12 @@ QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( const QgsVecto
15641564
mBorderWidthUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
15651565
mOffsetUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );
15661566
viewGroups->setHeaderHidden( true );
1567-
1567+
mChangeColorButton->setAllowAlpha( true );
15681568
mChangeColorButton->setColorDialogTitle( tr( "Select fill color" ) );
15691569
mChangeColorButton->setContext( "symbology" );
1570+
mChangeBorderColorButton->setAllowAlpha( true );
15701571
mChangeBorderColorButton->setColorDialogTitle( tr( "Select border color" ) );
1571-
mChangeColorButton->setContext( "symbology" );
1572+
mChangeBorderColorButton->setContext( "symbology" );
15721573

15731574
spinOffsetX->setClearValue( 0.0 );
15741575
spinOffsetY->setClearValue( 0.0 );

0 commit comments

Comments
 (0)