KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pgm_base.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28
29#include <wx/app.h>
30#include <wx/dialog.h>
31#include <wx/eventfilter.h>
32#include <wx/html/htmlwin.h>
33#include <wx/fs_zip.h>
34#include <wx/dir.h>
35#include <wx/filename.h>
36#include <wx/msgdlg.h>
37#include <wx/propgrid/propgrid.h>
38#include <wx/stdpaths.h>
39#include <wx/sysopt.h>
40#include <wx/filedlg.h>
41#include <wx/ffile.h>
42#include <wx/tooltip.h>
43
44#include <advanced_config.h>
46#include <api/api_server.h>
47#include <api/python_manager.h>
48#include <app_monitor.h>
50#include <bitmap_store.h>
51#include <bitmaps.h>
52#include <build_version.h>
53#include <common.h>
55#include <confirm.h>
56#include <core/arraydim.h>
57#include <id.h>
59#include <kiplatform/policy.h>
61#include <macros.h>
63#include <paths.h>
64#include <pgm_base.h>
66#include <policy_keys.h>
67#include <scoped_set_reset.h>
70#include <string_utils.h>
71#include <systemdirsappend.h>
72#include <thread_pool.h>
73#include <trace_helpers.h>
74
75#include <widgets/kistatusbar.h>
76#include <widgets/wx_splash.h>
77
78#ifdef _MSC_VER
79#include <winrt/base.h>
80#endif
90#undef _
91#define _(s) s
93{
94 { wxLANGUAGE_DEFAULT, ID_LANGUAGE_DEFAULT, _( "Default" ), false },
95 { wxLANGUAGE_ARABIC, ID_LANGUAGE_ARABIC, wxT( "العربية" ), true },
96 { wxLANGUAGE_FARSI, ID_LANGUAGE_FARSI, wxT( "فارسی" ), true },
97 { wxLANGUAGE_INDONESIAN, ID_LANGUAGE_INDONESIAN, wxT( "Bahasa Indonesia" ), true },
98 { wxLANGUAGE_BULGARIAN, ID_LANGUAGE_BULGARIAN, wxT( "Български" ), true },
99 { wxLANGUAGE_CATALAN, ID_LANGUAGE_CATALAN, wxT( "Català" ), true },
100 { wxLANGUAGE_CZECH, ID_LANGUAGE_CZECH, wxT( "Čeština" ), true },
101 { wxLANGUAGE_DANISH, ID_LANGUAGE_DANISH, wxT( "Dansk" ), true },
102 { wxLANGUAGE_GERMAN, ID_LANGUAGE_GERMAN, wxT( "Deutsch" ), true },
103 { wxLANGUAGE_GREEK, ID_LANGUAGE_GREEK, wxT( "Ελληνικά" ), true },
104 { wxLANGUAGE_ESTONIAN, ID_LANGUAGE_ESTONIAN, wxT( "Eesti" ), true },
105 { wxLANGUAGE_ENGLISH, ID_LANGUAGE_ENGLISH, wxT( "English" ), true },
106 { wxLANGUAGE_SPANISH, ID_LANGUAGE_SPANISH, wxT( "Español" ), true },
107 { wxLANGUAGE_SPANISH_MEXICAN, ID_LANGUAGE_SPANISH_MEXICAN,
108 wxT( "Español (Latinoamericano)" ), true },
109 { wxLANGUAGE_FRENCH, ID_LANGUAGE_FRENCH, wxT( "Français" ), true },
110 { wxLANGUAGE_HEBREW, ID_LANGUAGE_HEBREW, wxT( "עברית" ), true },
111 { wxLANGUAGE_HINDI, ID_LANGUAGE_HINDI, wxT( "हिन्दी" ), true },
112 { wxLANGUAGE_CROATIAN, ID_LANGUAGE_CROATIAN, wxT( "Hrvatski" ), true },
113 { wxLANGUAGE_KOREAN, ID_LANGUAGE_KOREAN, wxT( "한국어"), true },
114 { wxLANGUAGE_ITALIAN, ID_LANGUAGE_ITALIAN, wxT( "Italiano" ), true },
115 { wxLANGUAGE_LAOTHIAN, ID_LANGUAGE_LAOTHIAN, wxT( "ພາສາລາວ" ), true },
116 { wxLANGUAGE_LATVIAN, ID_LANGUAGE_LATVIAN, wxT( "Latviešu" ), true },
117 { wxLANGUAGE_LITHUANIAN, ID_LANGUAGE_LITHUANIAN, wxT( "Lietuvių" ), true },
118 { wxLANGUAGE_HUNGARIAN, ID_LANGUAGE_HUNGARIAN, wxT( "Magyar" ), true },
119 { wxLANGUAGE_DUTCH, ID_LANGUAGE_DUTCH, wxT( "Nederlands" ), true },
120 { wxLANGUAGE_NORWEGIAN_BOKMAL, ID_LANGUAGE_NORWEGIAN_BOKMAL, wxT( "Norsk Bokmål" ), true },
121 { wxLANGUAGE_JAPANESE, ID_LANGUAGE_JAPANESE, wxT( "日本語" ), true },
122 { wxLANGUAGE_GEORGIAN, ID_LANGUAGE_GEORGIAN, wxT( "ქართული" ), true },
123 { wxLANGUAGE_THAI, ID_LANGUAGE_THAI, wxT( "ภาษาไทย" ), true },
124 { wxLANGUAGE_POLISH, ID_LANGUAGE_POLISH, wxT( "Polski" ), true },
125 { wxLANGUAGE_PORTUGUESE, ID_LANGUAGE_PORTUGUESE, wxT( "Português" ),true },
126 { wxLANGUAGE_PORTUGUESE_BRAZILIAN, ID_LANGUAGE_PORTUGUESE_BRAZILIAN,
127 wxT( "Português (Brasil)" ), true },
128 { wxLANGUAGE_ROMANIAN, ID_LANGUAGE_ROMANIAN, wxT( "Română" ), true },
129 { wxLANGUAGE_RUSSIAN, ID_LANGUAGE_RUSSIAN, wxT( "Русский" ), true },
130 { wxLANGUAGE_SERBIAN, ID_LANGUAGE_SERBIAN, wxT( "Српски" ), true },
131 { wxLANGUAGE_SLOVAK, ID_LANGUAGE_SLOVAK, wxT( "Slovenčina" ), true },
132 { wxLANGUAGE_SLOVENIAN, ID_LANGUAGE_SLOVENIAN, wxT( "Slovenščina" ), true },
133 { wxLANGUAGE_FINNISH, ID_LANGUAGE_FINNISH, wxT( "Suomi" ), true },
134 { wxLANGUAGE_SWEDISH, ID_LANGUAGE_SWEDISH, wxT( "Svenska" ), true },
135 { wxLANGUAGE_VIETNAMESE, ID_LANGUAGE_VIETNAMESE, wxT( "Tiếng Việt" ), true },
136 { wxLANGUAGE_TAMIL, ID_LANGUAGE_TAMIL, wxT( "தமிழ்" ), true },
137 { wxLANGUAGE_TELUGU, ID_LANGUAGE_TELUGU, wxT( "తెలుగు" ), true },
138 { wxLANGUAGE_TURKISH, ID_LANGUAGE_TURKISH, wxT( "Türkçe" ), true },
139 { wxLANGUAGE_UKRAINIAN, ID_LANGUAGE_UKRAINIAN, wxT( "Українська" ), true },
140 { wxLANGUAGE_CHINESE_SIMPLIFIED, ID_LANGUAGE_CHINESE_SIMPLIFIED,
141 wxT( "简体中文" ), true },
142 { wxLANGUAGE_CHINESE_TRADITIONAL, ID_LANGUAGE_CHINESE_TRADITIONAL,
143 wxT( "繁體中文" ), true },
144 { 0, 0, "", false } // Sentinel
145};
146#undef _
147#define _(s) wxGetTranslation((s))
148
149
151{
152 return *m_singleton.m_ThreadPool;
153}
154
155
157{
158 m_locale = nullptr;
159 m_Printing = false;
160 m_Quitting = false;
161 m_sessionEnding = false;
162 m_argcUtf8 = 0;
163 m_argvUtf8 = nullptr;
164 m_splash = nullptr;
166
167 setLanguageId( wxLANGUAGE_DEFAULT );
168
169 ForceSystemPdfBrowser( false );
170}
171
172
174{
175 HideSplash();
176 Destroy();
177
178 for( int n = 0; n < m_argcUtf8; n++ )
179 {
180 free( m_argvUtf8[n] );
181 }
182
183 delete[] m_argvUtf8;
184
185 delete m_locale;
186 m_locale = nullptr;
187}
188
189
191{
192 // The preload reads the design block libraries, so it has to stop before they go
193 if( m_libraryPreloadReturn.valid() )
194 {
195 if( m_libraryPreloadInProgress.load() )
196 m_libraryPreloadAbort.store( true );
197
199 }
200
201 // Freeing thousands of cached libraries one item at a time would hold up the exit for seconds
203 m_library_manager->LeakCachesAtExit();
204
205 // Clean up library IO plugins before static destruction
206 m_library_manager.reset();
207
209
211
212#ifdef _MSC_VER
213 winrt::uninit_apartment();
214#endif
215
216 // A project that failed to unload still holds its lock, and removing the lock file during
217 // static destruction would run after wxWidgets has torn down its filename conversion.
219 m_settings_manager->ReleaseProjectLocks();
220
221 // Shut down the thread pool explicitly here, before static destruction begins.
222 // On macOS, if the thread pool destructor runs during static destruction
223 // (via __cxa_finalize_ranges), the condition variables may be in an invalid state,
224 // causing a crash. By destroying the thread pool here, we ensure it's cleaned up
225 // while the C++ runtime is still in a valid state.
226 m_singleton.Shutdown();
227}
228
229
234
235
237{
238 wxASSERT( wxTheApp );
239 return *wxTheApp;
240}
241
242
243void PGM_BASE::SetTextEditor( const wxString& aFileName )
244{
245 m_text_editor = aFileName;
247}
248
249
250const wxString& PGM_BASE::GetTextEditor( bool aCanShowFileChooser )
251{
252 wxString editorname = m_text_editor;
253
254 if( !editorname )
255 {
256 if( !wxGetEnv( wxT( "EDITOR" ), &editorname ) )
257 {
258 // If there is no EDITOR variable set, try the desktop default
259#ifdef __WXMAC__
260 editorname = wxT( "/usr/bin/open -e" );
261#elif __WXX11__
262 editorname = wxT( "/usr/bin/xdg-open" );
263#endif
264 }
265 }
266
267 // If we still don't have an editor name show a dialog asking the user to select one
268 if( !editorname && aCanShowFileChooser )
269 {
270 DisplayInfoMessage( nullptr, _( "No default editor found, you must choose one." ) );
271
272 editorname = AskUserForPreferredEditor();
273 }
274
275 // If we finally have a new editor name request it to be copied to m_text_editor and
276 // saved to the preferences file.
277 if( !editorname.IsEmpty() )
278 SetTextEditor( editorname );
279
280 // m_text_editor already has the same value that editorname, or empty if no editor was
281 // found/chosen.
282 return m_text_editor;
283}
284
285
286const wxString PGM_BASE::AskUserForPreferredEditor( const wxString& aDefaultEditor )
287{
288 // Create a mask representing the executable files in the current platform
289#ifdef __WINDOWS__
290 wxString mask( _( "Executable file" ) + wxT( " (*.exe)|*.exe" ) );
291#else
292 wxString mask( _( "Executable file" ) + wxT( " (*)|*" ) );
293#endif
294
295 // Extract the path, name and extension from the default editor (even if the editor's
296 // name was empty, this method will succeed and return empty strings).
297 wxString path, name, ext;
298 wxFileName::SplitPath( aDefaultEditor, &path, &name, &ext );
299
300 // Show the modal editor and return the file chosen (may be empty if the user cancels
301 // the dialog).
302 return wxFileSelector( _( "Select Preferred Editor" ), path, name, wxT( "." ) + ext,
303 mask, wxFD_OPEN | wxFD_FILE_MUST_EXIST, nullptr );
304}
305
306
308{
309 const wxArrayString& argArray = App().argv.GetArguments();
310 m_argcUtf8 = argArray.size();
311
312 m_argvUtf8 = new char*[m_argcUtf8 + 1];
313 for( int n = 0; n < m_argcUtf8; n++ )
314 {
315 m_argvUtf8[n] = wxStrdup( argArray[n].ToUTF8() );
316 }
317
318 m_argvUtf8[m_argcUtf8] = NULL; // null terminator at end of argv
319}
320
321
323{
324 // Disabling until we change to load each DSO at startup rather than lazy-load when needed.
325 // Note that once the splash screen is re-enabled, there are some remaining bugs to fix:
326 // Any wxWidgets error dialogs that appear during startup are hidden by the splash screen,
327 // so we either need to prevent these from happening (probably not feasible) or else change
328 // the error-handling path to make sure errors go on top of the splash.
329#if 0
330 if( m_splash )
331 return;
332
333 m_splash = new WX_SPLASH( KiBitmap( BITMAPS::splash ), wxSPLASH_CENTRE_ON_SCREEN, 0,
334 NULL, -1, wxDefaultPosition, wxDefaultSize,
335 wxBORDER_NONE | wxSTAY_ON_TOP );
336 wxYield();
337#endif
338}
339
340
342{
343 if( !m_splash )
344 return;
345
346 m_splash->Close( true );
347 m_splash->Destroy();
348 m_splash = nullptr;
349}
350
351
352wxString PGM_BASE::DesktopAppIdForProgram( const wxString& aPgmName )
353{
354#if defined( __WXGTK__ ) && defined( KICAD_DESKTOP_APP_NAME )
355 // The prefix varies by build (regular, Flatpak, Nightly) and is supplied by CMake. The main
356 // manager keeps the bare app name; the other GUI apps are prefixed.
357 if( aPgmName == wxT( "kicad" ) )
358 return wxT( KICAD_DESKTOP_APP_NAME );
359
360 if( aPgmName == wxT( "eeschema" ) || aPgmName == wxT( "pcbnew" ) || aPgmName == wxT( "gerbview" )
361 || aPgmName == wxT( "pcb_calculator" ) )
362 {
363 // pcb_calculator installs as pcbcalculator to satisfy freedesktop naming rules.
364 wxString appName = aPgmName == wxT( "pcb_calculator" ) ? wxT( "pcbcalculator" ) : aPgmName;
365 return wxString( wxT( KICAD_DESKTOP_APP_PREFIX ) ) + wxT( "." ) + appName;
366 }
367#endif
368
369 return wxEmptyString;
370}
371
372
373bool PGM_BASE::InitPgm( bool aHeadless, bool aIsUnitTest )
374{
375#if defined( __WXMAC__ )
376 // Set the application locale to the system default
377 wxLogNull noLog;
378 wxLocale loc;
379 loc.Init();
380#endif
381
382 // Just make sure we init precreate any folders early for later code
383 // In particular, the user cache path is the most likely to be hit by startup code
385
387
389
390 // Initialize the singleton instance
391 m_singleton.Init();
392
393 wxString pgm_name;
394
396 if( App().argc == 0 )
397 pgm_name = wxT( "kicad" );
398 else
399 pgm_name = wxFileName( App().argv[0] ).GetName().Lower();
400
401 APP_MONITOR::SENTRY::Instance()->AddTag( "kicad.app", pgm_name );
402
403 wxInitAllImageHandlers();
404
405 // libpng warnings such as "iCCP: known incorrect sRGB profile" otherwise pop up for
406 // benign plugin and user images; load failures are still reported by the callers
407 wxImage::SetDefaultLoadFlags( wxImage::GetDefaultLoadFlags() & ~wxImage::Load_Verbose );
408
409#if !wxCHECK_VERSION( 3, 3, 0 )
410 // Without this the wxPropertyGridManager segfaults on Windows.
411 if( !wxPGGlobalVars )
412 wxPGInitResourceModule();
413#endif
414
415#ifndef __WINDOWS__
416 if( wxString( wxGetenv( "HOME" ) ).IsEmpty() )
417 {
418 DisplayErrorMessage( nullptr, _( "Environment variable HOME is empty. "
419 "Unable to continue." ) );
420 return false;
421 }
422#endif
423
424 // Init KiCad environment
425 // the environment variable KICAD (if exists) gives the kicad path:
426 // something like set KICAD=d:\kicad
427 bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_kicad_env );
428
429 if( isDefined ) // ensure m_kicad_env ends by "/"
430 {
432
433 if( !m_kicad_env.IsEmpty() && m_kicad_env.Last() != '/' )
435 }
436
437 // Init parameters for configuration
438 App().SetVendorName( wxT( "KiCad" ) );
439 App().SetAppName( pgm_name );
440
442
443#if defined( __WXGTK__ ) && defined( KICAD_DESKTOP_APP_NAME )
444 // On wx >= 3.3.1 wxGTK feeds the class name to gdk_wayland_window_set_application_id(),
445 // which lets Wayland compositors resolve the correct window icon and launch feedback. The
446 // X11 WM_CLASS is applied per window in EDA_BASE_FRAME instead, because wxGTK derives it
447 // from the (human-facing) app display name and would otherwise not match the launcher.
448 if( !m_desktopAppId.IsEmpty() )
449 App().SetClassName( m_desktopAppId );
450#endif
451
452 // Analyze the command line & initialize the binary path
453 wxString tmp;
455 SetDefaultLanguage( tmp );
456
457#ifdef _MSC_VER
458 if( !wxGetEnv( "FONTCONFIG_PATH", NULL ) )
459 {
460 // We need to set this because the internal fontconfig logic
461 // seems to search relative to the dll rather the other logic it
462 // has to look for the /etc folder above the dll
463 // Also don't set it because we need it in QA cli tests to be set by ctest
464 wxSetEnv( "FONTCONFIG_PATH", PATHS::GetWindowsFontConfigDir() );
465 }
466#endif
467
468#ifdef _MSC_VER
469 winrt::init_apartment(winrt::apartment_type::single_threaded);
470#endif
471
472 m_settings_manager = std::make_unique<SETTINGS_MANAGER>();
473 m_library_manager = std::make_unique<LIBRARY_MANAGER>();
474 m_background_jobs_monitor = std::make_unique<BACKGROUND_JOBS_MONITOR>();
475 m_notifications_manager = std::make_unique<NOTIFICATIONS_MANAGER>();
476
477 m_plugin_manager = std::make_unique<API_PLUGIN_MANAGER>( &App() );
478
479 // Our unit test mocks break if we continue
480 // A bug caused InitPgm to terminate early in unit tests and the mocks are...simplistic
481 // TODO fix the unit tests so this can be removed
482 if( aIsUnitTest )
483 return false;
484
485 // Something got in the way of settings load: can't continue
486 if( !m_settings_manager->IsOK() )
487 return false;
488
489 // Set up built-in environment variables (and override them from the system environment if set)
490 COMMON_SETTINGS* commonSettings = GetCommonSettings();
491 commonSettings->InitializeEnvironment();
492
493 // Load color settings after env is initialized
494 m_settings_manager->ReloadColorSettings();
495
496 // Load common settings from disk after setting up env vars
497 GetSettingsManager().Load( commonSettings );
498
499 // If user doesn't have a saved Python interpreter, try (potentially again) to find one
500 if( commonSettings->m_Api.python_interpreter.IsEmpty() )
502
503 // Init user language *before* calling loadSettings, because
504 // env vars could be incorrectly initialized on Linux
505 // (if the value contains some non ASCII7 chars, the env var is not initialized)
506 SetLanguage( tmp, true );
507
508 // Now that translations are available, inform the user if the OS is unsupported
510
512
513 ReadPdfBrowserInfos(); // needs GetCommonSettings()
514
516
517 // TODO(JE): Remove this if apps are refactored to not assume Prj() always works
518 // Need to create a project early for now (it can have an empty path for the moment)
520
521 if( commonSettings->m_Api.enable_server )
522 m_plugin_manager->ReloadPlugins();
523
524 // This sets the maximum tooltip display duration to 10s (up from 5) but only affects
525 // Windows as other platforms display tooltips while the mouse is not moving
526 if( !aHeadless )
527 {
528 wxToolTip::Enable( true );
529 wxToolTip::SetAutoPop( 10000 );
530 }
531
532 if( ADVANCED_CFG::GetCfg().m_UpdateUIEventInterval != 0 )
533 wxUpdateUIEvent::SetUpdateInterval( ADVANCED_CFG::GetCfg().m_UpdateUIEventInterval );
534
535#if defined( __WXMSW__ ) || defined( __WXOSX__ )
536 // wx ends a session by closing the top window with an ordinary close event. Calling wx's handler
537 // here instead of Skip() keeps that close inside the flag's scope
538 if( !aHeadless )
539 {
540 App().Bind( wxEVT_QUERY_END_SESSION,
541 [this]( wxCloseEvent& aEvent )
542 {
543 SCOPED_SET_RESET<bool> sessionEnding( m_sessionEnding, true );
544 App().OnQueryEndSession( aEvent );
545 } );
546
547 App().Bind( wxEVT_END_SESSION,
548 [this]( wxCloseEvent& aEvent )
549 {
550 SCOPED_SET_RESET<bool> sessionEnding( m_sessionEnding, true );
551 App().OnEndSession( aEvent );
552 } );
553 }
554#endif
555
556 // Now the application can safely start, show the splash screen
557 if( !aHeadless )
558 ShowSplash();
559
560 return true;
561}
562
563
565{
567
568 for( const std::pair<wxString, ENV_VAR_ITEM> it : GetCommonSettings()->m_Env.vars )
569 {
570 wxLogTrace( traceEnvVars, wxT( "PGM_BASE::loadSettings: Found entry %s = %s" ),
571 it.first, it.second.GetValue() );
572
573 // Do not store the env var PROJECT_VAR_NAME ("KIPRJMOD") definition if for some reason
574 // it is found in config. (It is reserved and defined as project path)
575 if( it.first == PROJECT_VAR_NAME )
576 continue;
577
578 // Don't set bogus empty entries in the environment
579 if( it.first.IsEmpty() )
580 continue;
581
582 // Do not overwrite vars set by the system environment with values from the settings file
583 if( it.second.GetDefinedExternally() )
584 continue;
585
586 SetLocalEnvVariable( it.first, it.second.GetValue() );
587 }
588}
589
590
592{
593 // GetCommonSettings() is not initialized until fairly late in the
594 // process startup: InitPgm(), so test before using:
595 if( GetCommonSettings() && IsGUI() )
596 GetCommonSettings()->m_System.working_dir = wxGetCwd();
597}
598
599
601{
602 return m_settings_manager ? m_settings_manager->GetCommonSettings() : nullptr;
603}
604
605
606bool PGM_BASE::SetLanguage( wxString& aErrMsg, bool first_time )
607{
608 // Suppress wxWidgets error popups if locale is not found
609 wxLogNull doNotLog;
610
611 if( first_time )
612 {
613 setLanguageId( wxLANGUAGE_DEFAULT );
614
615 // First time SetLanguage is called, the user selected language id is set
616 // from common user config settings
617 wxString languageSel = GetCommonSettings()->m_System.language;
618
619 // Search for the current selection
620 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
621 {
622 if( LanguagesList[ii].m_Lang_Label == languageSel )
623 {
624 setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
625 break;
626 }
627 }
628 }
629
630 // dictionary file name without extend (full name is kicad.mo)
631 wxString dictionaryName( wxT( "kicad" ) );
632
633 delete m_locale;
634 m_locale = new wxLocale;
635
636 // don't use wxLOCALE_LOAD_DEFAULT flag so that Init() doesn't return
637 // false just because it failed to load wxstd catalog
638 if( !m_locale->Init( m_language_id ) )
639 {
640 wxLogTrace( traceLocale, wxT( "This language is not supported by the system." ) );
641
642 setLanguageId( wxLANGUAGE_DEFAULT );
643 delete m_locale;
644
645 m_locale = new wxLocale;
646 m_locale->Init( wxLANGUAGE_DEFAULT );
647
648 aErrMsg = _( "This language is not supported by the operating system." );
649 return false;
650 }
651 else if( !first_time )
652 {
653 wxLogTrace( traceLocale, wxT( "Search for dictionary %s.mo in %s" ) ,
654 dictionaryName, m_locale->GetName() );
655 }
656
657 if( !first_time )
658 {
659 // If we are here, the user has selected another language.
660 // Therefore the new preferred language name is stored in common config.
661 // Do NOT store the wxWidgets language Id, it can change between wxWidgets
662 // versions, for a given language
663 wxString languageSel;
664
665 // Search for the current selection language name
666 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
667 {
668 if( LanguagesList[ii].m_WX_Lang_Identifier == m_language_id )
669 {
670 languageSel = LanguagesList[ii].m_Lang_Label;
671 break;
672 }
673 }
674
676 cfg->m_System.language = languageSel;
677 cfg->SaveToFile( GetSettingsManager().GetPathForSettingsFile( cfg ) );
678 }
679
680 // Try adding the dictionary if it is not currently loaded
681 if( !m_locale->IsLoaded( dictionaryName ) )
682 m_locale->AddCatalog( dictionaryName );
683
684 // Verify the Kicad dictionary was loaded properly
685 // However, for the English language, the dictionary is not mandatory, as
686 // all messages are already in English, just restricted to ASCII7 chars,
687 // the verification is skipped.
688 if( !m_locale->IsLoaded( dictionaryName ) && m_language_id != wxLANGUAGE_ENGLISH )
689 {
690 wxLogTrace( traceLocale, wxT( "Unable to load dictionary %s.mo in %s" ),
691 dictionaryName, m_locale->GetName() );
692
693 setLanguageId( wxLANGUAGE_DEFAULT );
694 delete m_locale;
695
696 m_locale = new wxLocale;
697 m_locale->Init( wxLANGUAGE_DEFAULT );
698
699 aErrMsg = _( "The KiCad language file for this language is not installed." );
700 return false;
701 }
702
703 return true;
704}
705
706
707bool PGM_BASE::SetDefaultLanguage( wxString& aErrMsg )
708{
709 // Suppress error popups from wxLocale
710 wxLogNull doNotLog;
711
712 setLanguageId( wxLANGUAGE_DEFAULT );
713
714 // dictionary file name without extend (full name is kicad.mo)
715 wxString dictionaryName( wxT( "kicad" ) );
716
717 delete m_locale;
718 m_locale = new wxLocale;
719 m_locale->Init();
720
721 // Try adding the dictionary if it is not currently loaded
722 if( !m_locale->IsLoaded( dictionaryName ) )
723 m_locale->AddCatalog( dictionaryName );
724
725 // Verify the Kicad dictionary was loaded properly
726 // However, for the English language, the dictionary is not mandatory, as
727 // all messages are already in English, just restricted to ASCII7 chars,
728 // the verification is skipped.
729 if( !m_locale->IsLoaded( dictionaryName ) && m_language_id != wxLANGUAGE_ENGLISH )
730 {
731 wxLogTrace( traceLocale, wxT( "Unable to load dictionary %s.mo in %s" ),
732 dictionaryName, m_locale->GetName() );
733
734 setLanguageId( wxLANGUAGE_DEFAULT );
735 delete m_locale;
736
737 m_locale = new wxLocale;
738 m_locale->Init();
739
740 aErrMsg = _( "The KiCad language file for this language is not installed." );
741 return false;
742 }
743
744 return true;
745}
746
747
749{
750 wxLogTrace( traceLocale, wxT( "Select language ID %d from %d possible languages." ),
751 menu_id, (int)arrayDim( LanguagesList )-1 );
752
753 for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
754 {
755 if( menu_id == LanguagesList[ii].m_KI_Lang_Identifier )
756 {
757 setLanguageId( LanguagesList[ii].m_WX_Lang_Identifier );
758 break;
759 }
760 }
761}
762
763
765{
766 const wxLanguageInfo* langInfo = wxLocale::GetLanguageInfo( m_language_id );
767
768 if( !langInfo )
769 {
770 return "";
771 }
772 else
773 {
774 wxString str = langInfo->GetCanonicalWithRegion();
775 str.Replace( "_", "-" );
776
777 return str;
778 }
779}
780
781
783{
784#ifdef _MSC_VER
785 wxLocale::AddCatalogLookupPathPrefix( PATHS::GetWindowsBaseSharePath() + wxT( "locale" ) );
786#endif
787 wxLocale::AddCatalogLookupPathPrefix( PATHS::GetLocaleDataPath() );
788
790 {
791 wxFileName fn( Pgm().GetExecutablePath() );
792 fn.RemoveLastDir();
793 fn.AppendDir( wxT( "translation" ) );
794 wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
795 }
796}
797
798
799bool PGM_BASE::SetLocalEnvVariable( const wxString& aName, const wxString& aValue )
800{
801 wxString env;
802
803 if( aName.IsEmpty() )
804 {
805 wxLogTrace( traceEnvVars,
806 wxT( "PGM_BASE::SetLocalEnvVariable: Attempt to set empty variable to "
807 "value %s" ),
808 aValue );
809 return false;
810 }
811
812 // Check to see if the environment variable is already set.
813 if( wxGetEnv( aName, &env ) )
814 {
815 wxLogTrace( traceEnvVars,
816 wxT( "PGM_BASE::SetLocalEnvVariable: Environment variable %s already set "
817 "to %s" ),
818 aName, env );
819 return env == aValue;
820 }
821
822 wxLogTrace( traceEnvVars,
823 wxT( "PGM_BASE::SetLocalEnvVariable: Setting local environment variable %s to %s" ),
824 aName, aValue );
825
826 return wxSetEnv( aName, aValue );
827}
828
829
831{
832 // Overwrites externally defined environment variable until the next time the application
833 // is run.
834 for( const std::pair<wxString, ENV_VAR_ITEM> m_local_env_var : GetCommonSettings()->m_Env.vars )
835 {
836 wxLogTrace( traceEnvVars,
837 wxT( "PGM_BASE::SetLocalEnvVariables: Setting local environment variable %s "
838 "to %s" ),
839 m_local_env_var.first,
840 m_local_env_var.second.GetValue() );
841 wxSetEnv( m_local_env_var.first, m_local_env_var.second.GetValue() );
842 }
843}
844
845
850
851
853{
854 if( !wxTheApp )
855 return false;
856
857 return wxTheApp->IsGUI();
858}
859
860
861void PGM_BASE::HandleException( std::exception_ptr aPtr, bool aUnhandled )
862{
863 try
864 {
865 if( aPtr )
866 std::rethrow_exception( aPtr );
867 }
868 catch( const IO_ERROR& ioe )
869 {
870 wxLogError( ioe.What() );
871
872 if( aUnhandled )
873 {
874 // Log this IO_ERROR escaped our usual uses (bad)
875 APP_MONITOR::SENTRY::Instance()->LogException( ioe.What(), aUnhandled );
876 }
877 }
878 catch( const std::exception& e )
879 {
880 APP_MONITOR::SENTRY::Instance()->LogException( e.what(), aUnhandled );
881
882 wxLogError( wxT( "Unhandled exception class: %s what: %s" ),
883 From_UTF8( typeid( e ).name() ), From_UTF8( e.what() ) );
884 }
885 catch( ... )
886 {
887 // We really shouldn't have these but just in case...
888 wxLogError( wxT( "Unhandled exception of unknown type" ) );
889
890 if( aUnhandled )
891 {
892 APP_MONITOR::SENTRY::Instance()->LogException( "Unhandled exception of unknown type", aUnhandled );
893 }
894 }
895}
896
897
898void PGM_BASE::HandleAssert( const wxString& aFile, int aLine, const wxString& aFunc,
899 const wxString& aCond, const wxString& aMsg )
900{
901 wxString assertStr;
902
903 // Log the assertion details to standard log
904 if( !aMsg.empty() )
905 {
906 assertStr = wxString::Format( "Assertion failed at %s:%d in %s: %s - %s", aFile, aLine,
907 aFunc, aCond, aMsg );
908 }
909 else
910 {
911 assertStr = wxString::Format( "Assertion failed at %s:%d in %s: %s", aFile, aLine, aFunc,
912 aCond );
913 }
914
915#ifndef NDEBUG
916 wxLogError( assertStr );
917#endif
918
919#ifdef KICAD_USE_SENTRY
920 APP_MONITOR::ASSERT_CACHE_KEY key = { aFile, aLine, aFunc, aCond };
921 APP_MONITOR::SENTRY::Instance()->LogAssert( key, assertStr );
922#endif
923}
924
925
926const wxString& PGM_BASE::GetExecutablePath() const
927{
929}
930
931
937
938
944
945
947{
948 if( m_libraryPreloadInProgress.load() )
949 return;
950
952 Pgm().GetBackgroundJobMonitor().Create( _( "Loading Design Block Libraries" ) );
953
954 auto preload =
955 [this, aKiway]() -> void
956 {
957 // A task that starts after its cancel must not reach the project that is going away
958 if( m_libraryPreloadAbort.load() )
959 {
960 m_libraryPreloadAbort.store( false );
963 m_libraryPreloadInProgress.store( false );
964 return;
965 }
966
967 std::shared_ptr<BACKGROUND_JOB_REPORTER> reporter =
969
970 DESIGN_BLOCK_LIBRARY_ADAPTER* adapter = aKiway->Prj().DesignBlockLibs();
971
972 reporter->Report( _( "Loading Design Block Libraries" ) );
974
977 m_libraryPreloadInProgress.store( false );
978
979 std::string payload = "";
980 aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload, nullptr, true );
981 aKiway->ExpressMail( FRAME_PCB_EDITOR, MAIL_RELOAD_LIB, payload, nullptr, true );
982 };
983
984 // The preload waits on loads it queues on the pool, so it must not hold a pool thread itself
985 m_libraryPreloadInProgress.store( true );
986 m_libraryPreloadReturn = std::async( std::launch::async, preload );
987}
988
989
991{
992 if( m_libraryPreloadReturn.valid() )
993 m_libraryPreloadAbort.store( true );
994}
995
996
998{
999 if( m_libraryPreloadReturn.valid() )
1001
1002 // The preload has ended, so a flag it never read can only stop the next one
1003 m_libraryPreloadAbort.store( false );
1004}
1005
1006
1008{
1009 std::lock_guard<std::mutex> lock( m_libraryLoadStatusBarsMutex );
1010
1011 wxLogTrace( traceLibraries, "RegisterLibraryLoadStatusBar: statusBar=%p", aStatusBar );
1012
1013 if( std::find( m_libraryLoadStatusBars.begin(), m_libraryLoadStatusBars.end(), aStatusBar )
1014 == m_libraryLoadStatusBars.end() )
1015 {
1016 m_libraryLoadStatusBars.push_back( aStatusBar );
1017 wxLogTrace( traceLibraries, " -> registered, total count=%zu",
1018 m_libraryLoadStatusBars.size() );
1019 }
1020 else
1021 {
1022 wxLogTrace( traceLibraries, " -> already registered" );
1023 }
1024}
1025
1026
1028{
1029 std::lock_guard<std::mutex> lock( m_libraryLoadStatusBarsMutex );
1030
1031 wxLogTrace( traceLibraries, "UnregisterLibraryLoadStatusBar: statusBar=%p", aStatusBar );
1032
1034 std::remove( m_libraryLoadStatusBars.begin(), m_libraryLoadStatusBars.end(),
1035 aStatusBar ),
1037
1038 wxLogTrace( traceLibraries, " -> remaining count=%zu", m_libraryLoadStatusBars.size() );
1039}
1040
1041
1042void PGM_BASE::AddLibraryLoadMessages( const std::vector<KI_ERROR>& aMessages )
1043{
1044 wxLogTrace( traceLibraries, "AddLibraryLoadMessages: message_count=%zu", aMessages.size() );
1045
1046 if( aMessages.empty() )
1047 return;
1048
1049 std::lock_guard<std::mutex> lock( m_libraryLoadStatusBarsMutex );
1050
1051 wxLogTrace( traceLibraries, " -> registered status bars=%zu",
1052 m_libraryLoadStatusBars.size() );
1053
1054 for( KISTATUSBAR* statusBar : m_libraryLoadStatusBars )
1055 {
1056 if( statusBar )
1057 {
1058 wxLogTrace( traceLibraries, " -> forwarding to statusBar=%p", statusBar );
1059 statusBar->AddWarningMessages( "load", aMessages );
1060 }
1061 }
1062}
1063
1064
1066{
1067 std::lock_guard<std::mutex> lock( m_libraryLoadStatusBarsMutex );
1068
1069 wxLogTrace( traceLibraries, "ClearLibraryLoadMessages: status bars=%zu",
1070 m_libraryLoadStatusBars.size() );
1071
1072 for( KISTATUSBAR* statusBar : m_libraryLoadStatusBars )
1073 {
1074 if( statusBar )
1075 statusBar->ClearWarningMessages( "load" );
1076 }
1077}
1078
1079
1080int PGM_BASE::FilterAppEvent( wxEvent& aEvent )
1081{
1082 // Windows hear a theme switch in no set order, and each reloads its icons from the store
1083 if( aEvent.GetEventType() == wxEVT_SYS_COLOUR_CHANGED )
1085
1086 if( aEvent.GetEventType() == wxEVT_SHOW )
1087 {
1088 wxShowEvent& event = static_cast<wxShowEvent&>( aEvent );
1089 wxDialog* dialog = dynamic_cast<wxDialog*>( event.GetEventObject() );
1090
1091 if( dialog )
1092 {
1093 if( event.IsShown() && dialog->IsModal() )
1094 {
1095 m_ModalDialogs.push_back( dialog );
1096 }
1097 // Under GTK, sometimes the modal flag is cleared before hiding
1098 else if( !event.IsShown() && !m_ModalDialogs.empty() )
1099 {
1100 // If we close the expected dialog, remove it from our stack
1101 if( m_ModalDialogs.back() == dialog )
1102 m_ModalDialogs.pop_back();
1103 // If an out-of-order, remove all dialogs added after the closed one
1104 else if( auto it = std::ranges::find( m_ModalDialogs, dialog ); it != m_ModalDialogs.end() )
1105 m_ModalDialogs.erase( it, m_ModalDialogs.end() );
1106 }
1107 }
1108 }
1109
1110 return wxEventFilter::Event_Skip;
1111}
1112
1113
1115
1116
1118{
1119 wxASSERT( process ); // KIFACE_GETTER has already been called.
1120 return *process;
1121}
1122
1123
1124// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script.
1126{
1127 return process;
1128}
1129
1130
1131void SetPgm( PGM_BASE* pgm )
1132{
1133 process = pgm;
1134}
const char * name
void ExitFastIfAccessWorkerAbandoned(int aExitCode)
Ends the process without the normal teardown when an Access engine worker was abandoned,...
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition arraydim.h:27
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition bitmap.cpp:100
BITMAP_STORE * GetBitmapStore()
Definition bitmap.cpp:88
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void LogAssert(const ASSERT_CACHE_KEY &aKey, const wxString &aMsg)
void LogException(const wxString &aMsg, bool aUnhandled)
void AddTag(const wxString &aKey, const wxString &aValue)
static SENTRY * Instance()
std::shared_ptr< BACKGROUND_JOB > Create(const wxString &aName)
Creates a background job with the given name.
void Remove(std::shared_ptr< BACKGROUND_JOB > job)
Removes the given background job from any lists and frees it.
void ThemeChanged()
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated.
void InitializeEnvironment()
Creates the built-in environment variables and sets their default values.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
Calls Store() and then writes the contents of the JSON document to a file.
static void Cleanup()
Call curl_global_cleanup for the application.
static void Init()
Call curl_global_init for the application.
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
Definition kistatusbar.h:50
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:348
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr, bool aFromOtherThread=false)
Send aPayload to aDestination from aSource.
Definition kiway.cpp:511
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition kiway.cpp:210
bool RunPreload(PROGRESS_REPORTER &aReporter, std::atomic_bool &aAbort)
Starts AsyncLoad() and waits for it on the calling thread, reporting progress to aReporter.
void Load()
Load notifications stored from disk.
static bool RunningFromBuildDir()
True when KiCad runs from its build tree or KICAD_RUN_FROM_BUILD_DIR is set.
Definition paths.cpp:743
static void EnsureUserPathsExist()
Ensures/creates user default paths.
Definition paths.cpp:497
static wxString GetLocaleDataPath()
Gets the locales translation data path.
Definition paths.cpp:328
static const wxString & GetExecutablePath()
Definition paths.cpp:623
Container for data for KiCad programs.
Definition pgm_base.h:102
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:600
virtual wxApp & App()
Return a bare naked wxApp which may come from wxPython, SINGLE_TOP, or kicad.exe.
Definition pgm_base.cpp:236
std::unique_ptr< NOTIFICATIONS_MANAGER > m_notifications_manager
Definition pgm_base.h:445
void ExitIfTeardownUnsafe()
Ends the process at once when a worker abandoned inside a native driver makes the rest of the teardow...
Definition pgm_base.cpp:230
void PreloadDesignBlockLibraries(KIWAY *aKiway)
Starts a background job to preload the global and project design block libraries.
Definition pgm_base.cpp:946
int m_argcUtf8
Definition pgm_base.h:478
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition pgm_base.cpp:846
void WaitForDesignBlockPreload()
Waits for the design block preload to end, so it no longer reaches the project, and clears the cancel...
Definition pgm_base.cpp:997
std::unique_ptr< LIBRARY_MANAGER > m_library_manager
Definition pgm_base.h:443
bool m_Printing
wxWidgets on MSW tends to crash if you spool up more than one print job at a time.
Definition pgm_base.h:421
void setLanguageId(int aId)
Trap all changes in here, simplifies debugging.
Definition pgm_base.h:434
std::unique_ptr< API_PLUGIN_MANAGER > m_plugin_manager
Definition pgm_base.h:447
std::unique_ptr< SETTINGS_MANAGER > m_settings_manager
Definition pgm_base.h:442
void loadCommonSettings()
Load internal settings from COMMON_SETTINGS.
Definition pgm_base.cpp:564
virtual void SetPdfBrowserName(const wxString &aFileName)
Definition pgm_base.h:179
std::vector< KISTATUSBAR * > m_libraryLoadStatusBars
Definition pgm_base.h:489
wxLocale * m_locale
Definition pgm_base.h:454
int FilterAppEvent(wxEvent &aEvent)
Handle events that must be seen once per application, before any window processes them.
void Destroy()
Definition pgm_base.cpp:190
wxSplashScreen * m_splash
Definition pgm_base.h:480
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition pgm_base.h:130
char ** m_argvUtf8
argv parameters converted to utf8 form because wxWidgets has opinions.
Definition pgm_base.h:476
BS::priority_thread_pool & GetThreadPool()
Definition pgm_base.cpp:150
void UnregisterLibraryLoadStatusBar(KISTATUSBAR *aStatusBar)
Unregister a status bar from receiving library load warning messages.
void AddLibraryLoadMessages(const std::vector< KI_ERROR > &aMessages)
Add library load messages to all registered status bars.
virtual void ReadPdfBrowserInfos()
Read the PDF browser choice from the common configuration.
Definition pgm_base.cpp:932
void HandleException(std::exception_ptr aPtr, bool aUnhandled=false)
A exception handler to be used at the top level if exceptions bubble up that for.
Definition pgm_base.cpp:861
bool IsGUI()
Determine if the application is running with a GUI.
Definition pgm_base.cpp:852
bool m_use_system_pdf_browser
Definition pgm_base.h:457
bool m_Quitting
Definition pgm_base.h:425
void CancelDesignBlockPreload()
Asks the design block preload to stop, without waiting for it.
Definition pgm_base.cpp:990
void RegisterLibraryLoadStatusBar(KISTATUSBAR *aStatusBar)
Register a status bar to receive library load warning messages.
std::future< void > m_libraryPreloadReturn
Definition pgm_base.h:485
virtual NOTIFICATIONS_MANAGER & GetNotificationsManager() const
Definition pgm_base.h:135
std::shared_ptr< BACKGROUND_JOB > m_libraryPreloadBackgroundJob
Definition pgm_base.h:484
void BuildArgvUtf8()
Builds the UTF8 based argv variable.
Definition pgm_base.cpp:307
virtual const wxString & GetPdfBrowserName() const
Definition pgm_base.h:177
std::atomic_bool m_libraryPreloadAbort
Definition pgm_base.h:487
void ClearLibraryLoadMessages()
Clear library load messages from all registered status bars.
virtual void SetTextEditor(const wxString &aFileName)
Definition pgm_base.cpp:243
std::vector< void * > m_ModalDialogs
Definition pgm_base.h:423
virtual bool SetLocalEnvVariable(const wxString &aName, const wxString &aValue)
Set the environment variable aName to aValue.
Definition pgm_base.cpp:799
bool InitPgm(bool aHeadless=false, bool aIsUnitTest=false)
Initialize this program.
Definition pgm_base.cpp:373
wxString m_kicad_env
The KICAD system environment variable.
Definition pgm_base.h:450
virtual void ForceSystemPdfBrowser(bool aFlg)
Force the use of system PDF browser, even if a preferred PDF browser is set.
Definition pgm_base.h:194
int m_runResult
Definition pgm_base.h:482
virtual void SetLocalEnvVariables()
Update the local environment with the contents of the current ENV_VAR_MAP stored in the COMMON_SETTIN...
Definition pgm_base.cpp:830
virtual void SetLanguagePath()
Definition pgm_base.cpp:782
bool SetDefaultLanguage(wxString &aErrMsg)
Set the default language without reference to any preferences.
Definition pgm_base.cpp:707
void ShowSplash()
Definition pgm_base.cpp:322
wxString m_text_editor
Definition pgm_base.h:460
std::atomic_bool m_libraryPreloadInProgress
Definition pgm_base.h:486
virtual ~PGM_BASE()
Definition pgm_base.cpp:173
bool m_sessionEnding
Set while wx handles a session-end event.
Definition pgm_base.h:461
wxString m_desktopAppId
freedesktop app id of this process, or empty.
Definition pgm_base.h:452
virtual void SetLanguageIdentifier(int menu_id)
Set in .m_language_id member the wxWidgets language identifier ID from the KiCad menu id (internal me...
Definition pgm_base.cpp:748
int m_language_id
Definition pgm_base.h:455
std::unique_ptr< BACKGROUND_JOBS_MONITOR > m_background_jobs_monitor
Definition pgm_base.h:444
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.
Definition pgm_base.cpp:898
virtual wxString GetLanguageTag()
Definition pgm_base.cpp:764
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
Definition pgm_base.cpp:250
virtual const wxString & GetExecutablePath() const
Definition pgm_base.cpp:926
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:124
void HideSplash()
Definition pgm_base.cpp:341
virtual void WritePdfBrowserInfos()
Save the PDF browser choice to the common configuration.
Definition pgm_base.cpp:939
static wxString DesktopAppIdForProgram(const wxString &aPgmName)
Map a program name (argv[0] basename, lowercased) to the freedesktop application id of its installed ...
Definition pgm_base.cpp:352
void SaveCommonSettings()
Save the program (process) settings subset which are stored .kicad_common.
Definition pgm_base.cpp:591
bool m_PropertyGridInitialized
Definition pgm_base.h:427
KICAD_SINGLETON m_singleton
Definition pgm_base.h:463
std::mutex m_libraryLoadStatusBarsMutex
Definition pgm_base.h:490
virtual const wxString AskUserForPreferredEditor(const wxString &aDefaultEditor=wxEmptyString)
Show a dialog that instructs the user to select a new preferred editor.
Definition pgm_base.cpp:286
virtual bool SetLanguage(wxString &aErrMsg, bool first_time=false)
Set the dictionary file name for internationalization.
Definition pgm_base.cpp:606
virtual DESIGN_BLOCK_LIBRARY_ADAPTER * DesignBlockLibs()
Return the table of design block libraries.
Definition project.cpp:527
static wxString FindPythonInterpreter()
Searches for a Python intepreter on the user's system.
RAII class that sets an value at construction and resets it to the original value at destruction.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true, bool aOverrideLock=false)
Load a project or sets up a new project with a specified path.
bool WarnUserIfOperatingSystemUnsupported()
Checks if the operating system is explicitly unsupported and displays a disclaimer message box.
Definition common.cpp:1033
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:245
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
This file is part of the common library.
#define _(s)
@ FRAME_PCB_EDITOR
Definition frame_type.h:38
@ FRAME_SCH
Definition frame_type.h:30
#define WIN_STRING_DIR_SEP
Definition gestfich.h:42
#define UNIX_STRING_DIR_SEP
Definition gestfich.h:41
const wxChar *const traceLibraries
Flag to enable library table and library manager tracing.
const wxChar *const traceLocale
Flag to enable locale debug output.
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.
@ ID_LANGUAGE_SWEDISH
Definition id.h:97
@ ID_LANGUAGE_CATALAN
Definition id.h:86
@ ID_LANGUAGE_NORWEGIAN_BOKMAL
Definition id.h:104
@ ID_LANGUAGE_CHINESE_SIMPLIFIED
Definition id.h:87
@ ID_LANGUAGE_GERMAN
Definition id.h:71
@ ID_LANGUAGE_DUTCH
Definition id.h:89
@ ID_LANGUAGE_FARSI
Definition id.h:101
@ ID_LANGUAGE_GREEK
Definition id.h:72
@ ID_LANGUAGE_HUNGARIAN
Definition id.h:82
@ ID_LANGUAGE_LITHUANIAN
Definition id.h:93
@ ID_LANGUAGE_TAMIL
Definition id.h:105
@ ID_LANGUAGE_ESTONIAN
Definition id.h:100
@ ID_LANGUAGE_HINDI
Definition id.h:107
@ ID_LANGUAGE_PORTUGUESE_BRAZILIAN
Definition id.h:76
@ ID_LANGUAGE_DEFAULT
Definition id.h:64
@ ID_LANGUAGE_POLISH
Definition id.h:83
@ ID_LANGUAGE_THAI
Definition id.h:96
@ ID_LANGUAGE_JAPANESE
Definition id.h:90
@ ID_LANGUAGE_VIETNAMESE
Definition id.h:94
@ ID_LANGUAGE_ITALIAN
Definition id.h:79
@ ID_LANGUAGE_KOREAN
Definition id.h:85
@ ID_LANGUAGE_SERBIAN
Definition id.h:95
@ ID_LANGUAGE_RUSSIAN
Definition id.h:74
@ ID_LANGUAGE_CZECH
Definition id.h:84
@ ID_LANGUAGE_TELUGU
Definition id.h:106
@ ID_LANGUAGE_GEORGIAN
Definition id.h:108
@ ID_LANGUAGE_LATVIAN
Definition id.h:92
@ ID_LANGUAGE_SLOVENIAN
Definition id.h:80
@ ID_LANGUAGE_SPANISH
Definition id.h:69
@ ID_LANGUAGE_PORTUGUESE
Definition id.h:75
@ ID_LANGUAGE_ENGLISH
Definition id.h:65
@ ID_LANGUAGE_CROATIAN
Definition id.h:102
@ ID_LANGUAGE_SPANISH_MEXICAN
Definition id.h:70
@ ID_LANGUAGE_SLOVAK
Definition id.h:81
@ ID_LANGUAGE_CHINESE_TRADITIONAL
Definition id.h:88
@ ID_LANGUAGE_FINNISH
Definition id.h:67
@ ID_LANGUAGE_BULGARIAN
Definition id.h:91
@ ID_LANGUAGE_ARABIC
Definition id.h:99
@ ID_LANGUAGE_UKRAINIAN
Definition id.h:98
@ ID_LANGUAGE_LAOTHIAN
Definition id.h:109
@ ID_LANGUAGE_TURKISH
Definition id.h:77
@ ID_LANGUAGE_DANISH
Definition id.h:63
@ ID_LANGUAGE_FRENCH
Definition id.h:66
@ ID_LANGUAGE_HEBREW
Definition id.h:68
@ ID_LANGUAGE_ROMANIAN
Definition id.h:103
@ ID_LANGUAGE_INDONESIAN
Definition id.h:78
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
This file contains miscellaneous commonly used macros and functions.
@ MAIL_RELOAD_LIB
Definition mail_type.h:55
thread_pool< 1 > priority_thread_pool
Definition singleton.h:31
void SetPgm(PGM_BASE *pgm)
static PGM_BASE * process
PGM_BASE & Pgm()
The global program "get" accessor.
PGM_BASE * PgmOrNull()
Return a reference that can be nullptr when running a shared lib from a script, not from a kicad app.
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition pgm_base.cpp:92
#define _(s)
Current list of languages supported by KiCad.
Definition pgm_base.cpp:91
see class PGM_BASE
KICOMMON_API LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition pgm_base.cpp:92
KICOMMON_API PGM_BASE & Pgm()
The global program "get" accessor.
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition project.h:37
APIIMPORT wxPGGlobalVarsClass * wxPGGlobalVars
wxString From_UTF8(const char *cstring)
This struct represents a key being used for the std::set that deduplicates asserts during this runnin...
Definition app_monitor.h:86
A small class to handle the list of existing translations.
Definition pgm_base.h:68
System directories search utilities.
std::string path
IbisParser parser & reporter
wxLogTrace helper definitions.