Skip to content
Permalink
Browse files

fix transparency saving on QML file (follow 74ba70a):

do not store the same transparency value twice (for both SimpleFill symbol and its layers)
  • Loading branch information
brushtyler committed Oct 1, 2012
1 parent 1dfb3b3 commit 495246f57574d88453bc55190a91f41bdb2cb11f
Showing with 46 additions and 0 deletions.
  1. +21 −0 src/core/qgsmaplayer.cpp
  2. +25 −0 src/core/qgsprojectfiletransform.cpp
@@ -37,6 +37,7 @@
#include "qgscoordinatereferencesystem.h"
#include "qgsapplication.h"
#include "qgsproject.h"
#include "qgsprojectfiletransform.h"
#include "qgsdatasourceuri.h"
#include "qgsvectorlayer.h"

@@ -778,6 +779,26 @@ QString QgsMapLayer::loadNamedStyle( const QString theURI, bool &theResultFlag )
return myErrorMessage;
}

// get style file version string, if any
QgsProjectVersion fileVersion( myDocument.firstChildElement( "qgis" ).attribute( "version" ) );
QgsProjectVersion thisVersion( QGis::QGIS_VERSION );

if ( thisVersion > fileVersion )
{
QgsLogger::warning( "Loading a style file that was saved with an older "
"version of qgis (saved in " + fileVersion.text() +
", loaded in " + QGis::QGIS_VERSION +
"). Problems may occur." );

QgsProjectFileTransform styleFile( myDocument, fileVersion );

styleFile.dump();

styleFile.updateRevision( thisVersion );

styleFile.dump();
}

// now get the layer node out and pass it over to the layer
// to deserialise...
QDomElement myRoot = myDocument.firstChildElement( "qgis" );
@@ -531,6 +531,31 @@ void QgsProjectFileTransform::transform1800to1900()
}
}

// SimpleFill symbol layer v2: avoid double transparency
// replacing alpha value of symbol layer's color with 255 (the
// transparency value is already stored as symbol transparency).
QDomNodeList rendererList = mDom.elementsByTagName( "renderer-v2" );
for ( int i = 0; i < rendererList.size(); ++i )
{
QDomNodeList layerList = rendererList.at( i ).toElement().elementsByTagName( "layer" );
for ( int j = 0; j < layerList.size(); ++j )
{
QDomElement layerElem = layerList.at( j ).toElement();
if ( layerElem.attribute( "class" ) == "SimpleFill" )
{
QDomNodeList propList = layerElem.elementsByTagName( "prop" );
for ( int k = 0; k < propList.size(); ++k )
{
QDomElement propElem = propList.at( k ).toElement();
if ( propElem.attribute( "k" ) == "color" || propElem.attribute( "k" ) == "color_border" )
{
propElem.setAttribute( "v", propElem.attribute( "v" ).section( ",", 0, 2 ) + ",255" );
}
}
}
}
}

QgsDebugMsg( mDom.toString() );
}

0 comments on commit 495246f

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