Skip to content

Commit

Permalink
Improvements for setting the background colour of the canvas. It now …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
timlinux committed Jan 13, 2006
1 parent a8e5f46 commit 31494eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 15 additions & 6 deletions src/gui/qgisapp.cpp
Expand Up @@ -270,8 +270,6 @@ static void setTitleBarText_( QWidget & qgisApp )
mQgisInterface = new QgisIface(this);
// set the legend control for the map canvas
mMapCanvas->setLegend(mMapLegend);
QSettings mySettings;
mMapCanvas->enableAntiAliasing(mySettings.value("/qgis/enable_anti_aliasing").toBool());


//
Expand Down Expand Up @@ -1059,7 +1057,17 @@ void QgisApp::createCanvas()
// "theMapCanvas" used to find this canonical instance later
mMapCanvas = new QgsMapCanvas(NULL, "theMapCanvas" );
QWhatsThis::add(mMapCanvas, tr("Map canvas. This is where raster and vector layers are displayed when added to the map"));
mMapCanvas->setBackgroundColor(Qt::white); //QColor (220, 235, 255));
//set the canvas to the default background colour
//the default can be set in qgisoptions
//use project properties to override the colour on a per project basis
QSettings mySettings;
int myRed = mySettings.value("/qgis/default_canvas_color_red",255).toInt();
int myGreen = mySettings.value("/qgis/default_canvas_color_green",255).toInt();
int myBlue = mySettings.value("/qgis/default_canvas_color_blue",255).toInt();
mMapCanvas->setCanvasColor(QColor(myRed,myGreen,myBlue)); // this is the fill co;our when rendering
mMapCanvas->setBackgroundColor(QColor(myRed,myGreen,myBlue)); // this is for the widget itself

mMapCanvas->enableAntiAliasing(mySettings.value("/qgis/enable_anti_aliasing",false).toBool());
mMapCanvas->setMinimumWidth(400);
QVBoxLayout *myCanvasLayout = new QVBoxLayout;
myCanvasLayout->addWidget(mMapCanvas);
Expand Down Expand Up @@ -3008,8 +3016,8 @@ void QgisApp::openProject(int pathIndex)
int myGreenInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorGreenPart",255);
int myBlueInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorBluePart",255);
QColor myColor = QColor(myRedInt,myGreenInt,myBlueInt);
mMapCanvas->setCanvasColor(myColor);
mMapCanvas->setCanvasColor(myColor); //this is fill colour before rendering starts
mMapCanvas->setBackgroundColor(myColor); // this is for the widget itself
}
//set the projections enabled icon in the status bar
int myProjectionEnabledFlag =
Expand Down Expand Up @@ -5161,7 +5169,8 @@ void QgisApp::projectProperties()
int myGreenInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorGreenPart",255);
int myBlueInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorBluePart",255);
QColor myColor = QColor(myRedInt,myGreenInt,myBlueInt);
mMapCanvas->setCanvasColor(myColor);
mMapCanvas->setCanvasColor(myColor); //this is fil colour before rendering onto canvas
mMapCanvas->setBackgroundColor(myColor); // this is for the widget itself
// Set the window title.
setTitleBarText_( *this );
// delete the property sheet object
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsoptions.cpp
Expand Up @@ -94,9 +94,9 @@ QgsOptions::QgsOptions(QWidget *parent, const char *name, bool modal) :
// set the theme combo
cmbTheme->setCurrentText(settings.readEntry("/Themes","default"));
//set teh state of the checkboxes
chkAntiAliasing->setChecked(settings.value("/qgis/enable_anti_aliasing").toBool());
chkAddedVisibility->setChecked(!settings.value("/qgis/new_layers_visible").toBool());
cbxHideSplash->setChecked(settings.value("/qgis/hideSplash").toBool());
chkAntiAliasing->setChecked(settings.value("/qgis/enable_anti_aliasing",false).toBool());
chkAddedVisibility->setChecked(!settings.value("/qgis/new_layers_visible",false).toBool());
cbxHideSplash->setChecked(settings.value("/qgis/hideSplash",false).toBool());
//set the colour for selections
int myRed = settings.value("/qgis/default_selection_color_red",255).toInt();
int myGreen = settings.value("/qgis/default_selection_color_green",255).toInt();
Expand Down

0 comments on commit 31494eb

Please sign in to comment.