Skip to content

Commit

Permalink
Save and load alpha of conditional style color
Browse files Browse the repository at this point in the history
Alpha (opacity) will be saved and loaded for the conditional style color of text and background.
  • Loading branch information
signedav committed Apr 12, 2018
1 parent 6c06421 commit 8c8cd8d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/qgsconditionalstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ bool QgsConditionalStyle::writeXml( QDomNode &node, QDomDocument &doc ) const
stylesel.setAttribute( "rule", mRule );
stylesel.setAttribute( "name", mName );
stylesel.setAttribute( "background_color", mBackColor.name() );
stylesel.setAttribute( "background_color_alpha", mBackColor.alpha() );
stylesel.setAttribute( "text_color", mTextColor.name() );
stylesel.setAttribute( "text_color_alpha", mTextColor.alpha() );
QDomElement labelFontElem = QgsFontUtils::toXmlElement( mFont, doc, "font" );
stylesel.appendChild( labelFontElem );
if ( ! mSymbol.isNull() )
Expand All @@ -298,8 +300,18 @@ bool QgsConditionalStyle::readXml( const QDomNode &node )
QDomElement styleElm = node.toElement();
setRule( styleElm.attribute( "rule" ) );
setName( styleElm.attribute( "name" ) );
setBackgroundColor( QColor( styleElm.attribute( "background_color" ) ) );
setTextColor( QColor( styleElm.attribute( "text_color" ) ) );
QColor bColor = QColor( styleElm.attribute( "background_color" ) );
if ( styleElm.hasAttribute( "background_color_alpha" ) )
{
bColor.setAlpha( styleElm.attribute( "background_color_alpha" ).toInt() );
}
setBackgroundColor( bColor );
QColor tColor = QColor( styleElm.attribute( "text_color" ) );
if ( styleElm.hasAttribute( "text_color_alpha" ) )
{
tColor.setAlpha( styleElm.attribute( "text_color_alpha" ).toInt() );
}
setTextColor( tColor );
QgsFontUtils::setFromXmlChildNode( mFont, styleElm, "font" );
QDomElement symbolElm = styleElm.firstChildElement( "symbol" );
if ( !symbolElm.isNull() )
Expand Down

0 comments on commit 8c8cd8d

Please sign in to comment.