26
26
#include " qgspallabeling.h"
27
27
#include " qgsrendererv2.h"
28
28
#include " qgsvectorlayer.h"
29
+ #include " qgsproject.h"
29
30
30
31
#include " qgscomposition.h"
31
32
#include " qgscomposerarrow.h"
@@ -469,6 +470,51 @@ bool QgsWMSProjectParser::WMSInspireActivated() const
469
470
return inspireActivated;
470
471
}
471
472
473
+ bool QgsWMSProjectParser::activateSelectionColor () const
474
+ {
475
+ QDomElement propertiesElem = mProjectParser ->propertiesElem ();
476
+ if ( !propertiesElem.isNull () )
477
+ {
478
+ QDomElement guiElem = propertiesElem.firstChildElement ( " Gui" );
479
+ if ( !guiElem.isNull () )
480
+ {
481
+ int myAlpha = 255 ;
482
+ int myRed = 255 ;
483
+ int myGreen = 255 ;
484
+ int myBlue = 0 ;
485
+
486
+ QDomElement alphaElem = guiElem.firstChildElement ( " SelectionColorAlphaPart" );
487
+ if ( !alphaElem.isNull () )
488
+ {
489
+ myAlpha = QVariant ( alphaElem.text () ).toInt ();
490
+ }
491
+ QDomElement redElem = guiElem.firstChildElement ( " SelectionColorRedPart" );
492
+ if ( !redElem.isNull () )
493
+ {
494
+ myRed = QVariant ( redElem.text () ).toInt ();
495
+ }
496
+ QDomElement greenElem = guiElem.firstChildElement ( " SelectionColorGreenPart" );
497
+ if ( !greenElem.isNull () )
498
+ {
499
+ myGreen = QVariant ( greenElem.text () ).toInt ();
500
+ }
501
+ QDomElement blueElem = guiElem.firstChildElement ( " SelectionColorBluePart" );
502
+ if ( !blueElem.isNull () )
503
+ {
504
+ myBlue = QVariant ( blueElem.text () ).toInt ();
505
+ }
506
+ QgsProject* prj = QgsProject::instance ();
507
+ prj->writeEntry ( " Gui" , " /SelectionColorRedPart" , myRed );
508
+ prj->writeEntry ( " Gui" , " /SelectionColorGreenPart" , myGreen );
509
+ prj->writeEntry ( " Gui" , " /SelectionColorBluePart" , myBlue );
510
+ prj->writeEntry ( " Gui" , " /SelectionColorAlphaPart" , myAlpha );
511
+ return true ;
512
+ }
513
+ }
514
+
515
+ return false ;
516
+ }
517
+
472
518
QgsComposition* QgsWMSProjectParser::initComposition ( const QString& composerTemplate, QgsMapRenderer* mapRenderer, QList< QgsComposerMap* >& mapList, QList< QgsComposerLegend* >& legendList, QList< QgsComposerLabel* >& labelList, QList<const QgsComposerHtml *>& htmlList ) const
473
519
{
474
520
// Create composition from xml
@@ -484,6 +530,9 @@ QgsComposition* QgsWMSProjectParser::initComposition( const QString& composerTem
484
530
return nullptr ;
485
531
}
486
532
533
+ // Selection color
534
+ activateSelectionColor ();
535
+
487
536
QgsComposition* composition = new QgsComposition ( mapRenderer->mapSettings () ); // set resolution, paper size from composer element attributes
488
537
if ( !composition->readXML ( compositionElem, *( mProjectParser ->xmlDocument () ) ) )
489
538
{
0 commit comments