2222#include " qgslogger.h"
2323#include " qgsmapserviceexception.h"
2424#include " qgsrasterlayer.h"
25+ #include " qgsrenderer.h"
2526#include " qgsvectorlayer.h"
2627
2728#include " qgscomposition.h"
@@ -42,6 +43,7 @@ QgsProjectParser::QgsProjectParser( QDomDocument* xmlDoc, const QString& filePat
4243{
4344 mOutputUnits = QgsMapRenderer::Millimeters;
4445 setLegendParametersFromProject ();
46+ setSelectionColor ();
4547}
4648
4749QgsProjectParser::~QgsProjectParser ()
@@ -1409,3 +1411,50 @@ QString QgsProjectParser::convertToAbsolutePath( const QString& file ) const
14091411 return projElems.join ( " /" );
14101412}
14111413
1414+ void QgsProjectParser::setSelectionColor ()
1415+ {
1416+ int red = 255 ;
1417+ int green = 255 ;
1418+ int blue = 0 ;
1419+ int alpha = 255 ;
1420+
1421+ // overwrite default selection color with settings from the project
1422+ if ( mXMLDoc )
1423+ {
1424+ QDomElement qgisElem = mXMLDoc ->documentElement ();
1425+ if ( !qgisElem.isNull () )
1426+ {
1427+ QDomElement propertiesElem = qgisElem.firstChildElement ( " properties" );
1428+ if ( !propertiesElem.isNull () )
1429+ {
1430+ QDomElement guiElem = propertiesElem.firstChildElement ( " Gui" );
1431+ if ( !guiElem.isNull () )
1432+ {
1433+ QDomElement redElem = guiElem.firstChildElement ( " SelectionColorRedPart" );
1434+ if ( !redElem.isNull () )
1435+ {
1436+ red = redElem.text ().toInt ();
1437+ }
1438+ QDomElement greenElem = guiElem.firstChildElement ( " SelectionColorGreenPart" );
1439+ if ( !greenElem.isNull () )
1440+ {
1441+ green = greenElem.text ().toInt ();
1442+ }
1443+ QDomElement blueElem = guiElem.firstChildElement ( " SelectionColorBluePart" );
1444+ if ( !blueElem.isNull () )
1445+ {
1446+ blue = blueElem.text ().toInt ();
1447+ }
1448+ QDomElement alphaElem = guiElem.firstChildElement ( " SelectionColorAlphaPart" );
1449+ if ( !alphaElem.isNull () )
1450+ {
1451+ alpha = alphaElem.text ().toInt ();
1452+ }
1453+ }
1454+ }
1455+ }
1456+ }
1457+
1458+ QgsRenderer::setSelectionColor ( QColor ( red, green, blue, alpha ) );
1459+ }
1460+
0 commit comments