Skip to content
Permalink
Browse files

Merge pull request #6778 from signedav/fix_condformat_alpha

Save and load alpha of conditional style color
  • Loading branch information
m-kuhn committed Apr 12, 2018
2 parents d94cf12 + a4b5816 commit 0135b4c90ea91649416d1b93a76e3b59a8560207
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/core/qgsconditionalstyle.cpp
@@ -273,7 +273,9 @@ bool QgsConditionalStyle::writeXml( QDomNode &node, QDomDocument &doc, const Qgs
stylesel.setAttribute( QStringLiteral( "rule" ), mRule );
stylesel.setAttribute( QStringLiteral( "name" ), mName );
stylesel.setAttribute( QStringLiteral( "background_color" ), mBackColor.name() );
stylesel.setAttribute( QStringLiteral( "background_color_alpha" ), mBackColor.alpha() );
stylesel.setAttribute( QStringLiteral( "text_color" ), mTextColor.name() );
stylesel.setAttribute( QStringLiteral( "text_color_alpha" ), mTextColor.alpha() );
QDomElement labelFontElem = QgsFontUtils::toXmlElement( mFont, doc, QStringLiteral( "font" ) );
stylesel.appendChild( labelFontElem );
if ( mSymbol )
@@ -290,8 +292,18 @@ bool QgsConditionalStyle::readXml( const QDomNode &node, const QgsReadWriteConte
QDomElement styleElm = node.toElement();
setRule( styleElm.attribute( QStringLiteral( "rule" ) ) );
setName( styleElm.attribute( QStringLiteral( "name" ) ) );
setBackgroundColor( QColor( styleElm.attribute( QStringLiteral( "background_color" ) ) ) );
setTextColor( QColor( styleElm.attribute( QStringLiteral( "text_color" ) ) ) );
QColor bColor = QColor( styleElm.attribute( QStringLiteral( "background_color" ) ) );
if ( styleElm.hasAttribute( QStringLiteral( "background_color_alpha" ) ) )
{
bColor.setAlpha( styleElm.attribute( QStringLiteral( "background_color_alpha" ) ).toInt() );
}
setBackgroundColor( bColor );
QColor tColor = QColor( styleElm.attribute( QStringLiteral( "text_color" ) ) );
if ( styleElm.hasAttribute( QStringLiteral( "text_color_alpha" ) ) )
{
tColor.setAlpha( styleElm.attribute( QStringLiteral( "text_color_alpha" ) ).toInt() );
}
setTextColor( tColor );
QgsFontUtils::setFromXmlChildNode( mFont, styleElm, QStringLiteral( "font" ) );
QDomElement symbolElm = styleElm.firstChildElement( QStringLiteral( "symbol" ) );
if ( !symbolElm.isNull() )

0 comments on commit 0135b4c

Please sign in to comment.
You can’t perform that action at this time.