Skip to content

Commit

Permalink
Fixed handling global / project canvas color and selection color.
Browse files Browse the repository at this point in the history
Set default global selection color from white to yellow (as before).


git-svn-id: http://svn.osgeo.org/qgis/trunk@5007 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Mar 11, 2006
1 parent 930fd01 commit a4067da
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 61 deletions.
121 changes: 67 additions & 54 deletions src/gui/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ static void setTitleBarText_( QWidget & qgisApp )
createCanvas();
createOverview();
createLegend();

fileNew(); // prepare empty project

mSplash->showMessage("Checking database", Qt::AlignHCenter | Qt::AlignBottom);
qApp->processEvents();
Expand Down Expand Up @@ -1082,22 +1084,13 @@ void QgisApp::createCanvas()
// "theMapCanvas" used to find this canonical instance later
mMapCanvas = new QgsMapCanvas(this, "theMapCanvas" );
QWhatsThis::add(mMapCanvas, tr("Map canvas. This is where raster and vector layers are displayed when added to the map"));
//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->setMinimumWidth(10);
QVBoxLayout *myCanvasLayout = new QVBoxLayout;
myCanvasLayout->addWidget(mMapCanvas);
tabWidget->widget(0)->setLayout(myCanvasLayout);
// set the focus to the map canvas
mMapCanvas->setFocus();
pan(); // set map tool - panning
}

void QgisApp::createOverview()
Expand Down Expand Up @@ -2364,62 +2357,82 @@ void QgisApp::fileExit()

void QgisApp::fileNew()
{
int answer = saveDirty();

if (answer != QMessageBox::Cancel)
{
mMapCanvas->freeze(true);
QgsMapLayerRegistry::instance()->removeAllMapLayers();
mMapCanvas->clear();


QgsProject::instance()->title( QString::null );
QgsProject::instance()->filename( QString::null );

#ifdef QGISDEBUG
std::cout << "Clearing project properties" << std::endl;
#endif
QgsProject::instance()->clearProperties(); // why carry over properties from previous projects?
QgsProject::instance()->dirty(false);

setTitleBarText_( *this );
#ifdef QGISDEBUG
std::cout << "emiting new project signal" << std::endl ;
#endif
//note by Tim: I did some casual egrepping and this signal doesnt actually
//seem to be connected to anything....why is it here? Just for future needs?
emit newProject();

mMapCanvas->freeze(false);
}
//set the projections enabled icon in the status bar
int myProjectionEnabledFlag =
QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0);
projectionsEnabled(myProjectionEnabledFlag);
fileNew(TRUE); // prompts whether to save project
} // fileNew()


//as file new but accepts flags to indicate whether we should prompt to save
void QgisApp::fileNew(bool thePromptToSaveFlag)
{
{
if (thePromptToSaveFlag)
{
//just delegate this out
fileNew();
int answer = saveDirty();

if (answer == QMessageBox::Cancel)
{
return;
}
}
else
{
// mMapCanvas->clear();

#ifdef QGISDEBUG
std::cout << "erasing project" << std::endl;
#endif

mMapCanvas->freeze(true);
QgsMapLayerRegistry::instance()->removeAllMapLayers();
mMapCanvas->clear();

QgsProject* prj = QgsProject::instance();
prj->title( QString::null );
prj->filename( QString::null );
prj->clearProperties(); // why carry over properties from previous projects?

QSettings settings;

//set the colour for selections
//the default can be set in qgisoptions
//use project properties to override the colour on a per project basis
int myRed = settings.value("/qgis/default_selection_color_red",255).toInt();
int myGreen = settings.value("/qgis/default_selection_color_green",255).toInt();
int myBlue = settings.value("/qgis/default_selection_color_blue",0).toInt();
prj->writeEntry("Gui","/SelectionColorRedPart",myRed);
prj->writeEntry("Gui","/SelectionColorGreenPart",myGreen);
prj->writeEntry("Gui","/SelectionColorBluePart",myBlue);
QgsRenderer::mSelectionColor=QColor(myRed,myGreen,myBlue);

//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
myRed = settings.value("/qgis/default_canvas_color_red",255).toInt();
myGreen = settings.value("/qgis/default_canvas_color_green",255).toInt();
myBlue = settings.value("/qgis/default_canvas_color_blue",255).toInt();
prj->writeEntry("Gui","/CanvasColorRedPart",myRed);
prj->writeEntry("Gui","/CanvasColorGreenPart",myGreen);
prj->writeEntry("Gui","/CanvasColorBluePart",myBlue);
mMapCanvas->setCanvasColor(QColor(myRed,myGreen,myBlue));

prj->dirty(false);

QgsProject::instance()->title( QString::null );
QgsProject::instance()->filename( QString::null );
QgsProject::instance()->clearProperties(); // why carry over properties from previous projects?
QgsProject::instance()->dirty(false);
setTitleBarText_( *this );

#ifdef QGISDEBUG
std::cout << "emiting new project signal" << std::endl ;
#endif

setTitleBarText_( *this );
//note by Tim: I did some casual egrepping and this signal doesnt actually
//seem to be connected to anything....why is it here? Just for future needs?
//note by Martin: actually QgsComposer does use it
emit newProject();

mMapCanvas->freeze(false);
mMapCanvas->refresh();

//set the projections enabled icon in the status bar
int myProjectionEnabledFlag = prj->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0);
projectionsEnabled(myProjectionEnabledFlag);

pan(); // set map tool - panning

emit newProject();
}
} // QgisApp::fileNew(bool thePromptToSaveFlag)


Expand Down
6 changes: 0 additions & 6 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ QgsMapCanvas::QgsMapCanvas()
// create map canvas item which will show the map
mMap = new QgsMapCanvasMap(mCanvas, mMapRender);
mMap->show();

int myRedInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorRedPart",255);
int myGreenInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorGreenPart",255);
int myBlueInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorBluePart",255);
QColor myColor = QColor(myRedInt,myGreenInt,myBlueInt);
setCanvasColor(myColor);

moveCanvasContents(TRUE);

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
//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();
int myBlue = settings.value("/qgis/default_selection_color_blue",255).toInt();
int myBlue = settings.value("/qgis/default_selection_color_blue",0).toInt();
pbnSelectionColour->setPaletteBackgroundColor(QColor(myRed,myGreen,myBlue));
//set teh default color for canvas background
myRed = settings.value("/qgis/default_canvas_color_red",255).toInt();
Expand Down

0 comments on commit a4067da

Please sign in to comment.