25#include <wx/filename.h>
26#include <wx/snglinst.h>
27#include <wx/stdpaths.h>
52 m_headless( aHeadless ),
54 m_common_settings( nullptr ),
56 m_migrateLibraryTables( true )
77 if( !wxFileExists( commonSettings.GetFullPath() ) )
91 for( std::unique_ptr<JSON_SETTINGS>& settings :
m_settings )
102 std::unique_ptr<JSON_SETTINGS> ptr( aSettings );
104 ptr->SetManager(
this );
106 wxLogTrace(
traceSettings, wxT(
"Registered new settings object <%s>" ),
107 ptr->GetFullFilename() );
122 std::vector<JSON_SETTINGS*> toLoad;
126 []( std::unique_ptr<JSON_SETTINGS>& aSettings )
128 return aSettings.get();
139 [&aSettings](
const std::unique_ptr<JSON_SETTINGS>& aPtr )
141 return aPtr.get() == aSettings;
165 [&aSettings](
const std::unique_ptr<JSON_SETTINGS>& aPtr )
167 return aPtr.get() == aSettings;
172 wxLogTrace(
traceSettings, wxT(
"Saving %s" ), ( *it )->GetFullFilename() );
181 [&aSettings](
const std::unique_ptr<JSON_SETTINGS>& aPtr )
183 return aPtr.get() == aSettings;
188 wxLogTrace(
traceSettings, wxT(
"Flush and release %s" ), ( *it )->GetFullFilename() );
193 size_t typeHash =
typeid( *it->get() ).hash_code();
211 [&aName](
const std::pair<wxString, COLOR_SETTINGS*>& p )
213 return p.second->GetName().Lower() == aName.Lower();
244 wxLogTrace(
traceSettings, wxT(
"Attempting to load color theme %s" ), aName );
248 if( !fn.IsOk() || !fn.Exists() )
250 wxLogTrace(
traceSettings, wxT(
"Theme file %s.json not found, falling back to user" ),
257 if( settings->
GetFilename() != aName.ToStdString() )
259 wxLogTrace(
traceSettings, wxT(
"Warning: stored filename is actually %s, " ),
280 wxDirTraverseResult
OnFile(
const wxString& aFilePath )
override
282 wxFileName file( aFilePath );
284 if( file.GetExt() == wxS(
"json" ) )
287 return wxDIR_CONTINUE;
290 wxDirTraverseResult
OnDir(
const wxString& dirPath )
override
292 return wxDIR_CONTINUE;
312 if( aName.EndsWith( wxT(
".json" ) ) )
324 settings->
SetName( wxT(
"User" ) );
344 wxFileName third_party_path;
346 auto it = env.find( wxS(
"KICAD7_3RD_PARTY" ) );
348 if( it != env.end() && !it->second.GetValue().IsEmpty() )
349 third_party_path.SetPath( it->second.GetValue() );
353 third_party_path.AppendDir( wxS(
"colors" ) );
356 wxDir third_party_colors_dir( third_party_path.GetFullPath() );
371 [&](
const wxFileName& aFilename )
377 if( system_colors_dir.IsOpened() )
378 system_colors_dir.Traverse( readOnlyLoader );
380 if( third_party_colors_dir.IsOpened() )
381 third_party_colors_dir.Traverse( readOnlyLoader );
383 if( colors_dir.IsOpened() )
384 colors_dir.Traverse( loader );
399 [aSettings] (
const std::pair<wxString, COLOR_SETTINGS*>& el )
401 return el.second->GetFilename() == aSettings->GetFilename();
408 if( !aSettings->
Store() )
410 wxLogTrace(
traceSettings, wxT(
"Color scheme %s not modified; skipping save" ),
415 wxASSERT( aSettings->
Contains( aNamespace ) );
417 wxLogTrace(
traceSettings, wxT(
"Saving color scheme %s, preserving %s" ),
421 std::optional<nlohmann::json> backup = aSettings->
GetJson( aNamespace );
427 ( *aSettings->
Internals() )[aNamespace].update( *backup );
437 wxASSERT( aSettings );
441 case SETTINGS_LOC::USER:
444 case SETTINGS_LOC::PROJECT:
448 case SETTINGS_LOC::COLORS:
451 case SETTINGS_LOC::NONE:
455 wxASSERT_MSG(
false, wxT(
"Unknown settings location!" ) );
480 wxDirTraverseResult
OnFile(
const wxString& aSrcFilePath )
override
482 wxFileName file( aSrcFilePath );
485 file.GetName() == wxT(
"fp-lib-table" ) ) )
487 return wxDIR_CONTINUE;
491 if( file.GetFullName() == wxT(
"installed_packages.json" ) )
492 return wxDIR_CONTINUE;
496 if( file.GetExt() == wxT(
"hotkeys" ) )
497 return wxDIR_CONTINUE;
499 wxString
path = file.GetPath();
502 file.SetPath(
path );
504 wxLogTrace(
traceSettings, wxT(
"Copying %s to %s" ), aSrcFilePath, file.GetFullPath() );
509 return wxDIR_CONTINUE;
512 wxDirTraverseResult
OnDir(
const wxString& dirPath )
override
514 wxFileName dir( dirPath );
517 if( dir.GetName() == wxS(
"colors" ) ||
518 dir.GetName() == wxS(
"3d" ) )
521 wxString
path = dir.GetPath();
526 wxMkdir( dir.GetFullPath() );
528 return wxDIR_CONTINUE;
541 wxLogTrace(
traceSettings, wxT(
"Using settings path %s" ),
path.GetFullPath() );
549 if( !
path.DirExists() )
551 wxLogTrace(
traceSettings, wxT(
"Path didn't exist; creating it" ) );
552 path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
555 wxLogTrace(
traceSettings, wxT(
"Settings migration not checked; running headless" ) );
559 if(
path.DirExists() )
561 wxFileName common =
path;
562 common.SetName( wxS(
"kicad_common" ) );
563 common.SetExt( wxS(
"json" ) );
565 if( common.Exists() )
567 wxLogTrace(
traceSettings, wxT(
"Path exists and has a kicad_common, continuing!" ) );
575 if( dlg.ShowModal() != wxID_OK )
577 wxLogTrace(
traceSettings, wxT(
"Migration dialog canceled; exiting" ) );
581 if( !
path.DirExists() )
583 wxLogTrace(
traceSettings, wxT(
"Path didn't exist; creating it" ) );
584 path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
589 wxLogTrace(
traceSettings, wxT(
"No migration source given; starting with defaults" ) );
598 source_dir.Traverse( traverser );
610 const std::vector<wxString> libKeys = {
611 wxT(
"KICAD6_SYMBOL_DIR" ),
612 wxT(
"KICAD6_3DMODEL_DIR" ),
613 wxT(
"KICAD6_FOOTPRINT_DIR" ),
614 wxT(
"KICAD6_TEMPLATE_DIR" ),
615 wxT(
"KICAD7_SYMBOL_DIR" ),
616 wxT(
"KICAD7_3DMODEL_DIR" ),
617 wxT(
"KICAD7_FOOTPRINT_DIR" ),
618 wxT(
"KICAD7_TEMPLATE_DIR" ),
619 wxT(
"KICAD8_SYMBOL_DIR" ),
620 wxT(
"KICAD8_3DMODEL_DIR" ),
621 wxT(
"KICAD8_FOOTPRINT_DIR" ),
622 wxT(
"KICAD8_TEMPLATE_DIR" ),
625 wxT(
"KICAD_PTEMPLATES" ),
628 wxT(
"KICAD_SYMBOL_DIR" ),
631 for(
const wxString& key : libKeys )
648 std::vector<wxFileName> base_paths;
653 if( wxGetEnv( wxT(
"KICAD_CONFIG_HOME" ),
nullptr ) )
664 wxFileName wxGtkPath;
665 wxGtkPath.AssignDir( wxS(
"~/.config/kicad" ) );
666 wxGtkPath.MakeAbsolute();
667 base_paths.emplace_back( wxGtkPath );
670 wxGtkPath.AssignDir( wxS(
"~/.var/app/org.kicad.KiCad/config/kicad" ) );
671 wxGtkPath.MakeAbsolute();
672 base_paths.emplace_back( wxGtkPath );
679 auto check_dir = [&] (
const wxString& aSubDir )
684 wxString sub_path = dir.GetNameWithSep() + aSubDir;
688 aPaths->push_back( sub_path );
689 wxLogTrace(
traceSettings, wxT(
"GetPreviousVersionName: %s is valid" ), sub_path );
694 std::set<wxString> checkedPaths;
696 for(
const wxFileName& base_path : base_paths )
698 if( checkedPaths.count( base_path.GetFullPath() ) )
701 checkedPaths.insert( base_path.GetFullPath() );
703 if( !dir.Open( base_path.GetFullPath() ) )
705 wxLogTrace(
traceSettings, wxT(
"GetPreviousVersionName: could not open base path %s" ),
706 base_path.GetFullPath() );
710 wxLogTrace(
traceSettings, wxT(
"GetPreviousVersionName: checking base path %s" ),
711 base_path.GetFullPath() );
713 if( dir.GetFirst( &subdir, wxEmptyString, wxDIR_DIRS ) )
718 while( dir.GetNext( &subdir ) )
729 wxT(
"GetPreviousVersionName: root path %s is valid" ), dir.GetName() );
730 aPaths->push_back( dir.GetName() );
736 wxFileName fulldir = wxFileName::DirName( aPath );
737 const wxArrayString& dirs = fulldir.GetDirs();
739 if( dirs.empty() || !fulldir.IsDirReadable() )
742 std::string ver = dirs.back().ToStdString();
750 std::sort( aPaths->begin(), aPaths->end(),
751 [&](
const wxString& a,
const wxString& b ) ->
bool
753 wxFileName aPath = wxFileName::DirName( a );
754 wxFileName bPath = wxFileName::DirName( b );
756 const wxArrayString& aDirs = aPath.GetDirs();
757 const wxArrayString& bDirs = bPath.GetDirs();
765 std::string verA = aDirs.back().ToStdString();
766 std::string verB = bDirs.back().ToStdString();
768 if( !extractVersion( verA ) )
771 if( !extractVersion( verB ) )
774 return compareVersions( verA, verB ) >= 0;
777 return aPaths->size() > 0;
783 wxFileName
test( aPath, wxS(
"kicad_common" ) );
788 test.SetExt(
"json" );
790 return test.Exists();
799 path.AppendDir( wxS(
"colors" ) );
801 if( !
path.DirExists() )
803 if( !wxMkdir(
path.GetPath() ) )
806 wxT(
"GetColorSettingsPath(): Path %s missing and could not be created!" ),
811 return path.GetPath();
831 wxLogTrace(
traceSettings, wxT(
"compareSettingsVersions: bad input (%s, %s)" ),
840 else if( a_maj > b_maj )
850 else if( a_min > b_min )
864 std::regex re_version(
"(\\d+)\\.(\\d+)" );
867 if( std::regex_match( aVersionString, match, re_version ) )
871 int major = std::stoi( match[1].str() );
872 int minor = std::stoi( match[2].str() );
895 wxFileName
path( aFullPath );
900 wxString fullPath =
path.GetFullPath();
908 bool readOnly =
false;
911 if( !lockFile.
Valid() )
913 wxLogTrace(
traceSettings, wxT(
"Project %s is locked; opening read-only" ), fullPath );
925 [&](
const std::unique_ptr<PROJECT>& ptr )
927 return ptr.get() == oldProject;
934 wxLogTrace(
traceSettings, wxT(
"Load project %s" ), fullPath );
936 std::unique_ptr<PROJECT>
project = std::make_unique<PROJECT>();
937 project->setProjectFullName( fullPath );
943 wxFileName projectPath( fullPath );
951 project->SetReadOnly( readOnly ||
project->GetProjectFile().IsReadOnly() );
953 if( lockFile && aSetActive )
960 wxString fn(
path.GetName() );
969 m_projects[fullPath]->setLocalSettings( settings );
987 wxLogTrace(
traceSettings, wxT(
"Unload project %s" ), projectPath );
993 [&](
const std::unique_ptr<PROJECT>& ptr )
995 return ptr.get() == toRemove;
1003 if( wasActiveProject )
1049 std::vector<wxString> ret;
1051 for(
const std::pair<const wxString, PROJECT*>& pair :
m_projects )
1052 ret.emplace_back( pair.first );
1063 wxString
path = aFullPath;
1078 project->SaveToFile( projectPath );
1092 if( aFullPath.IsSameAs( oldName ) )
1101 wxFileName fn( aFullPath );
1110 project->SetFilename( fn.GetName() );
1111 project->SaveToFile( fn.GetPath() );
1130 wxString oldName =
project->GetFilename();
1131 wxFileName fn( aFullPath );
1133 bool readOnly =
project->IsReadOnly();
1134 project->SetReadOnly(
false );
1136 project->SetFilename( fn.GetName() );
1137 project->SaveToFile( fn.GetPath() );
1138 project->SetFilename( oldName );
1146 project->SetReadOnly( readOnly );
1153 wxString fn( fullFn.GetName() );
1162 wxString
path( fullFn.GetPath() );
1181 [&file](
const std::unique_ptr<JSON_SETTINGS>& aPtr )
1183 return aPtr.get() == file;
1193 ( *it )->SaveToFile( projectPath );
1215 wxDateTime timestamp = wxDateTime::Now();
1217 wxString fileName = wxString::Format( wxT(
"%s-%s" ),
Prj().GetProjectName(),
1222 target.SetName( fileName );
1225 if( !target.DirExists() && !wxMkdir( target.GetPath() ) )
1227 wxLogTrace(
traceSettings, wxT(
"Could not create project backup path %s" ),
1232 if( !target.IsDirWritable() )
1234 wxLogTrace(
traceSettings, wxT(
"Backup directory %s is not writable" ), target.GetPath() );
1238 wxLogTrace(
traceSettings, wxT(
"Backing up project to %s" ), target.GetPath() );
1242 return archiver.
Archive(
Prj().GetProjectPath(), target.GetFullPath(), aReporter );
1250 std::function<
bool(
const wxString& )> aCond ) :
1256 wxDirTraverseResult
OnFile(
const wxString& aFile )
override
1259 m_files.emplace_back( aFile );
1261 return wxDIR_CONTINUE;
1264 wxDirTraverseResult
OnDir(
const wxString& aDirName )
override
1266 return wxDIR_CONTINUE;
1286 [&prefix](
const wxString& aFile )
1289 wxString fn( wxFileName( aFile ).GetName() );
1290 fn.Replace( prefix, wxS(
"" ) );
1295 wxFileName projectPath(
Prj().GetProjectPath() );
1298 if( !projectPath.IsOk() || !projectPath.Exists() || !projectPath.IsDirWritable() )
1303 if( !wxDirExists( backupPath ) )
1305 wxLogTrace(
traceSettings, wxT(
"Backup path %s doesn't exist, creating it" ), backupPath );
1307 if( !wxMkdir( backupPath ) )
1309 wxLogTrace(
traceSettings, wxT(
"Could not create backups path! Skipping backup" ) );
1314 wxDir dir( backupPath );
1316 if( !dir.IsOpened() )
1318 wxLogTrace(
traceSettings, wxT(
"Could not open project backups path %s" ), dir.GetName() );
1322 std::vector<wxString> files;
1325 [&modTime](
const wxString& aFile )
1327 return modTime( aFile ).IsValid();
1330 dir.Traverse( traverser, wxT(
"*.zip" ) );
1333 std::sort( files.begin(), files.end(),
1334 [&](
const wxString& aFirst,
const wxString& aSecond ) ->
bool
1336 wxDateTime first = modTime( aFirst );
1337 wxDateTime second = modTime( aSecond );
1339 return first.GetTicks() > second.GetTicks();
1343 if( !files.empty() )
1345 wxDateTime lastTime = modTime( files[0] );
1347 if( lastTime.IsValid() )
1349 wxTimeSpan
delta = wxDateTime::Now() - modTime( files[0] );
1363 wxRemoveFile( files.back() );
1371 wxULongLong totalSize = 0;
1373 for(
const wxString& file : files )
1374 totalSize += wxFileName::GetSize( file );
1376 while( !files.empty() && totalSize >
static_cast<wxULongLong
>( settings.
limit_total_size ) )
1378 totalSize -= wxFileName::GetSize( files.back() );
1379 wxRemoveFile( files.back() );
1387 wxDateTime day = modTime( files[0] );
1390 wxASSERT( day.IsValid() );
1392 std::vector<wxString> filesToDelete;
1394 for(
size_t i = 1; i < files.size(); i++ )
1396 wxDateTime dt = modTime( files[i] );
1398 if( dt.IsSameDate( day ) )
1403 filesToDelete.emplace_back( files[i] );
1412 for(
const wxString& file : filesToDelete )
1413 wxRemoveFile( file );
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetName(const wxString &aName)
static std::vector< COLOR_SETTINGS * > CreateBuiltinColorSettings()
Constructs and returns a list of color settings objects based on the built-in color themes.
static const wxString COLOR_BUILTIN_DEFAULT
std::function< void(const wxFileName &)> m_action
JSON_DIR_TRAVERSER(std::function< void(const wxFileName &)> aAction)
wxDirTraverseResult OnDir(const wxString &dirPath) override
wxDirTraverseResult OnFile(const wxString &aFilePath) override
std::optional< nlohmann::json > GetJson(const std::string &aPath) const
Fetches a JSON object that is a subset of this JSON_SETTINGS object, using a path of the form "key1....
bool Contains(const std::string &aPath) const
SETTINGS_LOC GetLocation() const
virtual bool LoadFromFile(const wxString &aDirectory="")
Loads the backing file from disk and then calls Load()
virtual void Load()
Updates the parameters of this object based on the current JSON document contents.
void SetReadOnly(bool aReadOnly)
wxString GetFullFilename() const
JSON_SETTINGS_INTERNALS * Internals()
void SetFilename(const wxString &aFilename)
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
Calls Store() and then writes the contents of the JSON document to a file.
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
wxString GetFilename() const
virtual void ProjectChanged()
Calls ProjectChanged() on all KIWAY_PLAYERs.
wxDirTraverseResult OnDir(const wxString &dirPath) override
MIGRATION_TRAVERSER(const wxString &aSrcDir, const wxString &aDestDir, bool aMigrateTables)
wxDirTraverseResult OnFile(const wxString &aSrcFilePath) override
static wxString CalculateUserSettingsPath(bool aIncludeVer=true, bool aUseEnv=true)
Determines the base path for user settings files.
static wxString GetDefault3rdPartyPath()
Gets the default path for PCM packages.
static wxString GetStockDataPath(bool aRespectRunFromBuildDir=true)
Gets the stock (install) data path, which is the base path for things like scripting,...
static wxString GetUserSettingsPath()
Return the user configuration path used to store KiCad's configuration files.
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
bool Archive(const wxString &aSrcDir, const wxString &aDestFile, REPORTER &aReporter, bool aVerbose=true, bool aIncludeExtraFiles=false)
Creates an archive of the project.
The backing store for a PROJECT, in JSON format.
void SetProject(PROJECT *aProject)
The project local settings are things that are attached to a particular project, but also might be pa...
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
Calls Store() and then writes the contents of the JSON document to a file.
Container for project specific data.
virtual void setProjectFile(PROJECT_FILE *aFile)
Set the backing store file for this project.
virtual bool IsReadOnly() const
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual const wxString GetProjectName() const
Return the short name of the project.
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
virtual void setProjectFullName(const wxString &aFullPathAndName)
Set the full directory, basename, and extension of the project.
A pure virtual class used to derive REPORTER objects from.
static int compareVersions(const std::string &aFirst, const std::string &aSecond)
Compares two settings versions, like "5.99" and "6.0".
std::unique_ptr< LOCKFILE > m_project_lock
Lock for loaded project (expand to multiple once we support MDI)
wxString GetPathForSettingsFile(JSON_SETTINGS *aSettings)
Returns the path a given settings file should be loaded from / stored to.
static std::string GetSettingsVersion()
Parses the current KiCad build version and extracts the major and minor revision to use as the name o...
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 m...
JSON_SETTINGS * registerSettings(JSON_SETTINGS *aSettings, bool aLoadNow=true)
static wxString GetUserSettingsPath()
A proxy for PATHS::GetUserSettingsPath rather than fighting swig.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
void SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Saves a copy of the current project under the given path.
bool MigrateIfNeeded()
Handles the initialization of the user settings directory and migration from previous KiCad versions ...
wxString m_migration_source
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
bool BackupProject(REPORTER &aReporter) const
Creates a backup archive of the current project.
std::map< wxString, PROJECT * > m_projects
Loaded projects, mapped according to project full name.
static bool extractVersion(const std::string &aVersionString, int *aMajor=nullptr, int *aMinor=nullptr)
Extracts the numeric version from a given settings string.
COLOR_SETTINGS * registerColorSettings(const wxString &aFilename, bool aAbsolutePath=false)
bool m_headless
True if running outside a UI context.
SETTINGS_MANAGER(bool aHeadless=false)
static wxString GetColorSettingsPath()
Returns the path where color scheme files are stored; creating it if missing (normally .
COMMON_SETTINGS * GetCommonSettings() const
Retrieves the common settings shared by all applications.
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Saves a loaded project.
wxString GetProjectBackupsPath() const
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
std::map< wxString, PROJECT_FILE * > m_project_files
Loaded project files, mapped according to project full name.
std::unordered_map< wxString, COLOR_SETTINGS * > m_color_settings
COLOR_SETTINGS * loadColorSettingsByName(const wxString &aName)
Attempts to load a color theme by name (the color theme directory and .json ext are assumed)
bool IsProjectOpen() const
Helper for checking if we have a project open TODO: This should be deprecated along with Prj() once w...
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 d...
static bool IsSettingsPathValid(const wxString &aPath)
Checks if a given path is probably a valid KiCad configuration directory.
std::vector< std::unique_ptr< PROJECT > > m_projects_list
Loaded projects (ownership here)
void loadAllColorSettings()
PROJECT * GetProject(const wxString &aFullPath) const
Retrieves a loaded project by name.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
std::vector< wxString > GetOpenProjects() const
std::vector< std::unique_ptr< JSON_SETTINGS > > m_settings
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls BackupProject if a new backup is needed according to the current backup policy.
bool m_migrateLibraryTables
If true, the symbol and footprint library tables will be migrated from the previous version.
bool unloadProjectFile(PROJECT *aProject, bool aSave)
Optionally saves, and then unloads and unregisters the given PROJECT_FILE.
COLOR_SETTINGS * GetMigratedColorSettings()
Returns a color theme for storing colors migrated from legacy (5.x and earlier) settings,...
std::unordered_map< size_t, JSON_SETTINGS * > m_app_settings_cache
Cache for app settings.
COLOR_SETTINGS * AddNewColorSettings(const wxString &aFilename)
Registers a new color settings object with the given filename.
bool m_ok
True if settings loaded successfully at construction.
void registerBuiltinColorSettings()
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
bool loadProjectFile(PROJECT &aProject)
Registers a PROJECT_FILE and attempts to load it from disk.
static wxString backupDateTimeFormat
void ReloadColorSettings()
Re-scans the color themes directory, reloading any changes it finds.
COMMON_SETTINGS * m_common_settings
KIWAY * m_kiway
The kiway this settings manager interacts with.
void FlushAndRelease(JSON_SETTINGS *aSettings, bool aSave=true)
If the given settings object is registered, save it to disk and unregister it.
wxDirTraverseResult OnFile(const wxString &aFile) override
wxDirTraverseResult OnDir(const wxString &aDirName) override
std::vector< wxString > & m_files
VECTOR_INSERT_TRAVERSER(std::vector< wxString > &aVec, std::function< bool(const wxString &)> aCond)
std::function< bool(const wxString &)> m_condition
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
static const std::string ProjectFileExtension
static const std::string LegacyProjectFileExtension
static const std::string ArchiveFileExtension
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
This file contains miscellaneous commonly used macros and functions.
void delete_if(_Container &__c, _Function &&__f)
Deletes all values from __c for which __f returns true.
PGM_BASE & Pgm()
The global Program "get" accessor.
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
#define PROJECT_BACKUPS_DIR_SUFFIX
Project settings path will be <projectname> + this.
int min_interval
Minimum time, in seconds, between subsequent backups.
unsigned long long limit_total_size
Maximum total size of backups (bytes), 0 for unlimited.
int limit_total_files
Maximum number of backup archives to retain.
int limit_daily_files
Maximum files to keep per day, 0 for unlimited.
bool enabled
Automatically back up the project when files are saved.
Definition of file extensions used in Kicad.