@@ -233,6 +233,8 @@ static void setTitleBarText_( QWidget & qgisApp )
233
233
createCanvas ();
234
234
createOverview ();
235
235
createLegend ();
236
+
237
+ fileNew (); // prepare empty project
236
238
237
239
mSplash ->showMessage (" Checking database" , Qt::AlignHCenter | Qt::AlignBottom);
238
240
qApp->processEvents ();
@@ -1082,22 +1084,13 @@ void QgisApp::createCanvas()
1082
1084
// "theMapCanvas" used to find this canonical instance later
1083
1085
mMapCanvas = new QgsMapCanvas (this , " theMapCanvas" );
1084
1086
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
1093
1087
1094
1088
mMapCanvas ->setMinimumWidth (10 );
1095
1089
QVBoxLayout *myCanvasLayout = new QVBoxLayout;
1096
1090
myCanvasLayout->addWidget (mMapCanvas );
1097
1091
tabWidget->widget (0 )->setLayout (myCanvasLayout);
1098
1092
// set the focus to the map canvas
1099
1093
mMapCanvas ->setFocus ();
1100
- pan (); // set map tool - panning
1101
1094
}
1102
1095
1103
1096
void QgisApp::createOverview ()
@@ -2364,62 +2357,82 @@ void QgisApp::fileExit()
2364
2357
2365
2358
void QgisApp::fileNew ()
2366
2359
{
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
2399
2361
} // fileNew()
2400
2362
2401
2363
2402
2364
// as file new but accepts flags to indicate whether we should prompt to save
2403
2365
void QgisApp::fileNew (bool thePromptToSaveFlag)
2404
- {
2366
+ {
2405
2367
if (thePromptToSaveFlag)
2406
2368
{
2407
- // just delegate this out
2408
- fileNew ();
2369
+ int answer = saveDirty ();
2370
+
2371
+ if (answer == QMessageBox::Cancel)
2372
+ {
2373
+ return ;
2374
+ }
2409
2375
}
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 );
2413
2415
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
2418
2421
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
2420
2435
2421
- emit newProject ();
2422
- }
2423
2436
} // QgisApp::fileNew(bool thePromptToSaveFlag)
2424
2437
2425
2438
0 commit comments