22
22
#include " qgslogger.h"
23
23
#include " qgsmapserviceexception.h"
24
24
#include " qgsrasterlayer.h"
25
+ #include " qgsrenderer.h"
25
26
#include " qgsvectorlayer.h"
26
27
27
28
#include " qgscomposition.h"
@@ -42,6 +43,7 @@ QgsProjectParser::QgsProjectParser( QDomDocument* xmlDoc, const QString& filePat
42
43
{
43
44
mOutputUnits = QgsMapRenderer::Millimeters;
44
45
setLegendParametersFromProject ();
46
+ setSelectionColor ();
45
47
}
46
48
47
49
QgsProjectParser::~QgsProjectParser ()
@@ -1409,3 +1411,50 @@ QString QgsProjectParser::convertToAbsolutePath( const QString& file ) const
1409
1411
return projElems.join ( " /" );
1410
1412
}
1411
1413
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