Skip to content

Commit 31494eb

Browse files
author
timlinux
committedJan 13, 2006
Improvements for setting the background colour of the canvas. It now follows this logic:
1) set in qgis options to desired default bg colour 2) whenever you start new project / open qgis that colour will be used 3) overide canvas background on a project by project basis in project props git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4679 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a8e5f46 commit 31494eb

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed
 

‎src/gui/qgisapp.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ static void setTitleBarText_( QWidget & qgisApp )
270270
mQgisInterface = new QgisIface(this);
271271
// set the legend control for the map canvas
272272
mMapCanvas->setLegend(mMapLegend);
273-
QSettings mySettings;
274-
mMapCanvas->enableAntiAliasing(mySettings.value("/qgis/enable_anti_aliasing").toBool());
275273

276274

277275
//
@@ -1059,7 +1057,17 @@ void QgisApp::createCanvas()
10591057
// "theMapCanvas" used to find this canonical instance later
10601058
mMapCanvas = new QgsMapCanvas(NULL, "theMapCanvas" );
10611059
QWhatsThis::add(mMapCanvas, tr("Map canvas. This is where raster and vector layers are displayed when added to the map"));
1062-
mMapCanvas->setBackgroundColor(Qt::white); //QColor (220, 235, 255));
1060+
//set the canvas to the default background colour
1061+
//the default can be set in qgisoptions
1062+
//use project properties to override the colour on a per project basis
1063+
QSettings mySettings;
1064+
int myRed = mySettings.value("/qgis/default_canvas_color_red",255).toInt();
1065+
int myGreen = mySettings.value("/qgis/default_canvas_color_green",255).toInt();
1066+
int myBlue = mySettings.value("/qgis/default_canvas_color_blue",255).toInt();
1067+
mMapCanvas->setCanvasColor(QColor(myRed,myGreen,myBlue)); // this is the fill co;our when rendering
1068+
mMapCanvas->setBackgroundColor(QColor(myRed,myGreen,myBlue)); // this is for the widget itself
1069+
1070+
mMapCanvas->enableAntiAliasing(mySettings.value("/qgis/enable_anti_aliasing",false).toBool());
10631071
mMapCanvas->setMinimumWidth(400);
10641072
QVBoxLayout *myCanvasLayout = new QVBoxLayout;
10651073
myCanvasLayout->addWidget(mMapCanvas);
@@ -3008,8 +3016,8 @@ void QgisApp::openProject(int pathIndex)
30083016
int myGreenInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorGreenPart",255);
30093017
int myBlueInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorBluePart",255);
30103018
QColor myColor = QColor(myRedInt,myGreenInt,myBlueInt);
3011-
mMapCanvas->setCanvasColor(myColor);
3012-
3019+
mMapCanvas->setCanvasColor(myColor); //this is fill colour before rendering starts
3020+
mMapCanvas->setBackgroundColor(myColor); // this is for the widget itself
30133021
}
30143022
//set the projections enabled icon in the status bar
30153023
int myProjectionEnabledFlag =
@@ -5161,7 +5169,8 @@ void QgisApp::projectProperties()
51615169
int myGreenInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorGreenPart",255);
51625170
int myBlueInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorBluePart",255);
51635171
QColor myColor = QColor(myRedInt,myGreenInt,myBlueInt);
5164-
mMapCanvas->setCanvasColor(myColor);
5172+
mMapCanvas->setCanvasColor(myColor); //this is fil colour before rendering onto canvas
5173+
mMapCanvas->setBackgroundColor(myColor); // this is for the widget itself
51655174
// Set the window title.
51665175
setTitleBarText_( *this );
51675176
// delete the property sheet object

‎src/gui/qgsoptions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ QgsOptions::QgsOptions(QWidget *parent, const char *name, bool modal) :
9494
// set the theme combo
9595
cmbTheme->setCurrentText(settings.readEntry("/Themes","default"));
9696
//set teh state of the checkboxes
97-
chkAntiAliasing->setChecked(settings.value("/qgis/enable_anti_aliasing").toBool());
98-
chkAddedVisibility->setChecked(!settings.value("/qgis/new_layers_visible").toBool());
99-
cbxHideSplash->setChecked(settings.value("/qgis/hideSplash").toBool());
97+
chkAntiAliasing->setChecked(settings.value("/qgis/enable_anti_aliasing",false).toBool());
98+
chkAddedVisibility->setChecked(!settings.value("/qgis/new_layers_visible",false).toBool());
99+
cbxHideSplash->setChecked(settings.value("/qgis/hideSplash",false).toBool());
100100
//set the colour for selections
101101
int myRed = settings.value("/qgis/default_selection_color_red",255).toInt();
102102
int myGreen = settings.value("/qgis/default_selection_color_green",255).toInt();

0 commit comments

Comments
 (0)
Please sign in to comment.