Skip to content

Commit 4a387f1

Browse files
author
wonder
committedMar 11, 2006
Fixed handling global / project canvas color and selection color.
Set default global selection color from white to yellow (as before). git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5007 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

3 files changed

+68
-61
lines changed

3 files changed

+68
-61
lines changed
 

‎src/gui/qgisapp.cpp

Lines changed: 67 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ static void setTitleBarText_( QWidget & qgisApp )
233233
createCanvas();
234234
createOverview();
235235
createLegend();
236+
237+
fileNew(); // prepare empty project
236238

237239
mSplash->showMessage("Checking database", Qt::AlignHCenter | Qt::AlignBottom);
238240
qApp->processEvents();
@@ -1082,22 +1084,13 @@ void QgisApp::createCanvas()
10821084
// "theMapCanvas" used to find this canonical instance later
10831085
mMapCanvas = new QgsMapCanvas(this, "theMapCanvas" );
10841086
QWhatsThis::add(mMapCanvas, tr("Map canvas. This is where raster and vector layers are displayed when added to the map"));
1085-
//set the canvas to the default background colour
1086-
//the default can be set in qgisoptions
1087-
//use project properties to override the colour on a per project basis
1088-
QSettings mySettings;
1089-
int myRed = mySettings.value("/qgis/default_canvas_color_red",255).toInt();
1090-
int myGreen = mySettings.value("/qgis/default_canvas_color_green",255).toInt();
1091-
int myBlue = mySettings.value("/qgis/default_canvas_color_blue",255).toInt();
1092-
mMapCanvas->setCanvasColor(QColor(myRed,myGreen,myBlue)); // this is the fill co;our when rendering
10931087

10941088
mMapCanvas->setMinimumWidth(10);
10951089
QVBoxLayout *myCanvasLayout = new QVBoxLayout;
10961090
myCanvasLayout->addWidget(mMapCanvas);
10971091
tabWidget->widget(0)->setLayout(myCanvasLayout);
10981092
// set the focus to the map canvas
10991093
mMapCanvas->setFocus();
1100-
pan(); // set map tool - panning
11011094
}
11021095

11031096
void QgisApp::createOverview()
@@ -2364,62 +2357,82 @@ void QgisApp::fileExit()
23642357

23652358
void QgisApp::fileNew()
23662359
{
2367-
int answer = saveDirty();
2368-
2369-
if (answer != QMessageBox::Cancel)
2370-
{
2371-
mMapCanvas->freeze(true);
2372-
QgsMapLayerRegistry::instance()->removeAllMapLayers();
2373-
mMapCanvas->clear();
2374-
2375-
2376-
QgsProject::instance()->title( QString::null );
2377-
QgsProject::instance()->filename( QString::null );
2378-
2379-
#ifdef QGISDEBUG
2380-
std::cout << "Clearing project properties" << std::endl;
2381-
#endif
2382-
QgsProject::instance()->clearProperties(); // why carry over properties from previous projects?
2383-
QgsProject::instance()->dirty(false);
2384-
2385-
setTitleBarText_( *this );
2386-
#ifdef QGISDEBUG
2387-
std::cout << "emiting new project signal" << std::endl ;
2388-
#endif
2389-
//note by Tim: I did some casual egrepping and this signal doesnt actually
2390-
//seem to be connected to anything....why is it here? Just for future needs?
2391-
emit newProject();
2392-
2393-
mMapCanvas->freeze(false);
2394-
}
2395-
//set the projections enabled icon in the status bar
2396-
int myProjectionEnabledFlag =
2397-
QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0);
2398-
projectionsEnabled(myProjectionEnabledFlag);
2360+
fileNew(TRUE); // prompts whether to save project
23992361
} // fileNew()
24002362

24012363

