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 (saturation) will be saved and loaded for the conditional style color of text and background.
Before there was not only the problem, that it was not saved - it was additional the issue, that background with no color had after reopening the project the alpha(saturation) of FF and the color black.
This is fixed now.
  • Loading branch information
signedav committed Apr 10, 2018
1 parent 7fa9d41 commit 7018cb0
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( "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( "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 7018cb0

Please sign in to comment.