static bool LoadProfile() { if (Profile::GetPath().IsNull() && !dlgStartupShowModal()) return false; Profile::Load(); Profile::Use(Profile::map); Units::SetConfig(CommonInterface::GetUISettings().format.units); SetUserCoordinateFormat(CommonInterface::GetUISettings().format.coordinate_format); return true; }
static bool LoadProfile() { if (StringIsEmpty(Profile::GetPath()) && !dlgStartupShowModal()) return false; Profile::Load(); Profile::Use(); Units::SetConfig(CommonInterface::GetUISettings().units); SetUserCoordinateFormat(CommonInterface::GetUISettings().coordinate_format); #ifdef HAVE_MODEL_TYPE global_model_type = CommonInterface::GetSystemSettings().model_type; #endif return true; }
static void SettingsLeave(const UISettings &old_ui_settings) { if (!global_running) return; SuspendAllThreads(); VerboseOperationEnvironment operation; MainWindow &main_window = *CommonInterface::main_window; if (LanguageChanged) ReadLanguageFile(); bool TerrainFileChanged = false, TopographyFileChanged = false; if (MapFileChanged) { /* set these flags, because they may be loaded from the map file */ AirspaceFileChanged = true; AirfieldFileChanged = true; WaypointFileChanged = true; TerrainFileChanged = true; TopographyFileChanged = true; } if (TerrainFileChanged) { operation.SetText(_("Loading Terrain File...")); /* just in case the bottom widget uses the old terrain object (e.g. the cross section) */ main_window.SetBottomWidget(nullptr); main_window.SetTerrain(NULL); glide_computer->SetTerrain(NULL); // re-load terrain delete terrain; terrain = RasterTerrain::OpenTerrain(file_cache, operation); main_window.SetTerrain(terrain); glide_computer->SetTerrain(terrain); /* re-create the bottom widget if it was deleted here */ PageActions::Update(); } if (WaypointFileChanged || AirfieldFileChanged) { // re-load waypoints WaypointGlue::LoadWaypoints(way_points, terrain, operation); WaypointDetails::ReadFileFromProfile(way_points, operation); } if (WaypointFileChanged && protected_task_manager != NULL) { ProtectedTaskManager::ExclusiveLease lease(*protected_task_manager); OrderedTask *task = lease->Clone(CommonInterface::GetComputerSettings().task); if (task) { // this must be done in thread lock because it potentially changes the // waypoints database task->CheckDuplicateWaypoints(way_points); /* XXX shall this task be committed if it has been modified? */ delete task; way_points.Optimise(); lease->FillMatPoints(way_points); } } if (WaypointFileChanged || TerrainFileChanged) { // re-set home WaypointGlue::SetHome(way_points, terrain, CommonInterface::SetComputerSettings().poi, CommonInterface::SetComputerSettings().team_code, device_blackboard, WaypointFileChanged); WaypointGlue::SaveHome(CommonInterface::GetComputerSettings().poi, CommonInterface::GetComputerSettings().team_code); } if (TopographyFileChanged) { main_window.SetTopography(NULL); topography->Reset(); LoadConfiguredTopography(*topography, operation); main_window.SetTopography(topography); } if (AirspaceFileChanged) { if (glide_computer != NULL) glide_computer->GetAirspaceWarnings().clear(); if (glide_computer != NULL) glide_computer->ClearAirspaces(); airspace_database.clear(); ReadAirspace(airspace_database, terrain, CommonInterface::GetComputerSettings().pressure, operation); } if (DevicePortChanged) devRestart(); const UISettings &ui_settings = CommonInterface::GetUISettings(); Units::SetConfig(ui_settings.units); SetUserCoordinateFormat(ui_settings.coordinate_format); const MapSettings &old_settings_map = old_ui_settings.map; const MapSettings &settings_map = ui_settings.map; if (settings_map.trail.type != old_settings_map.trail.type || settings_map.trail.scaling_enabled != old_settings_map.trail.scaling_enabled) main_window.SetLook().map.trail.Initialise(settings_map.trail); if (settings_map.waypoint.landable_style != old_settings_map.waypoint.landable_style) main_window.SetLook().map.waypoint.Initialise(settings_map.waypoint); ResumeAllThreads(); main_window.ResumeThreads(); // allow map and calculations threads to continue ActionInterface::SendMapSettings(true); AudioVarioGlue::Configure(CommonInterface::GetUISettings().sound.vario); operation.Hide(); InfoBoxManager::SetDirty(); main_window.FullRedraw(); main_window.SetDefaultFocus(); }