KiCad PCB EDA Suite
|
Container for data for KiCad programs. More...
#include <pgm_base.h>
Public Member Functions | |
PGM_BASE () | |
virtual | ~PGM_BASE () |
void | BuildArgvUtf8 () |
Builds the UTF8 based argv variable. More... | |
virtual void | MacOpenFile (const wxString &aFileName)=0 |
Specific to MacOSX (not used under Linux or Windows). More... | |
virtual SETTINGS_MANAGER & | GetSettingsManager () const |
virtual COMMON_SETTINGS * | GetCommonSettings () const |
virtual BACKGROUND_JOBS_MONITOR & | GetBackgroundJobMonitor () const |
virtual NOTIFICATIONS_MANAGER & | GetNotificationsManager () const |
virtual void | SetTextEditor (const wxString &aFileName) |
virtual const wxString & | GetTextEditor (bool aCanShowFileChooser=true) |
Return the path to the preferred text editor application. More... | |
virtual const wxString | AskUserForPreferredEditor (const wxString &aDefaultEditor=wxEmptyString) |
Shows a dialog that instructs the user to select a new preferred editor. More... | |
virtual bool | IsKicadEnvVariableDefined () const |
virtual const wxString & | GetKicadEnvVariable () const |
virtual const wxString & | GetExecutablePath () const |
virtual wxLocale * | GetLocale () |
virtual const wxString & | GetPdfBrowserName () const |
virtual void | SetPdfBrowserName (const wxString &aFileName) |
virtual bool | UseSystemPdfBrowser () const |
virtual void | ForceSystemPdfBrowser (bool aFlg) |
Force the use of system PDF browser, even if a preferred PDF browser is set. More... | |
virtual bool | SetLanguage (wxString &aErrMsg, bool first_time=false) |
Set the dictionary file name for internationalization. More... | |
bool | SetDefaultLanguage (wxString &aErrMsg) |
Set the default language without reference to any preferences. More... | |
virtual void | SetLanguageIdentifier (int menu_id) |
Set in .m_language_id member the wxWidgets language identifier ID from the KiCad menu id (internal menu identifier). More... | |
virtual int | GetSelectedLanguageIdentifier () const |
virtual wxString | GetLanguageTag () |
virtual void | SetLanguagePath () |
virtual void | ReadPdfBrowserInfos () |
Read the PDF browser choice from the common configuration. More... | |
virtual void | WritePdfBrowserInfos () |
Save the PDF browser choice to the common configuration. More... | |
virtual bool | SetLocalEnvVariable (const wxString &aName, const wxString &aValue) |
Sets the environment variable aName to aValue. More... | |
virtual void | SetLocalEnvVariables () |
Updates the local environment with the contents of the current ENV_VAR_MAP stored in the COMMON_SETTINGS. More... | |
virtual ENV_VAR_MAP & | GetLocalEnvVariables () const |
virtual wxApp & | App () |
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe. More... | |
bool | InitPgm (bool aHeadless=false, bool aSkipPyInit=false, bool aIsUnitTest=false) |
Initialize this program. More... | |
void | Destroy () |
void | SaveCommonSettings () |
Save the program (process) settings subset which are stored .kicad_common. More... | |
void | HandleException (std::exception_ptr aPtr) |
A exception handler to be used at the top level if exceptions bubble up that for. More... | |
void | HandleAssert (const wxString &aFile, int aLine, const wxString &aFunc, const wxString &aCond, const wxString &aMsg) |
A common assert handler to be used between single_top and kicad. More... | |
bool | IsGUI () |
Determine if the application is running with a GUI. More... | |
void | ShowSplash () |
void | HideSplash () |
std::unique_ptr< wxSingleInstanceChecker > & | SingleInstance () |
Allows access to the wxSingleInstanceChecker to test for other running KiCads. More... | |
Public Attributes | |
bool | m_Printing |
wxWidgets on MSW tends to crash if you spool up more than one print job at a time. More... | |
std::vector< void * > | m_ModalDialogs |
bool | m_Quitting |
Static Public Attributes | |
static const wxChar | workingDirKey [] |
Protected Member Functions | |
void | loadCommonSettings () |
Loads internal settings from COMMON_SETTINGS. More... | |
void | setLanguageId (int aId) |
Trap all changes in here, simplifies debugging. More... | |
Protected Attributes | |
std::unique_ptr< SETTINGS_MANAGER > | m_settings_manager |
std::unique_ptr< BACKGROUND_JOBS_MONITOR > | m_background_jobs_monitor |
std::unique_ptr< NOTIFICATIONS_MANAGER > | m_notifications_manager |
std::unique_ptr< SCRIPTING > | m_python_scripting |
std::unique_ptr< wxSingleInstanceChecker > | m_pgm_checker |
Checks if there is another copy of Kicad running at the same time. More... | |
wxString | m_kicad_env |
wxLocale * | m_locale |
The KICAD system environment variable. More... | |
int | m_language_id |
bool | m_use_system_pdf_browser |
wxString | m_pdf_browser |
wxString | m_text_editor |
Filename of the app selected for browsing PDFs. More... | |
char ** | m_argvUtf8 |
int | m_argcUtf8 |
argv parameters converted to utf8 form, because wxwidgets has opinions and will return argv as either force converted to ascii in char* or wchar_t only More... | |
wxSplashScreen * | m_splash |
Container for data for KiCad programs.
The functions are virtual so we can do cross module calls without linking to them. This used to be a wxApp derivative, but that is difficult under wxPython which shapes the wxApp. So now this is a "side-car" (like a motorcycle side-car) object with a back pointer into the wxApp which initializes it.
Definition at line 98 of file pgm_base.h.
PGM_BASE::PGM_BASE | ( | ) |
Definition at line 130 of file pgm_base.cpp.
References ForceSystemPdfBrowser(), m_argcUtf8, m_argvUtf8, m_locale, m_Printing, m_Quitting, m_splash, and setLanguageId().
|
virtual |
Definition at line 145 of file pgm_base.cpp.
References Destroy(), HideSplash(), m_argcUtf8, and m_argvUtf8.
|
virtual |
Returns a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
This should return what wxGetApp() returns.
Definition at line 175 of file pgm_base.cpp.
References dummy.
Referenced by BuildArgvUtf8(), InitPgm(), PGM_SINGLE_TOP::MacOpenFile(), PGM_KICAD::MacOpenFile(), PGM_TEST_FRAME::MacOpenFile(), and PGM_KICAD::OnPgmInit().
|
virtual |
Shows a dialog that instructs the user to select a new preferred editor.
aDefaultEditor | Default full path for the default editor this dialog should show by default. |
Definition at line 231 of file pgm_base.cpp.
Referenced by GetTextEditor().
void PGM_BASE::BuildArgvUtf8 | ( | ) |
Builds the UTF8 based argv variable.
Definition at line 410 of file pgm_base.cpp.
References App(), m_argcUtf8, and m_argvUtf8.
void PGM_BASE::Destroy | ( | ) |
Definition at line 159 of file pgm_base.cpp.
References KICAD_CURL::Cleanup(), m_locale, and m_pgm_checker.
Referenced by PGM_KICAD::Destroy(), PGM_SINGLE_TOP::OnPgmExit(), PGM_TEST_FRAME::OnPgmExit(), and ~PGM_BASE().
|
inlinevirtual |
Force the use of system PDF browser, even if a preferred PDF browser is set.
Definition at line 195 of file pgm_base.h.
References m_use_system_pdf_browser.
Referenced by PGM_BASE().
|
inlinevirtual |
Definition at line 143 of file pgm_base.h.
References m_background_jobs_monitor.
|
virtual |
Definition at line 640 of file pgm_base.cpp.
References m_settings_manager.
Referenced by GetLocalEnvVariables(), InitPgm(), loadCommonSettings(), ReadPdfBrowserInfos(), SaveCommonSettings(), SetLanguage(), SetLocalEnvVariables(), SetTextEditor(), and WritePdfBrowserInfos().
|
virtual |
Definition at line 961 of file pgm_base.cpp.
References PATHS::GetExecutablePath().
Referenced by PGM_SINGLE_TOP::OnPgmInit(), and SetLanguagePath().
|
inlinevirtual |
Definition at line 172 of file pgm_base.h.
References m_kicad_env.
|
virtual |
Definition at line 803 of file pgm_base.cpp.
References m_language_id.
|
inlinevirtual |
Definition at line 176 of file pgm_base.h.
References m_locale.
|
virtual |
Definition at line 877 of file pgm_base.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_Env, and COMMON_SETTINGS::ENVIRONMENT::vars.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), FILENAME_RESOLVER::GetKicadPaths(), and PGM_KICAD::OnPgmInit().
|
inlinevirtual |
Definition at line 145 of file pgm_base.h.
References m_notifications_manager.
Referenced by InitPgm().
|
inlinevirtual |
Definition at line 178 of file pgm_base.h.
References m_pdf_browser.
Referenced by WritePdfBrowserInfos().
|
inlinevirtual |
Definition at line 229 of file pgm_base.h.
References m_language_id.
|
inlinevirtual |
Definition at line 139 of file pgm_base.h.
References m_settings_manager.
Referenced by InitPgm(), LIB_PIN::LIB_PIN(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), GERBV::IFACE::OnKifaceStart(), PGE::IFACE::OnKifaceStart(), PCBCALC::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), PGM_KICAD::OnPgmInit(), and SetLanguage().
|
virtual |
Return the path to the preferred text editor application.
aCanShowFileChooser | If no editor is currently set and this argument is 'true' then this method will show a file chooser dialog asking for the editor's executable. |
Definition at line 195 of file pgm_base.cpp.
References _, AskUserForPreferredEditor(), DisplayInfoMessage(), m_text_editor, and SetTextEditor().
void PGM_BASE::HandleAssert | ( | const wxString & | aFile, |
int | aLine, | ||
const wxString & | aFunc, | ||
const wxString & | aCond, | ||
const wxString & | aMsg | ||
) |
A common assert handler to be used between single_top and kicad.
This lets us have a common set of assert handling, including triggering sentry reports
aFile | the file path of the assert |
aLine | the line number of the assert |
aFunc | the function name the assert is within |
aCond | the condition of the assert |
aMsg | the attached assert message (can be empty) |
Definition at line 927 of file pgm_base.cpp.
void PGM_BASE::HandleException | ( | std::exception_ptr | aPtr | ) |
A exception handler to be used at the top level if exceptions bubble up that for.
The purpose is to have a central place to log a wxWidgets error message and/or sentry report
aPtr | Pass the std::current_exception() from within the catch block |
Definition at line 892 of file pgm_base.cpp.
References From_UTF8(), name, and IO_ERROR::What().
Referenced by APP_KICAD::OnRun(), and APP_KICAD_CLI::OnRun().
void PGM_BASE::HideSplash | ( | ) |
Definition at line 436 of file pgm_base.cpp.
References m_splash.
Referenced by PGM_KICAD::OnPgmInit(), and ~PGM_BASE().
bool PGM_BASE::InitPgm | ( | bool | aHeadless = false , |
bool | aSkipPyInit = false , |
||
bool | aIsUnitTest = false |
||
) |
Initialize this program.
Initialize the process in a KiCad standard way using some generalized techniques:
aHeadless | If true, run in headless mode (e.g. for unit tests) |
aSkipPyInit | If true, do not init python stuff. Useful in application that do not use python, to disable python dependency at run time |
Should never happen but boost unit_test isn't playing nicely in some cases
Definition at line 447 of file pgm_base.cpp.
References _, App(), DisplayErrorMessage(), PATHS::EnsureUserPathsExist(), ADVANCED_CFG::GetCfg(), GetCommonSettings(), GetNotificationsManager(), GetSettingsManager(), KICAD_CURL::Init(), COMMON_SETTINGS::InitializeEnvironment(), NOTIFICATIONS_MANAGER::Load(), SETTINGS_MANAGER::Load(), loadCommonSettings(), SETTINGS_MANAGER::LoadProject(), m_background_jobs_monitor, m_kicad_env, m_notifications_manager, m_pgm_checker, m_python_scripting, m_settings_manager, ReadPdfBrowserInfos(), SetDefaultLanguage(), SetLanguage(), SetLanguagePath(), ShowSplash(), UNIX_STRING_DIR_SEP, WarnUserIfOperatingSystemUnsupported(), WIN_STRING_DIR_SEP, and wxPGGlobalVars.
Referenced by PGM_KICAD::OnPgmInit().
bool PGM_BASE::IsGUI | ( | ) |
Determine if the application is running with a GUI.
Definition at line 883 of file pgm_base.cpp.
|
inlinevirtual |
Definition at line 170 of file pgm_base.h.
References m_kicad_env.
|
protected |
Loads internal settings from COMMON_SETTINGS.
Definition at line 604 of file pgm_base.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_System, m_text_editor, PROJECT_VAR_NAME, SetLocalEnvVariable(), COMMON_SETTINGS::SYSTEM::text_editor, and traceEnvVars.
Referenced by InitPgm().
|
pure virtual |
Specific to MacOSX (not used under Linux or Windows).
MacOSX requires it for file association.
Implemented in PGM_SINGLE_TOP, PGM_KICAD, and PGM_TEST_FRAME.
|
virtual |
Read the PDF browser choice from the common configuration.
Definition at line 37 of file eda_doc.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_System, m_use_system_pdf_browser, SetPdfBrowserName(), and COMMON_SETTINGS::SYSTEM::use_system_pdf_viewer.
Referenced by InitPgm().
void PGM_BASE::SaveCommonSettings | ( | ) |
Save the program (process) settings subset which are stored .kicad_common.
Definition at line 631 of file pgm_base.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_System, and COMMON_SETTINGS::SYSTEM::working_dir.
Referenced by PGM_SINGLE_TOP::OnPgmExit(), and PGM_KICAD::OnPgmExit().
bool PGM_BASE::SetDefaultLanguage | ( | wxString & | aErrMsg | ) |
Set the default language without reference to any preferences.
Can be used to set the language for dialogs that show before preferences are loaded
aErrMsg | String to return the error message(s) in |
Definition at line 746 of file pgm_base.cpp.
References _, m_language_id, m_locale, setLanguageId(), and traceLocale.
Referenced by InitPgm().
|
virtual |
Set the dictionary file name for internationalization.
The files are in kicad/internat/xx or kicad/internat/xx_XX and are named kicad.mo
aErrMsg | is the string to return the error message it. |
first_time | must be set to true the first time this function is called, false otherwise. |
Definition at line 646 of file pgm_base.cpp.
References _, GetCommonSettings(), GetSettingsManager(), COMMON_SETTINGS::SYSTEM::language, LanguagesList, LANGUAGE_DESCR::m_KI_Lang_Identifier, LANGUAGE_DESCR::m_Lang_Label, m_language_id, m_locale, COMMON_SETTINGS::m_System, JSON_SETTINGS::SaveToFile(), setLanguageId(), and traceLocale.
Referenced by InitPgm().
|
inlineprotected |
Trap all changes in here, simplifies debugging.
Definition at line 388 of file pgm_base.h.
References m_language_id.
Referenced by PGM_BASE(), SetDefaultLanguage(), SetLanguage(), and SetLanguageIdentifier().
|
virtual |
Set in .m_language_id member the wxWidgets language identifier ID from the KiCad menu id (internal menu identifier).
menu_id | The KiCad menuitem id (returned by Menu Event, when clicking on a menu item) |
Definition at line 787 of file pgm_base.cpp.
References arrayDim(), LanguagesList, LANGUAGE_DESCR::m_KI_Lang_Identifier, setLanguageId(), and traceLocale.
|
virtual |
Definition at line 819 of file pgm_base.cpp.
References GetExecutablePath(), PATHS::GetLocaleDataPath(), and Pgm().
Referenced by InitPgm().
|
virtual |
Sets the environment variable aName to aValue.
This function first checks to see if the environment variable aName is already defined. If it is not defined, then the environment variable aName is set to a value. Otherwise, the environment variable is left unchanged. This allows the user to override environment variables for testing purposes.
aName | is a wxString containing the environment variable name. |
aValue | is a wxString containing the environment variable value. |
Definition at line 833 of file pgm_base.cpp.
References traceEnvVars.
Referenced by loadCommonSettings().
|
virtual |
Updates the local environment with the contents of the current ENV_VAR_MAP stored in the COMMON_SETTINGS.
Definition at line 862 of file pgm_base.cpp.
References GetCommonSettings(), and traceEnvVars.
|
inlinevirtual |
Definition at line 180 of file pgm_base.h.
References m_pdf_browser.
Referenced by ReadPdfBrowserInfos().
|
virtual |
Definition at line 188 of file pgm_base.cpp.
References GetCommonSettings(), COMMON_SETTINGS::m_System, m_text_editor, and COMMON_SETTINGS::SYSTEM::text_editor.
Referenced by GetTextEditor().
void PGM_BASE::ShowSplash | ( | ) |
Definition at line 425 of file pgm_base.cpp.
References KiBitmap(), and m_splash.
Referenced by InitPgm().
|
inline |
Allows access to the wxSingleInstanceChecker to test for other running KiCads.
Definition at line 369 of file pgm_base.h.
References m_pgm_checker.
|
inlinevirtual |
Definition at line 187 of file pgm_base.h.
References m_pdf_browser, and m_use_system_pdf_browser.
|
virtual |
Save the PDF browser choice to the common configuration.
Definition at line 44 of file eda_doc.cpp.
References GetCommonSettings(), GetPdfBrowserName(), COMMON_SETTINGS::m_System, m_use_system_pdf_browser, COMMON_SETTINGS::SYSTEM::pdf_viewer_name, and COMMON_SETTINGS::SYSTEM::use_system_pdf_viewer.
|
protected |
argv parameters converted to utf8 form, because wxwidgets has opinions and will return argv as either force converted to ascii in char* or wchar_t only
Definition at line 426 of file pgm_base.h.
Referenced by BuildArgvUtf8(), PGM_BASE(), and ~PGM_BASE().
|
protected |
Definition at line 423 of file pgm_base.h.
Referenced by BuildArgvUtf8(), PGM_BASE(), and ~PGM_BASE().
|
protected |
Definition at line 398 of file pgm_base.h.
Referenced by GetBackgroundJobMonitor(), and InitPgm().
|
protected |
Definition at line 407 of file pgm_base.h.
Referenced by GetKicadEnvVariable(), InitPgm(), and IsKicadEnvVariableDefined().
|
protected |
Definition at line 410 of file pgm_base.h.
Referenced by GetLanguageTag(), GetSelectedLanguageIdentifier(), SetDefaultLanguage(), SetLanguage(), and setLanguageId().
|
protected |
The KICAD system environment variable.
Definition at line 409 of file pgm_base.h.
Referenced by Destroy(), GetLocale(), PGM_BASE(), SetDefaultLanguage(), and SetLanguage().
std::vector<void*> PGM_BASE::m_ModalDialogs |
Definition at line 379 of file pgm_base.h.
Referenced by APP_KICAD::FilterEvent().
|
protected |
Definition at line 399 of file pgm_base.h.
Referenced by GetNotificationsManager(), and InitPgm().
|
protected |
Definition at line 413 of file pgm_base.h.
Referenced by GetPdfBrowserName(), SetPdfBrowserName(), and UseSystemPdfBrowser().
|
protected |
Checks if there is another copy of Kicad running at the same time.
Definition at line 404 of file pgm_base.h.
Referenced by Destroy(), InitPgm(), and SingleInstance().
bool PGM_BASE::m_Printing |
wxWidgets on MSW tends to crash if you spool up more than one print job at a time.
Definition at line 377 of file pgm_base.h.
Referenced by PGM_BASE().
|
protected |
Definition at line 401 of file pgm_base.h.
Referenced by InitPgm().
bool PGM_BASE::m_Quitting |
Definition at line 381 of file pgm_base.h.
Referenced by PGM_BASE().
|
protected |
Definition at line 397 of file pgm_base.h.
Referenced by GetCommonSettings(), GetSettingsManager(), InitPgm(), PGM_SINGLE_TOP::OnPgmExit(), and PGM_KICAD::OnPgmExit().
|
protected |
Definition at line 428 of file pgm_base.h.
Referenced by HideSplash(), PGM_BASE(), and ShowSplash().
|
protected |
Filename of the app selected for browsing PDFs.
Definition at line 415 of file pgm_base.h.
Referenced by GetTextEditor(), loadCommonSettings(), and SetTextEditor().
|
protected |
Definition at line 412 of file pgm_base.h.
Referenced by ForceSystemPdfBrowser(), ReadPdfBrowserInfos(), UseSystemPdfBrowser(), and WritePdfBrowserInfos().
|
static |
Definition at line 278 of file pgm_base.h.