Skip to content
Permalink
Browse files

Merge pull request #6786 from signedav/fix_condformat_alpha_BP

Backport to 3.0 Save and load alpha of conditional style color
  • Loading branch information
m-kuhn committed Apr 12, 2018
2 parents 27fa062 + 79256b0 commit e516e7cf62e692a894a87f392b539d0e7ddaf134
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 e516e7c

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