|
KiCad PCB EDA Suite
|
#include <settings_manager.h>
Public Member Functions | |
| SETTINGS_MANAGER () | |
| ~SETTINGS_MANAGER () | |
| bool | SettingsDirectoryValid () const |
| bool | IsOK () |
| void | SetKiway (KIWAY *aKiway) |
| Associate this setting manager with the given Kiway. | |
| template<typename T> | |
| T * | RegisterSettings (T *aSettings, bool aLoadNow=true) |
| Take ownership of the pointer passed in. | |
| void | Load () |
| void | Load (JSON_SETTINGS *aSettings) |
| void | Save () |
| void | Save (JSON_SETTINGS *aSettings) |
| void | FlushAndRelease (JSON_SETTINGS *aSettings, bool aSave=true) |
| If the given settings object is registered, save it to disk and unregister it. | |
| void | ResetToDefaults () |
| Reset all program settings to defaults. | |
| void | ClearFileHistory () |
| Clear saved file history from all settings files. | |
| template<typename T> | |
| T * | GetAppSettings (const char *aFilename) |
| Return a handle to the a given settings by type. | |
| template<typename T> | |
| T * | GetToolbarSettings (const wxString &aFilename) |
| Return a handle to the given toolbar settings. | |
| COLOR_SETTINGS * | GetColorSettings (const wxString &aName) |
| Retrieve a color settings object that applications can read colors from. | |
| std::vector< COLOR_SETTINGS * > | GetColorSettingsList () |
| void | SaveColorSettings (COLOR_SETTINGS *aSettings, const std::string &aNamespace="") |
| Safely save a COLOR_SETTINGS to disk, preserving any changes outside the given namespace. | |
| COLOR_SETTINGS * | AddNewColorSettings (const wxString &aFilename) |
| Register a new color settings object with the given filename. | |
| COLOR_SETTINGS * | GetMigratedColorSettings () |
| Return a color theme for storing colors migrated from legacy (5.x and earlier) settings, creating the theme if necessary. | |
| COMMON_SETTINGS * | GetCommonSettings () const |
| Retrieve the common settings shared by all applications. | |
| wxString | GetPathForSettingsFile (JSON_SETTINGS *aSettings) |
| Return the path a given settings file should be loaded from / stored to. | |
| bool | MigrateFromPreviousVersion (const wxString &aSourcePath) |
| Handle migration of the settings from previous KiCad versions. | |
| bool | GetPreviousVersionPaths (std::vector< wxString > *aName=nullptr) |
| Retrieve the name of the most recent previous KiCad version that can be found in the user settings directory. | |
| void | ReloadColorSettings () |
| Re-scan the color themes directory, reloading any changes it finds. | |
| bool | LoadProject (const wxString &aFullPath, bool aSetActive=true) |
| Load a project or sets up a new project with a specified path. | |
| bool | UnloadProject (PROJECT *aProject, bool aSave=true) |
| Save, unload and unregister the given PROJECT. | |
| bool | IsProjectOpen () const |
| Helper for checking if we have a project open. | |
| bool | IsProjectOpenNotDummy () const |
| Helper for checking if we have a project open that is not a dummy project. | |
| PROJECT & | Prj () const |
| A helper while we are not MDI-capable – return the one and only project. | |
| PROJECT * | GetProject (const wxString &aFullPath) const |
| Retrieve a loaded project by name. | |
| bool | IsProjectLoaded (PROJECT *aProject) const |
True if aProject is still owned by the manager. | |
| PROJECT * | GetProjectForPath (const wxString &aProjectPath) const |
Return the active project iff its path matches aProjectPath, else nullptr. | |
| std::vector< wxString > | GetOpenProjects () const |
| bool | SaveProject (const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr) |
| Save a loaded project. | |
| void | SaveProjectAs (const wxString &aFullPath, PROJECT *aProject=nullptr) |
| Set the currently loaded project path and saves it (pointers remain valid). | |
| bool | SaveProjectCopy (const wxString &aFullPath, PROJECT *aProject=nullptr) |
| Save a copy of the current project under the given path. | |
| wxString | GetProjectBackupsPath () const |
| wxString | GetBackupRootForProject (const PROJECT *aProject=nullptr) const |
| Resolve the backup root directory for a project, honoring the active BACKUP_LOCATION preference. | |
| wxString | GetLocalHistoryDirForProject (const PROJECT *aProject=nullptr) const |
| Resolve the local-history (.history) storage directory for a project. | |
| wxString | GetLocalHistoryDirForPath (const wxString &aProjectPath) const |
| Resolve the local-history directory for a project given by its on-disk path. | |
| wxString | GetAutosaveRootForProject (const PROJECT *aProject=nullptr) const |
| Resolve the autosave-files root for a project. | |
| bool | BackupProject (REPORTER &aReporter, wxFileName &aTarget) const |
| Create a backup archive of the current project. | |
| bool | TriggerBackupIfNeeded (REPORTER &aReporter) const |
| Call BackupProject() if a new backup is needed according to the current backup policy. | |
Static Public Member Functions | |
| static bool | IsSettingsPathValid (const wxString &aPath) |
| Check if a given path is probably a valid KiCad configuration directory. | |
| static wxString | GetColorSettingsPath () |
| Return the path where color scheme files are stored; creating it if missing (normally . | |
| static wxString | GetToolbarSettingsPath () |
| Return the path where toolbar configuration files are stored; creating it if missing (normally . | |
| static std::string | GetSettingsVersion () |
| Parse the current KiCad build version and extracts the major and minor revision to use as the name of the settings directory for this KiCad version. | |
| static wxString | GetUserSettingsPath () |
| A proxy for PATHS::GetUserSettingsPath() rather than fighting swig. | |
Private Member Functions | |
| JSON_SETTINGS * | registerSettings (JSON_SETTINGS *aSettings, bool aLoadNow=true) |
| COLOR_SETTINGS * | loadColorSettingsByName (const wxString &aName) |
| Attempt to load a color theme by name (the color theme directory and .json ext are assumed). | |
| COLOR_SETTINGS * | registerColorSettings (const wxString &aFilename, bool aAbsolutePath=false) |
| void | loadAllColorSettings () |
| const PROJECT & | resolveProject (const PROJECT *aProject) const |
| Pick the project to resolve a backup path against, falling back to Prj(). | |
| bool | loadProjectFile (PROJECT &aProject) |
| Register a PROJECT_FILE and attempt to load it from disk. | |
| bool | unloadProjectFile (PROJECT *aProject, bool aSave) |
| Optionally save, unload and unregister the given PROJECT_FILE. | |
| void | registerBuiltinColorSettings () |
Static Private Member Functions | |
| static int | compareVersions (const std::string &aFirst, const std::string &aSecond) |
| Compare two settings versions, like "5.99" and "6.0". | |
| static bool | extractVersion (const std::string &aVersionString, int *aMajor=nullptr, int *aMinor=nullptr) |
| Extract the numeric version from a given settings string. | |
| static wxString | projectKeySuffix (const PROJECT *aProject) |
| Build "<projectname>-<sha256prefix>" suffix used to disambiguate per-project subdirectories under the user data path. | |
Private Attributes | |
| KIWAY * | m_kiway |
| The kiway this settings manager interacts with. | |
| std::vector< std::unique_ptr< JSON_SETTINGS > > | m_settings |
| std::unordered_map< wxString, COLOR_SETTINGS * > | m_color_settings |
| std::unordered_map< size_t, JSON_SETTINGS * > | m_app_settings_cache |
| Cache for app settings. | |
| std::mutex | m_app_settings_mutex |
| COMMON_SETTINGS * | m_common_settings |
| bool | m_migrateLibraryTables |
| If true, the symbol and footprint library tables will be migrated from the previous version. | |
| bool | m_ok |
| True if settings loaded successfully at construction. | |
| std::vector< std::unique_ptr< PROJECT > > | m_projects_list |
| Loaded projects (ownership here). | |
| std::map< wxString, PROJECT * > | m_projects |
| Loaded projects, mapped according to project full name. | |
| std::map< wxString, PROJECT_FILE * > | m_project_files |
| Loaded project files, mapped according to project full name. | |
Static Private Attributes | |
| static wxString | backupDateTimeFormat = wxT( "%Y-%m-%d_%H%M%S" ) |
Definition at line 48 of file settings_manager.h.
| SETTINGS_MANAGER::SETTINGS_MANAGER | ( | ) |
Definition at line 58 of file settings_manager.cpp.
References PATHS::GetUserSettingsPath(), m_common_settings, m_kiway, m_migrateLibraryTables, m_ok, path, registerBuiltinColorSettings(), RegisterSettings(), SettingsDirectoryValid(), and traceSettings.
| SETTINGS_MANAGER::~SETTINGS_MANAGER | ( | ) |
Definition at line 91 of file settings_manager.cpp.
References m_color_settings, m_projects, m_projects_list, m_settings, and project.
| COLOR_SETTINGS * SETTINGS_MANAGER::AddNewColorSettings | ( | const wxString & | aFilename | ) |
Register a new color settings object with the given filename.
| aFilename | is the location to store the new settings object. |
Definition at line 374 of file settings_manager.cpp.
References registerColorSettings().
Referenced by FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), and PANEL_COLOR_SETTINGS::OnThemeChanged().
| bool SETTINGS_MANAGER::BackupProject | ( | REPORTER & | aReporter, |
| wxFileName & | aTarget ) const |
Create a backup archive of the current project.
| aReporter | is used for progress reporting. |
| aTarget | is the full path to the backup file. If empty, will generate and return the full path to the backup file. |
Definition at line 1528 of file settings_manager.cpp.
References PROJECT_ARCHIVER::Archive(), FILEEXT::ArchiveFileExtension, backupDateTimeFormat, PATHS::EnsurePathExists(), GetProjectBackupsPath(), Prj(), and traceSettings.
Referenced by TriggerBackupIfNeeded().
| void SETTINGS_MANAGER::ClearFileHistory | ( | ) |
Clear saved file history from all settings files.
Definition at line 127 of file settings_manager.cpp.
References GetPathForSettingsFile(), m_settings, path, and USER.
Referenced by PANEL_MAINTENANCE::onClearFileHistory().
|
staticprivate |
Compare two settings versions, like "5.99" and "6.0".
Definition at line 918 of file settings_manager.cpp.
References extractVersion(), and traceSettings.
Referenced by GetPreviousVersionPaths().
|
staticprivate |
Extract the numeric version from a given settings string.
| aVersionString | is the string to split at the ".". |
| aMajor | will store the first part. |
| aMinor | will store the second part. |
Definition at line 958 of file settings_manager.cpp.
Referenced by compareVersions(), and GetPreviousVersionPaths().
| void SETTINGS_MANAGER::FlushAndRelease | ( | JSON_SETTINGS * | aSettings, |
| bool | aSave = true ) |
If the given settings object is registered, save it to disk and unregister it.
| aSettings | is the object to release |
Definition at line 227 of file settings_manager.cpp.
References GetPathForSettingsFile(), m_app_settings_cache, m_settings, and traceSettings.
Referenced by BIN_MOD::End(), and unloadProjectFile().
Return a handle to the a given settings by type.
If the settings have already been loaded, returns the existing pointer. If the settings have not been loaded, creates a new object owned by the settings manager and returns a pointer to it.
| T | is a type derived from APP_SETTINGS_BASE. |
| aFilename | is used to find the correct settings under clang (where RTTI doesn't work across compile boundaries). |
Definition at line 124 of file settings_manager.h.
References m_app_settings_cache, m_app_settings_mutex, m_settings, and T.
Referenced by STARTWIZARD_PROVIDER_PRIVACY::ApplyDefaults(), LIBRARY_MANAGER::ApplyLibOverrides(), BOOST_AUTO_TEST_CASE(), LIBRARY_MANAGER::ClearLibOverride(), FOOTPRINT_EDIT_FRAME::config(), DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR(), STARTWIZARD_PROVIDER_PRIVACY::Finish(), PCB_BASE_FRAME::GetFootprintEditorSettings(), PCB_BASE_FRAME::GetPcbNewSettings(), PCB_BASE_FRAME::GetViewerSettingsBase(), gvconfig(), LIBRARY_MANAGER::LoadGlobalTables(), FOOTPRINT_PREVIEW_PANEL::New(), DIALOG_TEMPLATE_SELECTOR::OnFilterChanged(), LIBRARY_MANAGER::SetLibOverride(), and KIGFX::PCB_PAINTER::viewer_settings().
| wxString SETTINGS_MANAGER::GetAutosaveRootForProject | ( | const PROJECT * | aProject = nullptr | ) | const |
Resolve the autosave-files root for a project.
In PROJECT_DIR mode this is the project directory itself (autosave files are written as siblings with a "_autosave-" prefix in the filename). In USER_DIR mode it is a per-project subdirectory under the user data path that mirrors the project tree.
Definition at line 1505 of file settings_manager.cpp.
References GetCommonSettings(), PATHS::GetUserSettingsPath(), COMMON_SETTINGS::AUTO_BACKUP::location, location, COMMON_SETTINGS::m_Backup, project, PROJECT_DIR, projectKeySuffix(), and resolveProject().
Referenced by findAutosaveFilePairs(), and LOCAL_HISTORY::RunRegisteredSaversAsAutosaveFiles().
| wxString SETTINGS_MANAGER::GetBackupRootForProject | ( | const PROJECT * | aProject = nullptr | ) | const |
Resolve the backup root directory for a project, honoring the active BACKUP_LOCATION preference.
PROJECT_DIR yields the legacy "<projectpath>/<name>-backups/" path; USER_DIR yields a per-project subdirectory under the user data path keyed by SHA-256 of the project full path so identically-named projects do not collide.
| aProject | is the project whose backup root to resolve, or nullptr to use Prj(). |
Definition at line 1448 of file settings_manager.cpp.
References GetCommonSettings(), PATHS::GetUserSettingsPath(), COMMON_SETTINGS::AUTO_BACKUP::location, location, COMMON_SETTINGS::m_Backup, project, PROJECT_BACKUPS_DIR_SUFFIX, PROJECT_DIR, projectKeySuffix(), and resolveProject().
Referenced by GetProjectBackupsPath().
| COLOR_SETTINGS * SETTINGS_MANAGER::GetColorSettings | ( | const wxString & | aName | ) |
Retrieve a color settings object that applications can read colors from.
If the given settings file cannot be found, returns the default settings.
| aName | is the name of the color scheme to load. |
Definition at line 253 of file settings_manager.cpp.
References COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT, DEFAULT_THEME, loadColorSettingsByName(), m_color_settings, registerColorSettings(), JSON_SETTINGS::SetFilename(), and JSON_SETTINGS::SetReadOnly().
Referenced by GetColorSettings(), and PCB_TEST_FRAME_BASE::LoadSettings().
| std::vector< COLOR_SETTINGS * > SETTINGS_MANAGER::GetColorSettingsList | ( | ) |
Definition at line 292 of file settings_manager.cpp.
References m_color_settings.
|
static |
Return the path where color scheme files are stored; creating it if missing (normally .
/colors/ under the user settings path).
Definition at line 869 of file settings_manager.cpp.
References PATHS::GetUserSettingsPath(), path, and traceSettings.
Referenced by GetPathForSettingsFile(), loadAllColorSettings(), loadColorSettingsByName(), PANEL_COLOR_SETTINGS::OnBtnOpenThemeFolderClicked(), PANEL_COLOR_SETTINGS::OnThemeChanged(), and SaveColorSettings().
|
inline |
Retrieve the common settings shared by all applications.
Definition at line 258 of file settings_manager.h.
References m_common_settings.
Referenced by findAutosaveFilePairs(), GetAutosaveRootForProject(), GetBackupRootForProject(), GetLocalHistoryDirForPath(), GetLocalHistoryDirForProject(), LOCAL_HISTORY::RunRegisteredSaversAsAutosaveFiles(), PANEL_PLUGIN_SETTINGS::TransferDataFromWindow(), PANEL_PLUGIN_SETTINGS::TransferDataToWindow(), and TriggerBackupIfNeeded().
| wxString SETTINGS_MANAGER::GetLocalHistoryDirForPath | ( | const wxString & | aProjectPath | ) | const |
Resolve the local-history directory for a project given by its on-disk path.
In PROJECT_DIR mode the supplied path is used verbatim (so callers can target a project that is not the active one); in USER_DIR mode the keying defers to GetLocalHistoryDirForProject when aProjectPath matches the active project.
Definition at line 1492 of file settings_manager.cpp.
References GetCommonSettings(), GetLocalHistoryDirForProject(), GetProjectForPath(), and PROJECT_DIR.
Referenced by historyPath(), and historyPath().
| wxString SETTINGS_MANAGER::GetLocalHistoryDirForProject | ( | const PROJECT * | aProject = nullptr | ) | const |
Resolve the local-history (.history) storage directory for a project.
PROJECT_DIR yields "<projectpath>/.history/"; USER_DIR yields a per-project subdirectory under the user data path.
Definition at line 1468 of file settings_manager.cpp.
References GetCommonSettings(), PATHS::GetUserSettingsPath(), COMMON_SETTINGS::AUTO_BACKUP::location, location, COMMON_SETTINGS::m_Backup, project, PROJECT_DIR, projectKeySuffix(), and resolveProject().
Referenced by GetLocalHistoryDirForPath().
| COLOR_SETTINGS * SETTINGS_MANAGER::GetMigratedColorSettings | ( | ) |
Return a color theme for storing colors migrated from legacy (5.x and earlier) settings, creating the theme if necessary.
This theme will be called "user.json" / "User".
Definition at line 383 of file settings_manager.cpp.
References m_color_settings, registerColorSettings(), Save(), and COLOR_SETTINGS::SetName().
Referenced by EESCHEMA_SETTINGS::MigrateFromLegacy(), GERBVIEW_SETTINGS::MigrateFromLegacy(), and PCBNEW_SETTINGS::MigrateFromLegacy().
| std::vector< wxString > SETTINGS_MANAGER::GetOpenProjects | ( | ) | const |
Definition at line 1232 of file settings_manager.cpp.
References m_projects.
Referenced by KICAD_MANAGER_FRAME::canCloseWindow(), and KICAD_MANAGER_FRAME::SaveSettings().
| wxString SETTINGS_MANAGER::GetPathForSettingsFile | ( | JSON_SETTINGS * | aSettings | ) |
Return the path a given settings file should be loaded from / stored to.
| aSettings | is the settings object. |
Definition at line 526 of file settings_manager.cpp.
References COLORS, GetColorSettingsPath(), JSON_SETTINGS::GetLocation(), JSON_SETTINGS::GetOwningProject(), PROJECT::GetProjectPath(), GetToolbarSettingsPath(), PATHS::GetUserSettingsPath(), NONE, Prj(), PROJECT, TOOLBARS, and USER.
Referenced by STARTWIZARD_PROVIDER_SETTINGS::ApplyDefaults(), ClearFileHistory(), STARTWIZARD_PROVIDER_SETTINGS::Finish(), FlushAndRelease(), Load(), Load(), MigrateFromPreviousVersion(), PANEL_COLOR_SETTINGS::OnThemeChanged(), registerSettings(), ResetToDefaults(), Save(), and Save().
| bool SETTINGS_MANAGER::GetPreviousVersionPaths | ( | std::vector< wxString > * | aName = nullptr | ) |
Retrieve the name of the most recent previous KiCad version that can be found in the user settings directory.
For legacy versions (5.x, and 5.99 builds before this code was written), this will return "5.x".
| aName | is filled with the name of the previous version, if one exists. |
Definition at line 714 of file settings_manager.cpp.
References PATHS::CalculateUserSettingsPath(), compareVersions(), extractVersion(), GetSettingsVersion(), IsSettingsPathValid(), and traceSettings.
Referenced by PANEL_STARTWIZARD_SETTINGS::TransferDataToWindow().
| PROJECT * SETTINGS_MANAGER::GetProject | ( | const wxString & | aFullPath | ) | const |
Retrieve a loaded project by name.
| aFullPath | is the full path including name and extension to the project file. |
Definition at line 1223 of file settings_manager.cpp.
References m_projects.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOARD_INSPECTION_TOOL::CompareBoardWithHistory(), SCH_INSPECTION_TOOL::CompareSchematicWithHistory(), CLI::IMPORT_COMMAND::doPerform(), CLI::JOBSET_RUN_COMMAND::doPerform(), PCBNEW_JOBS_HANDLER::getBoard(), SCH::IFACE::HandleApiOpenDocument(), PCB::IFACE::handleOpenFootprint(), PCB::IFACE::handleOpenPcb(), EESCHEMA_JOBS_HANDLER::JobImport(), EESCHEMA_HELPERS::LoadSchematic(), LoadScratchDoc(), SCH::readSchematicFromFile(), SCRATCH_PROJECT::SCRATCH_PROJECT(), BOARD_INSPECTION_TOOL::showBoardComparison(), and SCH_INSPECTION_TOOL::showSchematicComparison().
| wxString SETTINGS_MANAGER::GetProjectBackupsPath | ( | ) | const |
Definition at line 1442 of file settings_manager.cpp.
References GetBackupRootForProject().
Referenced by BackupProject(), and TriggerBackupIfNeeded().
| PROJECT * SETTINGS_MANAGER::GetProjectForPath | ( | const wxString & | aProjectPath | ) | const |
Return the active project iff its path matches aProjectPath, else nullptr.
Lets backup/history helpers feed the right PROJECT* into per-project path resolvers without falling back to Prj() for an unrelated project.
Definition at line 1428 of file settings_manager.cpp.
References PROJECT::GetProjectPath(), IsProjectOpen(), and Prj().
Referenced by findAutosaveFilePairs(), GetLocalHistoryDirForPath(), and LOCAL_HISTORY::RunRegisteredSaversAsAutosaveFiles().
|
static |
Parse the current KiCad build version and extracts the major and minor revision to use as the name of the settings directory for this KiCad version.
Definition at line 911 of file settings_manager.cpp.
References GetMajorMinorVersion().
Referenced by GetPreviousVersionPaths().
Return a handle to the given toolbar settings.
If the settings have already been loaded, returns the existing pointer. If the settings have not been loaded, creates a new object owned by the settings manager and returns a pointer to it.
| T | is a type derived from TOOLBAR_SETTINGS. |
| aFilename | is used to find the correct settings under clang (where RTTI doesn't work across compile boundaries). |
Definition at line 180 of file settings_manager.h.
References m_settings, RegisterSettings(), and T.
Referenced by CVPCB_MAINFRAME::CVPCB_MAINFRAME(), and EVT_TOOL_RANGE().
|
static |
Return the path where toolbar configuration files are stored; creating it if missing (normally .
/toolbars/ under the user settings path).
Definition at line 890 of file settings_manager.cpp.
References PATHS::GetUserSettingsPath(), path, and traceSettings.
Referenced by GetPathForSettingsFile().
|
static |
A proxy for PATHS::GetUserSettingsPath() rather than fighting swig.
Definition at line 1766 of file settings_manager.cpp.
References PATHS::GetUserSettingsPath().
|
inline |
Definition at line 65 of file settings_manager.h.
References m_ok.
| bool SETTINGS_MANAGER::IsProjectLoaded | ( | PROJECT * | aProject | ) | const |
True if aProject is still owned by the manager.
Compares pointers only and never dereferences aProject, so it is safe to call with a possibly-stale pointer to guard against unloading a project that was evicted underneath us.
Definition at line 1114 of file settings_manager.cpp.
References m_projects_list.
Referenced by BOARD_INSPECTION_TOOL::CompareBoardWithHistory(), and SCH_INSPECTION_TOOL::CompareSchematicWithHistory().
| bool SETTINGS_MANAGER::IsProjectOpen | ( | ) | const |
Helper for checking if we have a project open.
Definition at line 1210 of file settings_manager.cpp.
References m_projects.
Referenced by PCB_BASE_EDIT_FRAME::doCloseWindow(), KICAD_MANAGER_FRAME::GetProjectFileName(), and GetProjectForPath().
| bool SETTINGS_MANAGER::IsProjectOpenNotDummy | ( | ) | const |
Helper for checking if we have a project open that is not a dummy project.
Definition at line 1216 of file settings_manager.cpp.
References m_projects.
Referenced by EESCHEMA_JOBS_HANDLER::JobImport().
|
static |
Check if a given path is probably a valid KiCad configuration directory.
Actually it just checks if a file called "kicad_common" exists, because that's probably good enough for now.
| aPath | is the path to check. |
Definition at line 856 of file settings_manager.cpp.
Referenced by GetPreviousVersionPaths(), and PANEL_STARTWIZARD_SETTINGS::validatePath().
| void SETTINGS_MANAGER::Load | ( | ) |
Definition at line 159 of file settings_manager.cpp.
References GetPathForSettingsFile(), and m_settings.
Referenced by STARTWIZARD_PROVIDER_SETTINGS::Finish(), fuzz_init(), init_unit_test(), PGM_BASE::InitPgm(), and LLVMFuzzerInitialize().
| void SETTINGS_MANAGER::Load | ( | JSON_SETTINGS * | aSettings | ) |
Definition at line 177 of file settings_manager.cpp.
References GetPathForSettingsFile(), and m_settings.
|
private |
Definition at line 403 of file settings_manager.cpp.
References COLOR_SETTINGS::COLOR_BUILTIN_CLASSIC, COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT, GetColorSettingsPath(), PATHS::GetDefault3rdPartyPath(), JSON_SETTINGS::GetFilename(), PGM_BASE::GetLocalEnvVariables(), COLOR_SETTINGS::GetName(), PATHS::GetStockDataPath(), ENV_VAR::GetVersionedEnvVarName(), m_color_settings, Pgm(), registerBuiltinColorSettings(), registerColorSettings(), COLOR_SETTINGS::SetName(), and JSON_SETTINGS::SetReadOnly().
Referenced by ReloadColorSettings().
|
private |
Attempt to load a color theme by name (the color theme directory and .json ext are assumed).
| aName | is the filename of the color theme (without the extension or path). |
Definition at line 306 of file settings_manager.cpp.
References GetColorSettingsPath(), JSON_SETTINGS::GetFilename(), m_color_settings, RegisterSettings(), and traceSettings.
Referenced by GetColorSettings().
| bool SETTINGS_MANAGER::LoadProject | ( | const wxString & | aFullPath, |
| bool | aSetActive = true ) |
Load a project or sets up a new project with a specified path.
| aFullPath | is the full path to the project. |
| aSetActive | if true will set the loaded project as the active project. |
Definition at line 988 of file settings_manager.cpp.
References LIBRARY_MANAGER::AbortAsyncLoads(), KIWAY::FACE_PCB, PGM_BASE::GetLibraryManager(), JSON_SETTINGS::LoadFromFile(), loadProjectFile(), m_kiway, m_projects, m_projects_list, path, Pgm(), PgmOrNull(), project, PROJECT_VAR_NAME, LIBRARY_MANAGER::ProjectChanged(), FILEEXT::ProjectFileExtension, RegisterSettings(), TEXT_EVAL_VCS::SetContextPath(), traceSettings, unloadProjectFile(), and LOCKFILE::Valid().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOARD_INSPECTION_TOOL::CompareBoardWithHistory(), SCH_INSPECTION_TOOL::CompareSchematicWithHistory(), KICAD_MANAGER_FRAME::CreateNewProject(), CLI::IMPORT_COMMAND::doPerform(), fuzz_init(), PCBNEW_JOBS_HANDLER::getBoard(), SCH::IFACE::HandleApiOpenDocument(), PCB::IFACE::handleOpenFootprint(), PCB::IFACE::handleOpenPcb(), init_unit_test(), PGM_BASE::InitPgm(), EESCHEMA_JOBS_HANDLER::JobImport(), LLVMFuzzerInitialize(), KI_TEST::LoadBoard(), loadEagleSchematic(), loadFixture(), KICAD_MANAGER_FRAME::LoadProject(), EESCHEMA_HELPERS::LoadSchematic(), KI_TEST::LoadSchematic(), LoadScratchDoc(), main(), SCH_EDIT_FRAME::OnImportProject(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH::readSchematicFromFile(), SCRATCH_PROJECT::SCRATCH_PROJECT(), BOARD_INSPECTION_TOOL::showBoardComparison(), SCH_INSPECTION_TOOL::showSchematicComparison(), UnloadProject(), and PROJECT_LOCAL_SETTINGS_FIXTURE::writeAndLoadProject().
|
private |
Register a PROJECT_FILE and attempt to load it from disk.
| aProject | is the project object to load the file for. |
Definition at line 1344 of file settings_manager.cpp.
References PROJECT::GetProjectFullName(), PROJECT_FILE::LoadFromFile(), m_project_files, path, RegisterSettings(), PROJECT_FILE::SetProject(), and PROJECT::setProjectFile().
Referenced by LoadProject().
| bool SETTINGS_MANAGER::MigrateFromPreviousVersion | ( | const wxString & | aSourcePath | ) |
Handle migration of the settings from previous KiCad versions.
Definition at line 658 of file settings_manager.cpp.
References DisplayErrorMessage(), MIGRATION_TRAVERSER::GetErrors(), GetPathForSettingsFile(), PATHS::GetUserSettingsPath(), JSON_SETTINGS::LoadFromFile(), COMMON_SETTINGS::m_Env, m_migrateLibraryTables, path, JSON_SETTINGS::SaveToFile(), traceSettings, and COMMON_SETTINGS::ENVIRONMENT::vars.
Referenced by STARTWIZARD_PROVIDER_SETTINGS::Finish().
| PROJECT & SETTINGS_MANAGER::Prj | ( | ) | const |
A helper while we are not MDI-capable – return the one and only project.
Definition at line 1195 of file settings_manager.cpp.
References m_projects_list, and traceSettings.
Referenced by BackupProject(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCB_NET_INSPECTOR_PANEL::buildColumns(), PCB_NET_INSPECTOR_PANEL::buildNetsList(), CLI::API_SERVER_COMMAND::doPerform(), filterFootprints(), PCBNEW_JOBS_HANDLER::getBoard(), SCHEMATIC_SETTINGS::GetJunctionSize(), GetPathForSettingsFile(), GetProjectForPath(), EESCHEMA_JOBS_HANDLER::getSchematic(), API_HANDLER_COMMON::handleExpandTextVariables(), API_HANDLER_COMMON::handleGetNetClasses(), API_HANDLER_COMMON::handleGetTextVariables(), API_HANDLER_COMMON::handleSetNetClasses(), API_HANDLER_COMMON::handleSetTextVariables(), PCB::IFACE::IfaceOrAddress(), EESCHEMA_JOBS_HANDLER::JobImport(), KI_TEST::LoadBoard(), loadEagleSchematic(), EESCHEMA_HELPERS::LoadSchematic(), KI_TEST::LoadSchematic(), LoadScratchDoc(), PCB_NET_INSPECTOR_PANEL::netFilterMatches(), PCB_NET_INSPECTOR_PANEL::OnBoardChanged(), PCB_NET_INSPECTOR_PANEL::OnConfigButton(), LIB_TREE::onDetailsLink(), PCB_EDIT_FRAME::OpenProjectFiles(), KIWAY::Prj(), resolveProject(), SaveProject(), SaveProjectAs(), SaveProjectCopy(), PCB_NET_INSPECTOR_PANEL::SaveSettings(), and TriggerBackupIfNeeded().
|
staticprivate |
Build "<projectname>-<sha256prefix>" suffix used to disambiguate per-project subdirectories under the user data path.
Returns an empty string if the project is null or has no full name yet (e.g., a fresh standalone editor).
Definition at line 1404 of file settings_manager.cpp.
References PROJECT::GetProjectFullName(), and PROJECT::GetProjectName().
Referenced by GetAutosaveRootForProject(), GetBackupRootForProject(), and GetLocalHistoryDirForProject().
|
private |
Definition at line 396 of file settings_manager.cpp.
References COLOR_SETTINGS::CreateBuiltinColorSettings(), m_color_settings, and RegisterSettings().
Referenced by loadAllColorSettings(), and SETTINGS_MANAGER().
|
private |
Definition at line 361 of file settings_manager.cpp.
References m_color_settings, and RegisterSettings().
Referenced by AddNewColorSettings(), GetColorSettings(), GetMigratedColorSettings(), and loadAllColorSettings().
|
inline |
Take ownership of the pointer passed in.
| aSettings | is a settings object to register. |
Definition at line 81 of file settings_manager.h.
References registerSettings(), and T.
Referenced by BMP2CMP::IFACE::CreateKiWindow(), fuzz_init(), GetToolbarSettings(), init_unit_test(), LLVMFuzzerInitialize(), loadColorSettingsByName(), LoadProject(), loadProjectFile(), PCB_TEST_FRAME_BASE::LoadSettings(), CV::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), PGE::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), PGM_KICAD::OnPgmInit(), registerBuiltinColorSettings(), registerColorSettings(), PCB_TEST_FRAME_BASE::SetBoard(), and SETTINGS_MANAGER().
|
private |
Definition at line 142 of file settings_manager.cpp.
References GetPathForSettingsFile(), m_settings, and traceSettings.
Referenced by RegisterSettings().
| void SETTINGS_MANAGER::ReloadColorSettings | ( | ) |
Re-scan the color themes directory, reloading any changes it finds.
Definition at line 479 of file settings_manager.cpp.
References loadAllColorSettings(), and m_color_settings.
Referenced by PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), and KICAD_MANAGER_CONTROL::ShowPluginManager().
| void SETTINGS_MANAGER::ResetToDefaults | ( | ) |
Reset all program settings to defaults.
Definition at line 107 of file settings_manager.cpp.
References COLORS, GetPathForSettingsFile(), m_settings, path, and USER.
Referenced by PANEL_MAINTENANCE::onResetAll().
Pick the project to resolve a backup path against, falling back to Prj().
Definition at line 1422 of file settings_manager.cpp.
References Prj().
Referenced by GetAutosaveRootForProject(), GetBackupRootForProject(), and GetLocalHistoryDirForProject().
| void SETTINGS_MANAGER::Save | ( | ) |
Definition at line 190 of file settings_manager.cpp.
References GetPathForSettingsFile(), and m_settings.
Referenced by STARTWIZARD_PROVIDER_PRIVACY::Finish(), GetMigratedColorSettings(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), EDA_BASE_FRAME::ShowPreferences(), PANEL_COMMON_SETTINGS::TransferDataFromWindow(), PANEL_MAINTENANCE::TransferDataFromWindow(), and SYMBOL_EDIT_FRAME::~SYMBOL_EDIT_FRAME().
| void SETTINGS_MANAGER::Save | ( | JSON_SETTINGS * | aSettings | ) |
Definition at line 211 of file settings_manager.cpp.
References GetPathForSettingsFile(), m_settings, and traceSettings.
| void SETTINGS_MANAGER::SaveColorSettings | ( | COLOR_SETTINGS * | aSettings, |
| const std::string & | aNamespace = "" ) |
Safely save a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
A color settings namespace is one of the top-level JSON objects like "board", etc. This will perform a read-modify-write
| aSettings | is a pointer to a valid COLOR_SETTINGS object managed by SETTINGS_MANAGER. |
| aNamespace | is the namespace of settings to save. |
Definition at line 486 of file settings_manager.cpp.
References JSON_SETTINGS::Contains(), GetColorSettingsPath(), JSON_SETTINGS::GetFilename(), JSON_SETTINGS::GetJson(), JSON_SETTINGS::Internals(), JSON_SETTINGS::IsReadOnly(), JSON_SETTINGS::Load(), JSON_SETTINGS::LoadFromFile(), m_color_settings, path, JSON_SETTINGS::SaveToFile(), JSON_SETTINGS::Store(), and traceSettings.
Referenced by EESCHEMA_SETTINGS::MigrateFromLegacy(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), GERBVIEW_SETTINGS::MigrateFromLegacy(), PCBNEW_SETTINGS::MigrateFromLegacy(), PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), PANEL_COLOR_SETTINGS::saveCurrentTheme(), GERBVIEW_FRAME::SaveSettings(), and BOARD_ADAPTER::SetLayerColors().
| bool SETTINGS_MANAGER::SaveProject | ( | const wxString & | aFullPath = wxEmptyString, |
| PROJECT * | aProject = nullptr ) |
Save a loaded project.
| aFullPath | is the project name to save. If empty, will save the first loaded project. |
| aProject | is the project to save, or nullptr to save the active project (Prj() return). |
Definition at line 1247 of file settings_manager.cpp.
References PROJECT::GetLocalSettings(), PROJECT::GetProjectFullName(), PROJECT::GetProjectPath(), PROJECT::IsReadOnly(), m_project_files, path, Prj(), project, and PROJECT_LOCAL_SETTINGS::SaveToFile().
Referenced by KICAD_MANAGER_FRAME::CloseProject(), KICAD_MANAGER_FRAME::CreateNewProject(), CLI::IMPORT_COMMAND::doPerform(), API_HANDLER_COMMON::handleSetTextVariables(), DIALOG_CONFIG_EQUFILES::OnOkClick(), SCH_EDIT_FRAME::OpenProjectFiles(), PROJECT::PinLibrary(), PCB_EDIT_FRAME::SavePcbFile(), SaveProjectAs(), PCB_EDIT_FRAME::SaveProjectLocalSettings(), SCH_EDIT_FRAME::saveProjectSettings(), SCH_EDIT_FRAME::ShowSchematicSetupDialog(), PROJECT::UnpinLibrary(), and SCH_API_SAVE::UpdateProjectFile().
| void SETTINGS_MANAGER::SaveProjectAs | ( | const wxString & | aFullPath, |
| PROJECT * | aProject = nullptr ) |
Set the currently loaded project path and saves it (pointers remain valid).
| aFullPath | is the full filename to set for the project. |
| aProject | is the project to save, or nullptr to save the active project (Prj() return). |
Definition at line 1274 of file settings_manager.cpp.
References PROJECT::GetLocalSettings(), PROJECT::GetProjectFullName(), PROJECT::IsReadOnly(), m_project_files, m_projects, Prj(), project, SaveProject(), PROJECT_LOCAL_SETTINGS::SaveToFile(), JSON_SETTINGS::SetFilename(), PROJECT::setProjectFullName(), and JSON_SETTINGS::SetReadOnly().
Referenced by HEADLESS_PCB_CONTEXT::SaveBoard(), HEADLESS_PCB_CONTEXT::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), and SCH_EDIT_FRAME::SaveProject().
| bool SETTINGS_MANAGER::SaveProjectCopy | ( | const wxString & | aFullPath, |
| PROJECT * | aProject = nullptr ) |
Save a copy of the current project under the given path.
| aFullPath | is the full filename to set for the project. |
| aProject | is the project to save, or nullptr to save the active project (Prj() return). |
Definition at line 1313 of file settings_manager.cpp.
References PROJECT::GetLocalSettings(), PROJECT::GetProjectFullName(), m_project_files, Prj(), project, PROJECT_LOCAL_SETTINGS::SaveToFile(), and JSON_SETTINGS::SetFilename().
Referenced by PCBNEW_JOBS_HANDLER::runPcbMerge(), PCB_EDIT_FRAME::SavePcbCopy(), SCH_EDIT_FRAME::SaveProject(), and SCH_API_SAVE::SaveSchematicCopy().
|
inline |
Associate this setting manager with the given Kiway.
| aKiway | is the kiway this settings manager should use |
Definition at line 72 of file settings_manager.h.
References m_kiway.
Referenced by PGM_KICAD::OnPgmInit().
| bool SETTINGS_MANAGER::SettingsDirectoryValid | ( | ) | const |
Definition at line 637 of file settings_manager.cpp.
References PATHS::GetUserSettingsPath(), path, and traceSettings.
Referenced by STARTWIZARD_PROVIDER_SETTINGS::NeedsUserInput(), and SETTINGS_MANAGER().
| bool SETTINGS_MANAGER::TriggerBackupIfNeeded | ( | REPORTER & | aReporter | ) | const |
Call BackupProject() if a new backup is needed according to the current backup policy.
| aReporter | is used for progress reporting. |
Definition at line 1592 of file settings_manager.cpp.
References PROJECT_ARCHIVER::AreZipArchivesIdentical(), backupDateTimeFormat, BackupProject(), delta, COMMON_SETTINGS::AUTO_BACKUP::enabled, PATHS::EnsurePathExists(), COMMON_SETTINGS::AUTO_BACKUP::format, GetCommonSettings(), GetProjectBackupsPath(), PROJECT::GetProjectName(), COMMON_SETTINGS::AUTO_BACKUP::limit_daily_files, COMMON_SETTINGS::AUTO_BACKUP::limit_total_files, COMMON_SETTINGS::AUTO_BACKUP::limit_total_size, COMMON_SETTINGS::m_Backup, COMMON_SETTINGS::AUTO_BACKUP::min_interval, Prj(), traceSettings, and ZIP.
Referenced by KICAD_MANAGER_FRAME::CloseProject().
| bool SETTINGS_MANAGER::UnloadProject | ( | PROJECT * | aProject, |
| bool | aSave = true ) |
Save, unload and unregister the given PROJECT.
| aProject | is the project object to unload. |
| aSave | if true will save the project before unloading. |
Definition at line 1127 of file settings_manager.cpp.
References LIBRARY_MANAGER::AbortAsyncLoads(), KIWAY::FACE_PCB, PGM_BASE::GetLibraryManager(), PROJECT::GetProjectFullName(), PATHS::GetUserSettingsPath(), LoadProject(), m_kiway, m_projects, m_projects_list, Pgm(), PgmOrNull(), PROJECT_VAR_NAME, TEXT_EVAL_VCS::SetContextPath(), traceSettings, and unloadProjectFile().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), KICAD_MANAGER_FRAME::CloseProject(), BOARD_INSPECTION_TOOL::CompareBoardWithHistory(), SCH_INSPECTION_TOOL::CompareSchematicWithHistory(), PCB_BASE_EDIT_FRAME::doCloseWindow(), CLI::IMPORT_COMMAND::doPerform(), EESCHEMA_JOBS_HANDLER::JobImport(), KI_TEST::LoadSchematic(), LoadScratchDoc(), SCH_EDIT_FRAME::OnImportProject(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), BOARD_INSPECTION_TOOL::showBoardComparison(), SCH_INSPECTION_TOOL::showSchematicComparison(), and SCH_EDIT_FRAME::~SCH_EDIT_FRAME().
|
private |
Optionally save, unload and unregister the given PROJECT_FILE.
| aProject | is the project object to unload the file for. |
| aSave | if true will save the project file before unloading. |
Definition at line 1362 of file settings_manager.cpp.
References FlushAndRelease(), PROJECT::GetLocalSettings(), PROJECT::GetProjectFullName(), PROJECT::GetProjectPath(), m_project_files, m_settings, name, PROJECT_FILE::ShouldAutoSave(), and PROJECT_LOCAL_SETTINGS::ShouldAutoSave().
Referenced by LoadProject(), and UnloadProject().
Definition at line 582 of file settings_manager.h.
Referenced by BackupProject(), and TriggerBackupIfNeeded().
|
private |
Cache for app settings.
Definition at line 561 of file settings_manager.h.
Referenced by FlushAndRelease(), and GetAppSettings().
|
private |
Definition at line 562 of file settings_manager.h.
Referenced by GetAppSettings().
|
private |
Definition at line 558 of file settings_manager.h.
Referenced by GetColorSettings(), GetColorSettingsList(), GetMigratedColorSettings(), loadAllColorSettings(), loadColorSettingsByName(), registerBuiltinColorSettings(), registerColorSettings(), ReloadColorSettings(), SaveColorSettings(), and ~SETTINGS_MANAGER().
|
private |
Definition at line 565 of file settings_manager.h.
Referenced by GetCommonSettings(), and SETTINGS_MANAGER().
|
private |
The kiway this settings manager interacts with.
Definition at line 554 of file settings_manager.h.
Referenced by LoadProject(), SetKiway(), SETTINGS_MANAGER(), and UnloadProject().
|
private |
If true, the symbol and footprint library tables will be migrated from the previous version.
Definition at line 568 of file settings_manager.h.
Referenced by MigrateFromPreviousVersion(), and SETTINGS_MANAGER().
|
private |
True if settings loaded successfully at construction.
Definition at line 571 of file settings_manager.h.
Referenced by IsOK(), and SETTINGS_MANAGER().
|
private |
Loaded project files, mapped according to project full name.
Definition at line 580 of file settings_manager.h.
Referenced by loadProjectFile(), SaveProject(), SaveProjectAs(), SaveProjectCopy(), and unloadProjectFile().
|
private |
Loaded projects, mapped according to project full name.
Definition at line 577 of file settings_manager.h.
Referenced by GetOpenProjects(), GetProject(), IsProjectOpen(), IsProjectOpenNotDummy(), LoadProject(), SaveProjectAs(), UnloadProject(), and ~SETTINGS_MANAGER().
|
private |
Loaded projects (ownership here).
Definition at line 574 of file settings_manager.h.
Referenced by IsProjectLoaded(), LoadProject(), Prj(), UnloadProject(), and ~SETTINGS_MANAGER().
|
private |
Definition at line 556 of file settings_manager.h.
Referenced by ClearFileHistory(), FlushAndRelease(), GetAppSettings(), GetToolbarSettings(), Load(), Load(), registerSettings(), ResetToDefaults(), Save(), Save(), unloadProjectFile(), and ~SETTINGS_MANAGER().