@@ -1605,6 +1605,22 @@ void QgisApp::readRecentProjects()
1605
1605
settings.endGroup ();
1606
1606
}
1607
1607
1608
+ void QgisApp::applyProjectSettingsToCanvas ( QgsMapCanvas *canvas )
1609
+ {
1610
+ int red = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorRedPart" ), 255 );
1611
+ int green = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorGreenPart" ), 255 );
1612
+ int blue = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorBluePart" ), 255 );
1613
+ QColor myColor = QColor ( red, green, blue );
1614
+ canvas->setCanvasColor ( myColor );
1615
+
1616
+ int alpha = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorAlphaPart" ), 255 );
1617
+ red = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorRedPart" ), 255 );
1618
+ green = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorGreenPart" ), 255 );
1619
+ blue = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorBluePart" ), 0 );
1620
+ myColor = QColor ( red, green, blue, alpha );
1621
+ canvas->setSelectionColor ( myColor );
1622
+ }
1623
+
1608
1624
void QgisApp::readSettings ()
1609
1625
{
1610
1626
QgsSettings settings;
@@ -4564,27 +4580,27 @@ void QgisApp::fileNew( bool promptToSaveFlag, bool forceBlank )
4564
4580
// set the color for selections
4565
4581
// the default can be set in qgisoptions
4566
4582
// use project properties to override the color on a per project basis
4567
- int myRed = settings.value ( QStringLiteral ( " /qgis/default_selection_color_red" ), 255 ).toInt ();
4568
- int myGreen = settings.value ( QStringLiteral ( " /qgis/default_selection_color_green" ), 255 ).toInt ();
4569
- int myBlue = settings.value ( QStringLiteral ( " /qgis/default_selection_color_blue" ), 0 ).toInt ();
4570
- int myAlpha = settings.value ( QStringLiteral ( " /qgis/default_selection_color_alpha" ), 255 ).toInt ();
4571
- prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorRedPart" ), myRed );
4572
- prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorGreenPart" ), myGreen );
4573
- prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorBluePart" ), myBlue );
4574
- prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorAlphaPart" ), myAlpha );
4575
- mMapCanvas ->setSelectionColor ( QColor ( myRed, myGreen, myBlue, myAlpha ) );
4583
+ int red = settings.value ( QStringLiteral ( " /qgis/default_selection_color_red" ), 255 ).toInt ();
4584
+ int green = settings.value ( QStringLiteral ( " /qgis/default_selection_color_green" ), 255 ).toInt ();
4585
+ int blue = settings.value ( QStringLiteral ( " /qgis/default_selection_color_blue" ), 0 ).toInt ();
4586
+ int alpha = settings.value ( QStringLiteral ( " /qgis/default_selection_color_alpha" ), 255 ).toInt ();
4587
+ prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorRedPart" ), red );
4588
+ prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorGreenPart" ), green );
4589
+ prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorBluePart" ), blue );
4590
+ prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorAlphaPart" ), alpha );
4576
4591
4577
4592
// set the canvas to the default background color
4578
4593
// the default can be set in qgisoptions
4579
4594
// use project properties to override the color on a per project basis
4580
- myRed = settings.value ( QStringLiteral ( " /qgis/default_canvas_color_red" ), 255 ).toInt ();
4581
- myGreen = settings.value ( QStringLiteral ( " /qgis/default_canvas_color_green" ), 255 ).toInt ();
4582
- myBlue = settings.value ( QStringLiteral ( " /qgis/default_canvas_color_blue" ), 255 ).toInt ();
4583
- prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorRedPart" ), myRed );
4584
- prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorGreenPart" ), myGreen );
4585
- prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorBluePart" ), myBlue );
4586
- mMapCanvas ->setCanvasColor ( QColor ( myRed, myGreen, myBlue ) );
4587
- mOverviewCanvas ->setBackgroundColor ( QColor ( myRed, myGreen, myBlue ) );
4595
+ red = settings.value ( QStringLiteral ( " /qgis/default_canvas_color_red" ), 255 ).toInt ();
4596
+ green = settings.value ( QStringLiteral ( " /qgis/default_canvas_color_green" ), 255 ).toInt ();
4597
+ blue = settings.value ( QStringLiteral ( " /qgis/default_canvas_color_blue" ), 255 ).toInt ();
4598
+ prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorRedPart" ), red );
4599
+ prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorGreenPart" ), green );
4600
+ prj->writeEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorBluePart" ), blue );
4601
+
4602
+ mOverviewCanvas ->setBackgroundColor ( QColor ( red, green, blue ) );
4603
+ applyProjectSettingsToCanvas ( mMapCanvas );
4588
4604
4589
4605
prj->setDirty ( false );
4590
4606
@@ -5027,16 +5043,9 @@ bool QgisApp::addProject( const QString &projectFile )
5027
5043
int myGreenInt = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorGreenPart" ), 255 );
5028
5044
int myBlueInt = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /CanvasColorBluePart" ), 255 );
5029
5045
QColor myColor = QColor ( myRedInt, myGreenInt, myBlueInt );
5030
- mMapCanvas ->setCanvasColor ( myColor ); // this is fill color before rendering starts
5031
5046
mOverviewCanvas ->setBackgroundColor ( myColor );
5032
5047
5033
- QgsDebugMsg ( " Canvas background color restored..." );
5034
- int myAlphaInt = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorAlphaPart" ), 255 );
5035
- myRedInt = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorRedPart" ), 255 );
5036
- myGreenInt = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorGreenPart" ), 255 );
5037
- myBlueInt = QgsProject::instance ()->readNumEntry ( QStringLiteral ( " Gui" ), QStringLiteral ( " /SelectionColorBluePart" ), 0 );
5038
- myColor = QColor ( myRedInt, myGreenInt, myBlueInt, myAlphaInt );
5039
- mMapCanvas ->setSelectionColor ( myColor ); // this is selection color before rendering starts
5048
+ applyProjectSettingsToCanvas ( mMapCanvas );
5040
5049
5041
5050
// load project scales
5042
5051
bool projectScales = QgsProject::instance ()->readBoolEntry ( QStringLiteral ( " Scales" ), QStringLiteral ( " /useProjectScales" ) );
0 commit comments