Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #6786 from signedav/fix_condformat_alpha_BP
Browse files Browse the repository at this point in the history
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 e516e7c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/qgsconditionalstyle.cpp
Expand Up @@ -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 )
Expand All @@ -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() )
Expand Down

0 comments on commit e516e7c

Please sign in to comment.