Skip to content

Commit 91384a0

Browse files
authored
Merge pull request #6788 from signedav/fix_condformat_alpha_BP_218_3
Backport to 2.18 Save and load alpha of conditional style color
2 parents 6c06421 + 8c8cd8d commit 91384a0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/core/qgsconditionalstyle.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ bool QgsConditionalStyle::writeXml( QDomNode &node, QDomDocument &doc ) const
281281
stylesel.setAttribute( "rule", mRule );
282282
stylesel.setAttribute( "name", mName );
283283
stylesel.setAttribute( "background_color", mBackColor.name() );
284+
stylesel.setAttribute( "background_color_alpha", mBackColor.alpha() );
284285
stylesel.setAttribute( "text_color", mTextColor.name() );
286+
stylesel.setAttribute( "text_color_alpha", mTextColor.alpha() );
285287
QDomElement labelFontElem = QgsFontUtils::toXmlElement( mFont, doc, "font" );
286288
stylesel.appendChild( labelFontElem );
287289
if ( ! mSymbol.isNull() )
@@ -298,8 +300,18 @@ bool QgsConditionalStyle::readXml( const QDomNode &node )
298300
QDomElement styleElm = node.toElement();
299301
setRule( styleElm.attribute( "rule" ) );
300302
setName( styleElm.attribute( "name" ) );
301-
setBackgroundColor( QColor( styleElm.attribute( "background_color" ) ) );
302-
setTextColor( QColor( styleElm.attribute( "text_color" ) ) );
303+
QColor bColor = QColor( styleElm.attribute( "background_color" ) );
304+
if ( styleElm.hasAttribute( "background_color_alpha" ) )
305+
{
306+
bColor.setAlpha( styleElm.attribute( "background_color_alpha" ).toInt() );
307+
}
308+
setBackgroundColor( bColor );
309+
QColor tColor = QColor( styleElm.attribute( "text_color" ) );
310+
if ( styleElm.hasAttribute( "text_color_alpha" ) )
311+
{
312+
tColor.setAlpha( styleElm.attribute( "text_color_alpha" ).toInt() );
313+
}
314+
setTextColor( tColor );
303315
QgsFontUtils::setFromXmlChildNode( mFont, styleElm, "font" );
304316
QDomElement symbolElm = styleElm.firstChildElement( "symbol" );
305317
if ( !symbolElm.isNull() )

0 commit comments

Comments
 (0)