KiCad PCB EDA Suite
|
#include <settings_manager.h>
Public Member Functions | |
SETTINGS_MANAGER (bool aHeadless=false) | |
~SETTINGS_MANAGER () | |
bool | IsOK () |
void | SetKiway (KIWAY *aKiway) |
Associate this setting manager with the given Kiway. More... | |
template<typename T > | |
T * | RegisterSettings (T *aSettings, bool aLoadNow=true) |
Takes ownership of the pointer passed in. More... | |
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. More... | |
template<typename T > | |
T * | GetAppSettings () |
Returns a handle to the a given settings by type If the settings have already been loaded, returns the existing pointer. More... | |
COLOR_SETTINGS * | GetColorSettings (const wxString &aName="user") |
Retrieves a color settings object that applications can read colors from. More... | |
std::vector< COLOR_SETTINGS * > | GetColorSettingsList () |
void | SaveColorSettings (COLOR_SETTINGS *aSettings, const std::string &aNamespace="") |
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace. More... | |
COLOR_SETTINGS * | AddNewColorSettings (const wxString &aFilename) |
Registers a new color settings object with the given filename. More... | |
COLOR_SETTINGS * | GetMigratedColorSettings () |
Returns a color theme for storing colors migrated from legacy (5.x and earlier) settings, creating the theme if necessary. More... | |
COMMON_SETTINGS * | GetCommonSettings () const |
Retrieves the common settings shared by all applications. More... | |
wxString | GetPathForSettingsFile (JSON_SETTINGS *aSettings) |
Returns the path a given settings file should be loaded from / stored to. More... | |
bool | MigrateIfNeeded () |
Handles the initialization of the user settings directory and migration from previous KiCad versions as needed. More... | |
void | SetMigrationSource (const wxString &aSource) |
Helper for DIALOG_MIGRATE_SETTINGS to specify a source for migration. More... | |
void | SetMigrateLibraryTables (bool aMigrate=true) |
bool | GetPreviousVersionPaths (std::vector< wxString > *aName=nullptr) |
Retrieves the name of the most recent previous KiCad version that can be found in the user settings directory. More... | |
void | ReloadColorSettings () |
Re-scans the color themes directory, reloading any changes it finds. More... | |
bool | LoadProject (const wxString &aFullPath, bool aSetActive=true) |
Loads a project or sets up a new project with a specified path. More... | |
bool | UnloadProject (PROJECT *aProject, bool aSave=true) |
Saves, unloads and unregisters the given PROJECT. More... | |
bool | IsProjectOpen () const |
Helper for checking if we have a project open TODO: This should be deprecated along with Prj() once we support multiple projects fully. More... | |
PROJECT & | Prj () const |
A helper while we are not MDI-capable – return the one and only project. More... | |
PROJECT * | GetProject (const wxString &aFullPath) const |
Retrieves a loaded project by name. More... | |
std::vector< wxString > | GetOpenProjects () const |
bool | SaveProject (const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr) |
Saves a loaded project. More... | |
void | SaveProjectAs (const wxString &aFullPath, PROJECT *aProject=nullptr) |
Sets the currently loaded project path and saves it (pointers remain valid) Note that this will not modify the read-only state of the project, so it will have no effect if the project is marked as read-only! More... | |
void | SaveProjectCopy (const wxString &aFullPath, PROJECT *aProject=nullptr) |
Saves a copy of the current project under the given path. More... | |
wxString | GetProjectBackupsPath () const |
bool | BackupProject (REPORTER &aReporter) const |
Creates a backup archive of the current project. More... | |
bool | TriggerBackupIfNeeded (REPORTER &aReporter) const |
Calls BackupProject if a new backup is needed according to the current backup policy. More... | |
Static Public Member Functions | |
static bool | IsSettingsPathValid (const wxString &aPath) |
Checks if a given path is probably a valid KiCad configuration directory. More... | |
static wxString | GetColorSettingsPath () |
Returns the path where color scheme files are stored; creating it if missing (normally . More... | |
static wxString | GetUserSettingsPath () |
Return the user configuration path used to store KiCad's configuration files. More... | |
static std::string | GetSettingsVersion () |
Parses 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. More... | |
Private Member Functions | |
JSON_SETTINGS * | registerSettings (JSON_SETTINGS *aSettings, bool aLoadNow=true) |
COLOR_SETTINGS * | loadColorSettingsByName (const wxString &aName) |
Attempts to load a color theme by name (the color theme directory and .json ext are assumed) More... | |
COLOR_SETTINGS * | registerColorSettings (const wxString &aFilename, bool aAbsolutePath=false) |
void | loadAllColorSettings () |
bool | loadProjectFile (PROJECT &aProject) |
Registers a PROJECT_FILE and attempts to load it from disk. More... | |
bool | unloadProjectFile (PROJECT *aProject, bool aSave) |
Optionally saves, and then unloads and unregisters the given PROJECT_FILE. More... | |
void | registerBuiltinColorSettings () |
Static Private Member Functions | |
static wxString | calculateUserSettingsPath (bool aIncludeVer=true, bool aUseEnv=true) |
Determines the base path for user settings files. More... | |
static int | compareVersions (const std::string &aFirst, const std::string &aSecond) |
Compares two settings versions, like "5.99" and "6.0". More... | |
static bool | extractVersion (const std::string &aVersionString, int *aMajor=nullptr, int *aMinor=nullptr) |
Extracts the numeric version from a given settings string. More... | |
Private Attributes | |
bool | m_headless |
True if running outside a UI context. More... | |
KIWAY * | m_kiway |
The kiway this settings manager interacts with. More... | |
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. More... | |
COMMON_SETTINGS * | m_common_settings |
wxString | m_migration_source |
bool | m_migrateLibraryTables |
If true, the symbol and footprint library tables will be migrated from the previous version. More... | |
bool | m_ok |
True if settings loaded successfully at construction. More... | |
std::vector< std::unique_ptr< PROJECT > > | m_projects_list |
Loaded projects (ownership here) More... | |
std::map< wxString, PROJECT * > | m_projects |
Loaded projects, mapped according to project full name. More... | |
std::map< wxString, PROJECT_FILE * > | m_project_files |
Loaded project files, mapped according to project full name. More... | |
std::unique_ptr< LOCKFILE > | m_project_lock |
Lock for loaded project (expand to multiple once we support MDI) More... | |
Static Private Attributes | |
static wxString | backupDateTimeFormat = wxT( "%Y-%m-%d_%H%M%S" ) |
Definition at line 44 of file settings_manager.h.
SETTINGS_MANAGER::SETTINGS_MANAGER | ( | bool | aHeadless = false | ) |
Definition at line 51 of file settings_manager.cpp.
References m_common_settings, m_ok, MigrateIfNeeded(), registerBuiltinColorSettings(), and RegisterSettings().
SETTINGS_MANAGER::~SETTINGS_MANAGER | ( | ) |
Definition at line 75 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 | ) |
Registers a new color settings object with the given filename.
aFilename | is the location to store the new settings object |
Definition at line 299 of file settings_manager.cpp.
References registerColorSettings().
Referenced by FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), COLOR_SETTINGS::migrateSchema0to1(), and PANEL_COLOR_SETTINGS::OnThemeChanged().
bool SETTINGS_MANAGER::BackupProject | ( | REPORTER & | aReporter | ) | const |
Creates a backup archive of the current project.
aReporter | is used for progress reporting |
Definition at line 1186 of file settings_manager.cpp.
References PROJECT_ARCHIVER::Archive(), ArchiveFileExtension, backupDateTimeFormat, GetProjectBackupsPath(), Prj(), and traceSettings.
Referenced by TriggerBackupIfNeeded().
|
staticprivate |
Determines the base path for user settings files.
The configuration path order of precedence is determined by the following criteria:
aIncludeVer | will append the current KiCad version if true (default) |
aUseEnv | will prefer the base path found in the KICAD_CONFIG_DIR if found (default) |
Definition at line 776 of file settings_manager.cpp.
References GetSettingsVersion(), KIPLATFORM::ENV::GetUserConfigPath(), and TO_STR.
Referenced by GetPreviousVersionPaths(), and GetUserSettingsPath().
|
staticprivate |
Compares two settings versions, like "5.99" and "6.0".
Definition at line 809 of file settings_manager.cpp.
References extractVersion(), and traceSettings.
Referenced by GetPreviousVersionPaths().
|
staticprivate |
Extracts 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 848 of file settings_manager.cpp.
Referenced by compareVersions().
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 168 of file settings_manager.cpp.
References GetPathForSettingsFile(), m_app_settings_cache, m_settings, and traceSettings.
Referenced by unloadProjectFile().
|
inline |
Returns 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 |
aLoadNow | is true to load the registered file from disk immediately |
Definition at line 99 of file settings_manager.h.
References m_app_settings_cache, and m_settings.
Referenced by SYMBOL_EDIT_FRAME::CommonSettingsChanged(), PL_EDITOR_FRAME::CommonSettingsChanged(), PCB::IFACE::CreateKiWindow(), PCB_TEST_FRAME_BASE::createView(), GRID_CELL_LAYER_RENDERER::Draw(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), EVT_TOOL_RANGE(), PCB_EDITOR_CONDITIONS::get45degModeFunc(), SCH_BASE_FRAME::GetColorSettings(), SYMBOL_EDIT_FRAME::GetColorSettings(), GERBVIEW_FRAME::GetColorSettings(), PCB_LAYER_BOX_SELECTOR::getLayerColor(), PCB_TOOL_BASE::Is45Limited(), LIB_PIN::LIB_PIN(), FP_LIB_TABLE::LoadGlobalTable(), SYMBOL_LIB_TABLE::LoadGlobalTable(), PCB_VIEWER_TOOLS::MeasureTool(), PANEL_PACKAGES_VIEW::OnDownloadVersionClicked(), DIALOG_PCM::OnManageRepositoriesClicked(), PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS(), PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), PANEL_GERBVIEW_COLOR_SETTINGS::PANEL_GERBVIEW_COLOR_SETTINGS(), PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS(), PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL(), DIALOG_PLOT::Plot(), EDA_3D_CANVAS::RenderEngineChanged(), SaveFileAs(), PCB_TEST_FRAME_BASE::SetBoard(), DRAWING_TOOL::ToggleHV45Mode(), PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow(), PANEL_EESCHEMA_ANNOTATION_OPTIONS::TransferDataFromWindow(), PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow(), PANEL_SYM_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow(), PANEL_GERBVIEW_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_PCM_SETTINGS::TransferDataFromWindow(), PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_EDIT_OPTIONS::TransferDataFromWindow(), PANEL_FP_EDITOR_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_FP_EDITOR_DEFAULTS::TransferDataFromWindow(), PANEL_PCBNEW_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_3D_RAYTRACING_OPTIONS::TransferDataToWindow(), PANEL_EESCHEMA_ANNOTATION_OPTIONS::TransferDataToWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow(), PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow(), PANEL_SYM_EDITING_OPTIONS::TransferDataToWindow(), PANEL_PCM_SETTINGS::TransferDataToWindow(), PANEL_DISPLAY_OPTIONS::TransferDataToWindow(), PANEL_EDIT_OPTIONS::TransferDataToWindow(), PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow(), and DRAWING_TOOL::UpdateStatusBar().
COLOR_SETTINGS * SETTINGS_MANAGER::GetColorSettings | ( | const wxString & | aName = "user" | ) |
Retrieves 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 193 of file settings_manager.cpp.
References COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT, loadColorSettingsByName(), m_color_settings, registerColorSettings(), JSON_SETTINGS::SetFilename(), and JSON_SETTINGS::SetReadOnly().
Referenced by PL_EDITOR_FRAME::CommonSettingsChanged(), GRID_CELL_LAYER_RENDERER::Draw(), DIALOG_PLOT_SCHEMATIC::getColorSettings(), SCH_BASE_FRAME::GetColorSettings(), SYMBOL_EDIT_FRAME::GetColorSettings(), GERBVIEW_FRAME::GetColorSettings(), PCB_LAYER_BOX_SELECTOR::getLayerColor(), PCBNEW_JOBS_HANDLER::JobExportPdf(), PANEL_EESCHEMA_EDITING_OPTIONS::loadEEschemaSettings(), PCB_TEST_FRAME_BASE::LoadSettings(), PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS(), PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), PANEL_GERBVIEW_COLOR_SETTINGS::PANEL_GERBVIEW_COLOR_SETTINGS(), PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS(), PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL(), PCB_PLOT_SVG::Plot(), SCH_PLOTTER::Plot(), DIALOG_PLOT::Plot(), SCH_PRINTOUT::PrintPage(), PANEL_COLOR_SETTINGS::saveCurrentTheme(), and PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow().
|
inline |
Definition at line 139 of file settings_manager.h.
References m_color_settings.
Referenced by DIALOG_PLOT_SCHEMATIC::initDlg(), PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow(), and DIALOG_PRINT_PCBNEW::TransferDataToWindow().
|
static |
Returns the path where color scheme files are stored; creating it if missing (normally .
/colors/ under the user settings path)
Definition at line 744 of file settings_manager.cpp.
References GetUserSettingsPath(), path, and traceSettings.
Referenced by GetPathForSettingsFile(), loadAllColorSettings(), loadColorSettingsByName(), PANEL_COLOR_SETTINGS::OnBtnOpenThemeFolderClicked(), PANEL_COLOR_SETTINGS::OnThemeChanged(), and SaveColorSettings().
|
inline |
Retrieves the common settings shared by all applications.
Definition at line 183 of file settings_manager.h.
References m_common_settings.
Referenced by TriggerBackupIfNeeded().
COLOR_SETTINGS * SETTINGS_MANAGER::GetMigratedColorSettings | ( | ) |
Returns 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 308 of file settings_manager.cpp.
References m_color_settings, registerColorSettings(), Save(), and COLOR_SETTINGS::SetName().
std::vector< wxString > SETTINGS_MANAGER::GetOpenProjects | ( | ) | const |
Definition at line 1020 of file settings_manager.cpp.
References m_projects.
Referenced by KICAD_MANAGER_FRAME::canCloseWindow().
wxString SETTINGS_MANAGER::GetPathForSettingsFile | ( | JSON_SETTINGS * | aSettings | ) |
Returns the path a given settings file should be loaded from / stored to.
aSettings | is the settings object |
Definition at line 419 of file settings_manager.cpp.
References GetColorSettingsPath(), JSON_SETTINGS::GetLocation(), PROJECT::GetProjectPath(), GetUserSettingsPath(), and Prj().
Referenced by FlushAndRelease(), Load(), MigrateIfNeeded(), PANEL_COLOR_SETTINGS::OnThemeChanged(), registerSettings(), Save(), and unloadProjectFile().
bool SETTINGS_MANAGER::GetPreviousVersionPaths | ( | std::vector< wxString > * | aName = nullptr | ) |
Retrieves 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 620 of file settings_manager.cpp.
References calculateUserSettingsPath(), compareVersions(), GetSettingsVersion(), IsSettingsPathValid(), and traceSettings.
Referenced by DIALOG_MIGRATE_SETTINGS::TransferDataToWindow().
PROJECT * SETTINGS_MANAGER::GetProject | ( | const wxString & | aFullPath | ) | const |
Retrieves a loaded project by name.
aFullPath | is the full path including name and extension to the project file |
Definition at line 1011 of file settings_manager.cpp.
References m_projects.
Referenced by EESCHEMA_HELPERS::GetDefaultProject(), GetDefaultProject(), LoadBoard(), EESCHEMA_HELPERS::LoadSchematic(), NewBoard(), DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction(), and DIALOG_BOARD_SETUP::onAuxiliaryAction().
wxString SETTINGS_MANAGER::GetProjectBackupsPath | ( | ) | const |
Definition at line 1177 of file settings_manager.cpp.
References PROJECT::GetProjectName(), PROJECT::GetProjectPath(), Prj(), and PROJECT_BACKUPS_DIR_SUFFIX.
Referenced by BackupProject(), and TriggerBackupIfNeeded().
|
static |
Parses 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 802 of file settings_manager.cpp.
References GetMajorMinorVersion().
Referenced by calculateUserSettingsPath(), GetPreviousVersionPaths(), PATHS::GetUserCachePath(), PATHS::getUserDocumentPath(), and DIALOG_MIGRATE_SETTINGS::TransferDataToWindow().
|
static |
Return the user configuration path used to store KiCad's configuration files.
NOTE: The path is cached at startup, it will never change during program lifetime!
Definition at line 765 of file settings_manager.cpp.
References calculateUserSettingsPath().
Referenced by getAdvancedCfgFilename(), GetColorSettingsPath(), SYMBOL_LIB_TABLE::GetGlobalTableFileName(), FP_LIB_TABLE::GetGlobalTableFileName(), GetPathForSettingsFile(), MigrateIfNeeded(), COMMON_SETTINGS::migrateSchema2to3(), PLUGIN_CONTENT_MANAGER::PLUGIN_CONTENT_MANAGER(), ReadHotKeyConfig(), ReadLegacyHotkeyConfigFile(), PLUGIN_CONTENT_MANAGER::SaveInstalledPackages(), and WriteHotKeyConfig().
|
inline |
Definition at line 54 of file settings_manager.h.
References m_ok.
bool SETTINGS_MANAGER::IsProjectOpen | ( | ) | const |
Helper for checking if we have a project open TODO: This should be deprecated along with Prj() once we support multiple projects fully.
Definition at line 1005 of file settings_manager.cpp.
References m_projects.
Referenced by FOOTPRINT_EDIT_FRAME::doCloseWindow(), and PCB_BASE_EDIT_FRAME::doCloseWindow().
|
static |
Checks 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 731 of file settings_manager.cpp.
Referenced by GetPreviousVersionPaths(), and DIALOG_MIGRATE_SETTINGS::validatePath().
void SETTINGS_MANAGER::Load | ( | ) |
Definition at line 107 of file settings_manager.cpp.
References GetPathForSettingsFile(), and m_settings.
Referenced by PGM_BASE::InitPgm(), SCH::IFACE::OnKifaceStart(), and PCB::IFACE::OnKifaceStart().
void SETTINGS_MANAGER::Load | ( | JSON_SETTINGS * | aSettings | ) |
Definition at line 126 of file settings_manager.cpp.
References GetPathForSettingsFile(), and m_settings.
|
private |
Definition at line 328 of file settings_manager.cpp.
References GetColorSettingsPath(), PATHS::GetDefault3rdPartyPath(), Pgm(), registerBuiltinColorSettings(), registerColorSettings(), and JSON_SETTINGS::SetReadOnly().
Referenced by ReloadColorSettings().
|
private |
Attempts 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 232 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 |
||
) |
Loads 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 878 of file settings_manager.cpp.
References LegacyProjectFileExtension, JSON_SETTINGS::LoadFromFile(), loadProjectFile(), m_kiway, m_project_lock, m_projects, m_projects_list, path, project, KIWAY::ProjectChanged(), ProjectFileExtension, RegisterSettings(), traceSettings, unloadProjectFile(), and LOCKFILE::Valid().
Referenced by KICAD_MANAGER_FRAME::CreateNewProject(), EESCHEMA_HELPERS::GetDefaultProject(), GetDefaultProject(), PGM_BASE::InitPgm(), KI_TEST::LoadBoard(), LoadBoard(), KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic(), KI_TEST::LoadSchematic(), EESCHEMA_HELPERS::LoadSchematic(), NewBoard(), DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction(), DIALOG_BOARD_SETUP::onAuxiliaryAction(), SCH_EDIT_FRAME::OnImportProject(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), TEST_NGSPICE_HELPERS::TEST_NGSPICE_HELPERS(), and UnloadProject().
|
private |
Registers a PROJECT_FILE and attempts to load it from disk.
aProject | is the project object to load the file for |
Definition at line 1123 of file settings_manager.cpp.
References PROJECT::GetProjectFullName(), JSON_SETTINGS::LoadFromFile(), m_project_files, path, RegisterSettings(), PROJECT_FILE::SetProject(), and PROJECT::setProjectFile().
Referenced by LoadProject().
bool SETTINGS_MANAGER::MigrateIfNeeded | ( | ) |
Handles the initialization of the user settings directory and migration from previous KiCad versions as needed.
This method will check for the existence of the user settings path for this KiCad version. If it exists, settings load will proceed normally using that path.
If that directory is empty or does not exist, the migration wizard will be launched, which will give users the option to migrate settings from a previous KiCad version (if one is found), manually specify a directory to migrate fromm, or start with default settings.
Definition at line 522 of file settings_manager.cpp.
References DisplayErrorMessage(), MIGRATION_TRAVERSER::GetErrors(), GetPathForSettingsFile(), GetUserSettingsPath(), JSON_SETTINGS::LoadFromFile(), COMMON_SETTINGS::m_Env, m_headless, m_migrateLibraryTables, m_migration_source, path, JSON_SETTINGS::SaveToFile(), traceSettings, and COMMON_SETTINGS::ENVIRONMENT::vars.
Referenced by SETTINGS_MANAGER().
PROJECT & SETTINGS_MANAGER::Prj | ( | ) | const |
A helper while we are not MDI-capable – return the one and only project.
Definition at line 997 of file settings_manager.cpp.
References m_projects_list.
Referenced by BackupProject(), PCB_EDIT_FRAME::Files_io_from_id(), GetPathForSettingsFile(), GetProjectBackupsPath(), KI_TEST::LoadBoard(), KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic(), KI_TEST::LoadSchematic(), PCB_EDIT_FRAME::OpenProjectFiles(), SaveProject(), SaveProjectAs(), SaveProjectCopy(), TEST_NGSPICE_HELPERS::TEST_NGSPICE_HELPERS(), TriggerBackupIfNeeded(), and WriteDRCReport().
|
private |
Definition at line 321 of file settings_manager.cpp.
References COLOR_SETTINGS::CreateBuiltinColorSettings(), m_color_settings, and RegisterSettings().
Referenced by loadAllColorSettings(), and SETTINGS_MANAGER().
|
private |
Definition at line 286 of file settings_manager.cpp.
References m_color_settings, and RegisterSettings().
Referenced by AddNewColorSettings(), GetColorSettings(), GetMigratedColorSettings(), and loadAllColorSettings().
|
private |
Definition at line 91 of file settings_manager.cpp.
References GetPathForSettingsFile(), m_settings, and traceSettings.
Referenced by RegisterSettings().
|
inline |
Takes ownership of the pointer passed in.
aSettings | is a settings object to register |
Definition at line 69 of file settings_manager.h.
References registerSettings().
Referenced by loadColorSettingsByName(), LoadProject(), loadProjectFile(), PCB_TEST_FRAME_BASE::LoadSettings(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), PGM_SINGLE_TOP::OnPgmInit(), PGM_KICAD::OnPgmInit(), registerBuiltinColorSettings(), registerColorSettings(), PCB_TEST_FRAME_BASE::SetBoard(), and SETTINGS_MANAGER().
void SETTINGS_MANAGER::ReloadColorSettings | ( | ) |
Re-scans the color themes directory, reloading any changes it finds.
Definition at line 372 of file settings_manager.cpp.
References loadAllColorSettings(), and m_color_settings.
Referenced by PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS().
void SETTINGS_MANAGER::Save | ( | ) |
Definition at line 139 of file settings_manager.cpp.
References GetPathForSettingsFile(), and m_settings.
Referenced by GetMigratedColorSettings(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), and COLOR_SETTINGS::migrateSchema0to1().
void SETTINGS_MANAGER::Save | ( | JSON_SETTINGS * | aSettings | ) |
Definition at line 152 of file settings_manager.cpp.
References GetPathForSettingsFile(), m_settings, and traceSettings.
void SETTINGS_MANAGER::SaveColorSettings | ( | COLOR_SETTINGS * | aSettings, |
const std::string & | aNamespace = "" |
||
) |
Safely saves 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 379 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 FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), and PANEL_COLOR_SETTINGS::saveCurrentTheme().
bool SETTINGS_MANAGER::SaveProject | ( | const wxString & | aFullPath = wxEmptyString , |
PROJECT * | aProject = nullptr |
||
) |
Saves 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 1031 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(), SCH_EDIT_FRAME::OpenProjectFiles(), SaveProjectAs(), PCB_EDIT_FRAME::SaveProjectLocalSettings(), and SCH_EDIT_FRAME::saveProjectSettings().
void SETTINGS_MANAGER::SaveProjectAs | ( | const wxString & | aFullPath, |
PROJECT * | aProject = nullptr |
||
) |
Sets the currently loaded project path and saves it (pointers remain valid) Note that this will not modify the read-only state of the project, so it will have no effect if the project is marked as read-only!
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 1058 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 SaveBoard(), PCB_EDIT_FRAME::SavePcbFile(), and SCH_EDIT_FRAME::SaveProject().
void SETTINGS_MANAGER::SaveProjectCopy | ( | const wxString & | aFullPath, |
PROJECT * | aProject = nullptr |
||
) |
Saves a copy of the current project under the given path.
Will save the copy even if the current project is marked as read-only.
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 1097 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 PCB_EDIT_FRAME::SavePcbCopy(), and SCH_EDIT_FRAME::SaveProject().
|
inline |
Associate this setting manager with the given Kiway.
aKiway | is the kiway this settings manager should use |
Definition at line 61 of file settings_manager.h.
References m_kiway.
Referenced by PGM_SINGLE_TOP::OnPgmInit(), and PGM_KICAD::OnPgmInit().
|
inline |
Definition at line 213 of file settings_manager.h.
References m_migrateLibraryTables.
Referenced by DIALOG_MIGRATE_SETTINGS::TransferDataFromWindow().
|
inline |
Helper for DIALOG_MIGRATE_SETTINGS to specify a source for migration.
aSource | is a directory containing settings files to migrate from (can be empty) |
Definition at line 211 of file settings_manager.h.
References m_migration_source.
Referenced by DIALOG_MIGRATE_SETTINGS::TransferDataFromWindow().
bool SETTINGS_MANAGER::TriggerBackupIfNeeded | ( | REPORTER & | aReporter | ) | const |
Calls BackupProject if a new backup is needed according to the current backup policy.
aReporter | is used for progress reporting |
Definition at line 1248 of file settings_manager.cpp.
References backupDateTimeFormat, BackupProject(), delta, COMMON_SETTINGS::AUTO_BACKUP::enabled, 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(), and traceSettings.
Referenced by KICAD_MANAGER_FRAME::CloseProject(), SCH_EDIT_FRAME::doAutoSave(), and PCB_EDIT_FRAME::doAutoSave().
bool SETTINGS_MANAGER::UnloadProject | ( | PROJECT * | aProject, |
bool | aSave = true |
||
) |
Saves, unloads and unregisters the given PROJECT.
aProject | is the project object to unload |
aSave | if true will save the project before unloading |
Definition at line 956 of file settings_manager.cpp.
References PROJECT::GetProjectFullName(), LoadProject(), m_kiway, m_project_lock, m_projects, m_projects_list, PROJECT_VAR_NAME, KIWAY::ProjectChanged(), traceSettings, and unloadProjectFile().
Referenced by KICAD_MANAGER_FRAME::CloseProject(), PCB_BASE_EDIT_FRAME::doCloseWindow(), PCB_EDIT_FRAME::Files_io_from_id(), KI_TEST::LoadSchematic(), DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction(), DIALOG_BOARD_SETUP::onAuxiliaryAction(), SCH_EDIT_FRAME::OnImportProject(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::~SCH_EDIT_FRAME().
|
private |
Optionally saves, and then unloads and unregisters 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 1141 of file settings_manager.cpp.
References FlushAndRelease(), PROJECT::GetLocalSettings(), GetPathForSettingsFile(), PROJECT::GetProjectFullName(), m_project_files, m_settings, and name.
Referenced by LoadProject(), and UnloadProject().
|
staticprivate |
Definition at line 453 of file settings_manager.h.
Referenced by BackupProject(), and TriggerBackupIfNeeded().
|
private |
Cache for app settings.
Definition at line 428 of file settings_manager.h.
Referenced by FlushAndRelease(), and GetAppSettings().
|
private |
Definition at line 425 of file settings_manager.h.
Referenced by GetColorSettings(), GetColorSettingsList(), GetMigratedColorSettings(), loadColorSettingsByName(), registerBuiltinColorSettings(), registerColorSettings(), ReloadColorSettings(), SaveColorSettings(), and ~SETTINGS_MANAGER().
|
private |
Definition at line 431 of file settings_manager.h.
Referenced by GetCommonSettings(), and SETTINGS_MANAGER().
|
private |
True if running outside a UI context.
Definition at line 418 of file settings_manager.h.
Referenced by MigrateIfNeeded().
|
private |
The kiway this settings manager interacts with.
Definition at line 421 of file settings_manager.h.
Referenced by LoadProject(), SetKiway(), and UnloadProject().
|
private |
If true, the symbol and footprint library tables will be migrated from the previous version.
Definition at line 436 of file settings_manager.h.
Referenced by MigrateIfNeeded(), and SetMigrateLibraryTables().
|
private |
Definition at line 433 of file settings_manager.h.
Referenced by MigrateIfNeeded(), and SetMigrationSource().
|
private |
True if settings loaded successfully at construction.
Definition at line 439 of file settings_manager.h.
Referenced by IsOK(), and SETTINGS_MANAGER().
|
private |
Loaded project files, mapped according to project full name.
Definition at line 448 of file settings_manager.h.
Referenced by loadProjectFile(), SaveProject(), SaveProjectAs(), SaveProjectCopy(), and unloadProjectFile().
|
private |
Lock for loaded project (expand to multiple once we support MDI)
Definition at line 451 of file settings_manager.h.
Referenced by LoadProject(), and UnloadProject().
|
private |
Loaded projects, mapped according to project full name.
Definition at line 445 of file settings_manager.h.
Referenced by GetOpenProjects(), GetProject(), IsProjectOpen(), LoadProject(), SaveProjectAs(), UnloadProject(), and ~SETTINGS_MANAGER().
|
private |
Loaded projects (ownership here)
Definition at line 442 of file settings_manager.h.
Referenced by LoadProject(), Prj(), UnloadProject(), and ~SETTINGS_MANAGER().
|
private |
Definition at line 423 of file settings_manager.h.
Referenced by FlushAndRelease(), GetAppSettings(), Load(), registerSettings(), Save(), unloadProjectFile(), and ~SETTINGS_MANAGER().