Skip to content
Permalink
Browse files

Save and load alpha of conditional style color

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 7018cb01a62015f7d230b38190964b661ad1cebf
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( "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() )

0 comments on commit 7018cb0

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