Skip to content

Commit

Permalink
fix transparency saving on QML file (follow 74ba70a):
Browse files Browse the repository at this point in the history
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 495246f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/core/qgsmaplayer.cpp
Expand Up @@ -37,6 +37,7 @@
#include "qgscoordinatereferencesystem.h"
#include "qgsapplication.h"
#include "qgsproject.h"
#include "qgsprojectfiletransform.h"
#include "qgsdatasourceuri.h"
#include "qgsvectorlayer.h"

Expand Down Expand Up @@ -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" );
Expand Down
25 changes: 25 additions & 0 deletions src/core/qgsprojectfiletransform.cpp
Expand Up @@ -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() );
}

Expand Down

0 comments on commit 495246f

Please sign in to comment.