24022364
//as file new but accepts flags to indicate whether we should prompt to save
24032365
void QgisApp::fileNew(bool thePromptToSaveFlag)
2404-
{
2366+
{
24052367
if (thePromptToSaveFlag)
24062368
{
2407-
//just delegate this out
2408-
fileNew();
2369+
int answer = saveDirty();
2370+
2371+
if (answer == QMessageBox::Cancel)
2372+
{
2373+
return;
2374+
}
24092375
}
2410-
else
2411-
{
2412-
// mMapCanvas->clear();
2376+
2377+
#ifdef QGISDEBUG
2378+
std::cout << "erasing project" << std::endl;
2379+
#endif
2380+
2381+
mMapCanvas->freeze(true);
2382+
QgsMapLayerRegistry::instance()->removeAllMapLayers();
2383+
mMapCanvas->clear();
2384+
2385+
QgsProject* prj = QgsProject::instance();
2386+
prj->title( QString::null );
2387+
prj->filename( QString::null );
2388+
prj->clearProperties(); // why carry over properties from previous projects?
2389+
2390+
QSettings settings;
2391+
2392+
//set the colour for selections
2393+
//the default can be set in qgisoptions
2394+
//use project properties to override the colour on a per project basis
2395+
int myRed = settings.value("/qgis/default_selection_color_red",255).toInt();
2396+
int myGreen = settings.value("/qgis/default_selection_color_green",255).toInt();
2397+
int myBlue = settings.value("/qgis/default_selection_color_blue",0).toInt();
2398+
prj->writeEntry("Gui","/SelectionColorRedPart",myRed);
2399+
prj->writeEntry("Gui","/SelectionColorGreenPart",myGreen);
2400+
prj->writeEntry("Gui","/SelectionColorBluePart",myBlue);
2401+
QgsRenderer::mSelectionColor=QColor(myRed,myGreen,myBlue);
2402+
2403+
//set the canvas to the default background colour
2404+
//the default can be set in qgisoptions
2405+
//use project properties to override the colour on a per project basis
2406+
myRed = settings.value("/qgis/default_canvas_color_red",255).toInt();
2407+
myGreen = settings.value("/qgis/default_canvas_color_green",255).toInt();
2408+
myBlue = settings.value("/qgis/default_canvas_color_blue",255).toInt();
2409+
prj->writeEntry("Gui","/CanvasColorRedPart",myRed);
2410+
prj->writeEntry("Gui","/CanvasColorGreenPart",myGreen);
2411+
prj->writeEntry("Gui","/CanvasColorBluePart",myBlue);
2412+
mMapCanvas->setCanvasColor(QColor(myRed,myGreen,myBlue));
2413+
2414+
prj->dirty(false);
24132415

2414-
QgsProject::instance()->title( QString::null );
2415-
QgsProject::instance()->filename( QString::null );
2416-
QgsProject::instance()->clearProperties(); // why carry over properties from previous projects?
2417-
QgsProject::instance()->dirty(false);
2416+
setTitleBarText_( *this );
2417+
2418+
#ifdef QGISDEBUG
2419+
std::cout << "emiting new project signal" << std::endl ;
2420+
#endif
24182421

2419-
setTitleBarText_( *this );
2422+
//note by Tim: I did some casual egrepping and this signal doesnt actually
2423+
//seem to be connected to anything....why is it here? Just for future needs?
2424+
//note by Martin: actually QgsComposer does use it
2425+
emit newProject();
2426+
2427+
mMapCanvas->freeze(false);
2428+
mMapCanvas->refresh();
2429+
2430+
//set the projections enabled icon in the status bar
2431+
int myProjectionEnabledFlag = prj->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0);
2432+
projectionsEnabled(myProjectionEnabledFlag);
2433+
2434+
pan(); // set map tool - panning
24202435

2421-
emit newProject();
2422-
}
24232436
} // QgisApp::fileNew(bool thePromptToSaveFlag)
24242437

24252438

‎src/gui/qgsmapcanvas.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ QgsMapCanvas::QgsMapCanvas()
113113
// create map canvas item which will show the map
114114
mMap = new QgsMapCanvasMap(mCanvas, mMapRender);
115115
mMap->show();
116-
117-
int myRedInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorRedPart",255);
118-
int myGreenInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorGreenPart",255);
119-
int myBlueInt = QgsProject::instance()->readNumEntry("Gui","/CanvasColorBluePart",255);
120-
QColor myColor = QColor(myRedInt,myGreenInt,myBlueInt);
121-
setCanvasColor(myColor);
122116

123117
moveCanvasContents(TRUE);
124118

‎src/gui/qgsoptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
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();
103-
int myBlue = settings.value("/qgis/default_selection_color_blue",255).toInt();
103+
int myBlue = settings.value("/qgis/default_selection_color_blue",0).toInt();
104104
pbnSelectionColour->setPaletteBackgroundColor(QColor(myRed,myGreen,myBlue));
105105
//set teh default color for canvas background
106106
myRed = settings.value("/qgis/default_canvas_color_red",255).toInt();

0 commit comments

Comments
 (0)
Please sign in to comment.