KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_manager_frame.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2013 CERN (www.cern.ch)
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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include "kicad_id.h"
27#include "pcm.h"
28#include "pgm_kicad.h"
29#include "project_tree_pane.h"
31
32#include <advanced_config.h>
34#include <bitmaps.h>
35#include <build_version.h>
36#include <confirm.h>
40#include <eda_base_frame.h>
41#include <executable_names.h>
42#include <file_history.h>
43#include <policy_keys.h>
44#include <gestfich.h>
45#include <kiplatform/app.h>
47#include <kiplatform/policy.h>
48#include <build_version.h>
49#include <kiway.h>
50#include <kiway_express.h>
51#include <launch_ext.h>
52#include <lockfile.h>
54#include <reporter.h>
56#include <sch_file_versions.h>
58#include <tool/action_manager.h>
59#include <tool/action_toolbar.h>
60#include <tool/common_control.h>
62#include <tool/tool_manager.h>
68#include <widgets/kistatusbar.h>
69#include <wx/ffile.h>
70#include <wx/filedlg.h>
71#include <wx/dnd.h>
72#include <wx/process.h>
73#include <wx/snglinst.h>
74#include <atomic>
75#include <update_manager.h>
76#include <jobs/jobset.h>
77
78#include <../pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h> // for SEXPR_BOARD_FILE_VERSION def
79
80
81#ifdef __WXMAC__
82#include <MacTypes.h>
83#include <ApplicationServices/ApplicationServices.h>
84#endif
85
86#include "kicad_manager_frame.h"
88
90
91
92#define EDITORS_CAPTION _( "Editors" )
93#define PROJECT_FILES_CAPTION _( "Project Files" )
94
95#define ID_INIT_WATCHED_PATHS 52913
96
97#define SEP() wxFileName::GetPathSeparator()
98
99
100// Menubar and toolbar event table
101BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
102 // Window events
105
106 // Menu events
107 EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
114
115 // Range menu events
117 KICAD_MANAGER_FRAME::language_change )
118
120 EVT_MENU( ID_FILE_LIST_CLEAR, KICAD_MANAGER_FRAME::OnClearFileHistory )
121
122 // Special functions
123 EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
124
125 // Drop files event
126 EVT_DROP_FILES( KICAD_MANAGER_FRAME::OnDropFiles )
127
128END_EVENT_TABLE()
129
130// See below the purpose of this include
131#include <wx/xml/xml.h>
132
133KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
134 const wxPoint& pos, const wxSize& size ) :
137 m_active_project( false ),
138 m_leftWin( nullptr ),
139 m_launcher( nullptr ),
140 m_lastToolbarIconSize( 0 ),
141 m_pcmButton( nullptr ),
142 m_pcmUpdateCount( 0 )
143{
144 const int defaultLeftWinWidth = FromDIP( 250 );
145
146 m_leftWinWidth = defaultLeftWinWidth; // Default value
147 m_aboutTitle = "KiCad";
148
149 // JPC: A very ugly hack to fix an issue on Linux: if the wxbase315u_xml_gcc_custom.so is
150 // used **only** in PCM, it is not found in some cases at run time.
151 // So just use it in the main module to avoid a not found issue
152 // wxbase315u_xml_gcc_custom shared object when launching Kicad
153 wxXmlDocument dummy;
154
155 // Create the status line (bottom of the frame). Left half is for project name; right half
156 // is for Reporter (currently used by archiver/unarchiver and PCM).
157 // Note: this is a KISTATUSBAR status bar. Therefore the specified number of fields
158 // is the extra number of fields, not the full field count.
159 // We need here 2 fields: the extra fiels to display the project name, and another field
160 // to display a info (specific to Windows) using the FIELD_OFFSET_BGJOB_TEXT id offset (=1)
161 // So the extra field count is 1
162 CreateStatusBar( 1 );
165 GetStatusBar()->SetFont( KIUI::GetStatusFont( this ) );
166
167 // Give an icon
168 wxIcon icon;
169 wxIconBundle icon_bundle;
170
171 if( IsNightlyVersion())
172 {
173 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly, 48 ) );
174 icon_bundle.AddIcon( icon );
175 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly, 128 ) );
176 icon_bundle.AddIcon( icon );
177 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly, 256 ) );
178 icon_bundle.AddIcon( icon );
179 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_32 ) );
180 icon_bundle.AddIcon( icon );
181 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_16 ) );
182 icon_bundle.AddIcon( icon );
183 }
184 else
185 {
186 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad, 48 ) );
187 icon_bundle.AddIcon( icon );
188 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad, 128 ) );
189 icon_bundle.AddIcon( icon );
190 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad, 256 ) );
191 icon_bundle.AddIcon( icon );
192 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_32 ) );
193 icon_bundle.AddIcon( icon );
194 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_16 ) );
195 icon_bundle.AddIcon( icon );
196 }
197
198 SetIcons( icon_bundle );
199
200 // Load the settings
201 LoadSettings( config() );
202
203 // Left window: is the box which display tree project
204 m_leftWin = new PROJECT_TREE_PANE( this );
205
206 setupTools();
207 setupUIConditions();
208
209 m_toolbarSettings = GetToolbarSettings<KICAD_MANAGER_TOOLBAR_SETTINGS>( "kicad-toolbars" );
210 configureToolbars();
211 RecreateToolbars();
212 ReCreateMenuBar();
213
214 m_auimgr.SetManagedWindow( this );
215 m_auimgr.SetFlags( wxAUI_MGR_LIVE_RESIZE );
216
217 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( "TopMainToolbar" ).Left().Layer( 2 ) );
218
219 // BestSize() does not always set the actual pane size of m_leftWin to the required value.
220 // It happens when m_leftWin is too large (roughly > 1/3 of the kicad manager frame width.
221 // (Well, BestSize() sets the best size... not the window size)
222 // A trick is to use MinSize() to set the required pane width,
223 // and after give a reasonable MinSize value
224 m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer( 1 )
225 .Caption( PROJECT_FILES_CAPTION ).PaneBorder( false )
226 .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) );
227
228 wxSize client_size = GetClientSize();
229 m_notebook = new wxAuiNotebook( this, wxID_ANY, wxPoint( client_size.x, client_size.y ),
230 FromDIP( wxSize( 700, 590 ) ),
231 wxAUI_NB_TOP | wxAUI_NB_CLOSE_ON_ALL_TABS | wxAUI_NB_TAB_MOVE
232 | wxAUI_NB_SCROLL_BUTTONS | wxNO_BORDER );
233
234 m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CLOSE, &KICAD_MANAGER_FRAME::onNotebookPageCloseRequest, this );
235 m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CLOSED, &KICAD_MANAGER_FRAME::onNotebookPageCountChanged, this );
236 m_launcher = new PANEL_KICAD_LAUNCHER( m_notebook );
237
238 m_notebook->Freeze();
239 m_launcher->SetClosable( false );
240 m_notebook->AddPage( m_launcher, EDITORS_CAPTION, false );
241 m_notebook->SetTabCtrlHeight( 0 );
242 m_notebook->Thaw();
243
244 m_auimgr.AddPane( m_notebook, EDA_PANE().Canvas().Name( "Editors" ).Center().Caption( EDITORS_CAPTION )
245 .PaneBorder( false ).MinSize( m_notebook->GetBestSize() ) );
246
247 m_auimgr.Update();
248
249 // Now the actual m_leftWin size is set, give it a reasonable min width
250 m_auimgr.GetPane( m_leftWin ).MinSize( defaultLeftWinWidth, -1 );
251
252
253 wxSizer* mainSizer = GetSizer();
254
255 // Only fit the initial window size the first time KiCad is run.
256 if( mainSizer && config()->m_Window.state.size_x == 0 && config()->m_Window.state.size_y == 0 )
257 {
258 Layout();
259 mainSizer->Fit( this );
260 Center();
261 }
262
263 if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
264 SetTitle( wxT( "KiCad" ) );
265 else
266 SetTitle( wxString( "KiCad " ) + GetMajorMinorVersion() );
267
268 // Do not let the messages window have initial focus
269 m_leftWin->SetFocus();
270
271 // Init for dropping files
274
275 // Gerber files
276 // Note that all gerber files are aliased as GerberFileExtension
280
281 DragAcceptFiles( true );
282
283 // Ensure the window is on top
284 Raise();
285}
286
287
289{
291 Unbind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
292
293 m_notebook->Unbind( wxEVT_AUINOTEBOOK_PAGE_CLOSE,
295 m_notebook->Unbind( wxEVT_AUINOTEBOOK_PAGE_CLOSED,
297
300
301 // Shutdown all running tools
302 if( m_toolManager )
304
305 if( m_pcm )
306 m_pcm->StopBackgroundUpdate();
307
308 delete m_actions;
309 delete m_toolManager;
310 delete m_toolDispatcher;
311
312 m_auimgr.UnInit();
313}
314
316{
317 if( m_notebook->GetPageCount() == 1 )
318 m_notebook->SetTabCtrlHeight( 0 );
319 else
320 m_notebook->SetTabCtrlHeight( -1 );
321}
322
323
325{
327}
328
329
331{
332 wxAuiNotebook* notebook = (wxAuiNotebook*) evt.GetEventObject();
333 wxWindow* page = notebook->GetPage( evt.GetSelection() );
334
335 if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
336 {
337 if( panel->GetClosable() )
338 {
339 if( !panel->GetCanClose() )
340 evt.Veto();
341
342 CallAfter(
343 [this]()
344 {
346 } );
347 }
348 else
349 {
350 evt.Veto();
351 }
352 }
353}
354
355
356wxStatusBar* KICAD_MANAGER_FRAME::OnCreateStatusBar( int number, long style, wxWindowID id,
357 const wxString& name )
358{
359 return new KISTATUSBAR( number, this, id );
360}
361
362
364{
365 // creates the PLUGIN_CONTENT_MANAGER, if not exists
366 if( m_pcm )
367 return;
368
369 m_pcm = std::make_shared<PLUGIN_CONTENT_MANAGER>(
370 [this]( int aUpdateCount )
371 {
372 m_pcmUpdateCount = aUpdateCount;
373
374 if( aUpdateCount > 0 )
375 {
377 wxS( "pcm" ),
378 _( "PCM Updates Available" ),
379 wxString::Format( _( "%d package update(s) avaliable" ), aUpdateCount ),
380 wxT( "" ) );
381 }
382 else
383 {
384 Pgm().GetNotificationsManager().Remove( wxS( "pcm" ) );
385 }
386
387 CallAfter(
388 [this]()
389 {
391 } );
392 });
393
394 m_pcm->SetRepositoryList( kicadSettings()->m_PcmRepositories );
395}
396
397
399{
400 // Create the manager
402 m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
404
406
407 // Attach the events to the tool dispatcher
409 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
410
411 // Register tools
415}
416
417
419{
421
423
424 wxASSERT( manager );
425
426 auto activeProject =
427 [this] ( const SELECTION& )
428 {
429 return m_active_project;
430 };
431
432#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
433
434 ACTION_CONDITIONS activeProjectCond;
435 activeProjectCond.Enable( activeProject );
436
437 manager->SetConditions( ACTIONS::saveAs, activeProjectCond );
438 manager->SetConditions( KICAD_MANAGER_ACTIONS::closeProject, activeProjectCond );
439 manager->SetConditions( KICAD_MANAGER_ACTIONS::archiveProject, activeProjectCond );
440 manager->SetConditions( KICAD_MANAGER_ACTIONS::newJobsetFile, activeProjectCond );
441 manager->SetConditions( KICAD_MANAGER_ACTIONS::openJobsetFile, activeProjectCond );
442
443 // These are just here for text boxes, search boxes, etc. in places such as the standard
444 // file dialogs.
448
449#undef ENABLE
450}
451
452
454{
455 return m_leftWin;
456}
457
458
460{
462 wxASSERT( ret );
463 return ret;
464}
465
466
468{
469 KICAD_SETTINGS* ret = dynamic_cast<KICAD_SETTINGS*>( config() );
470 wxASSERT( ret );
471 return ret;
472}
473
474
476{
478 wxString( wxEmptyString );
479}
480
481
483{
484 wxFileName fn( GetProjectFileName() );
485
487 return fn.GetFullPath();
488}
489
490
492{
493 wxFileName fn( GetProjectFileName() );
494
496 return fn.GetFullPath();
497}
498
499
501{
502 wxFileName fn( GetProjectFileName() );
503
504 fn.SetExt( FILEEXT::PcbFileExtension );
505 return fn.GetFullPath();
506}
507
508
510{
511 wxFileName fn( GetProjectFileName() );
512
514 return fn.GetFullPath();
515}
516
517
519{
521}
522
523
525{
526 return PgmTop().SysSearch();
527}
528
529
531{
532 return PgmTop().GetHelpFileName();
533}
534
535
536void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event )
537{
538 if( m_auimgr.GetManagedWindow() )
539 m_auimgr.Update();
540
541 PrintPrjInfo();
542
543#if defined( _WIN32 )
544 KISTATUSBAR* statusBar = static_cast<KISTATUSBAR*>( GetStatusBar() );
546#endif
547
548 event.Skip();
549}
550
551
553{
554 // All fileNames are now in m_AcceptedFiles vector.
555 // Check if contains a project file name and load project.
556 // If not, open files in dedicated app.
557 for( const wxFileName& fileName : m_AcceptedFiles )
558 {
559 wxString ext = fileName.GetExt();
560
562 {
563 wxString fn = fileName.GetFullPath();
564 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( fileName.GetExt() ), &fn );
565
566 return;
567 }
568 }
569
570 // Then stock gerber files in gerberFiles and run action for other files.
571 wxString gerberFiles;
572
573 // Gerbview editor should be able to open Gerber and drill files
574 for( const wxFileName& fileName : m_AcceptedFiles )
575 {
576 wxString ext = fileName.GetExt();
577
580 {
581 gerberFiles += wxT( '\"' );
582 gerberFiles += fileName.GetFullPath() + wxT( '\"' );
583 gerberFiles = gerberFiles.Pad( 1 );
584 }
585 else
586 {
587 wxString fn = fileName.GetFullPath();
588 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( fileName.GetExt() ), &fn );
589 }
590 }
591
592 // Execute Gerbviewer
593 if( !gerberFiles.IsEmpty() )
594 {
595 wxString fullEditorName = FindKicadFile( GERBVIEW_EXE );
596
597 if( wxFileExists( fullEditorName ) )
598 {
599 wxString command = fullEditorName + " " + gerberFiles;
601 &command );
602 }
603 }
604}
605
606
607bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
608{
609 KICAD_SETTINGS* settings = kicadSettings();
611
612 for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
613 {
614 wxWindow* page = m_notebook->GetPage( i );
615
616 if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
617 {
618 if( !panel->GetCanClose() )
619 return false;
620 }
621 }
622
623 // CloseProject will recursively ask all the open editors if they need to save changes.
624 // If any of them cancel then we need to cancel closing the KICAD_MANAGER_FRAME.
625 if( CloseProject( true ) )
626 {
627 // Don't propagate event to frames which have already been closed
628 aEvent.StopPropagation();
629
630 return true;
631 }
632 else
633 {
634 if( aEvent.CanVeto() )
635 aEvent.Veto();
636
637 return false;
638 }
639}
640
641
643{
644#ifdef _WINDOWS_
645 // For some obscure reason, on Windows, when killing Kicad from the Windows task manager
646 // if a editor frame (schematic, library, board editor or fp editor) is open and has
647 // some edition to save, OnCloseWindow is run twice *at the same time*, creating race
648 // conditions between OnCloseWindow() code.
649 // Therefore I added (JPC) a ugly hack to discard the second call (unwanted) during
650 // execution of the first call (only one call is right).
651 // Note also if there is no change made in editors, this behavior does not happen.
652 static std::atomic<unsigned int> lock_close_event( 0 );
653
654 if( ++lock_close_event > 1 ) // Skip extra calls
655 {
656 return;
657 }
658#endif
659
660 m_leftWin->Show( false );
661 Pgm().m_Quitting = true;
662
663 Destroy();
664
665#ifdef _WINDOWS_
666 lock_close_event = 0; // Reenable event management
667#endif
668}
669
670
672{
674
675 if( !aIsExplicitUserSave && !cfg.ShouldAutoSave() )
676 return;
677
678 cfg.m_OpenJobSets.clear();
679
680 for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
681 {
682 if( PANEL_JOBSET* jobset = dynamic_cast<PANEL_JOBSET*>( m_notebook->GetPage( i ) ) )
683 {
684 wxFileName jobsetFn( jobset->GetFilePath() );
685 jobsetFn.MakeRelativeTo( Prj().GetProjectPath() );
686 cfg.m_OpenJobSets.emplace_back( jobsetFn.GetFullPath() );
687 }
688 }
689
690 cfg.SaveToFile( Prj().GetProjectPath() );
691}
692
693
694void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
695{
696 Close( true );
697}
698
699
701{
702 if( !Kiway().PlayersClose( false ) )
703 return false;
704
705 bool shouldSaveProject = Prj().GetLocalSettings().ShouldAutoSave()
707
708 // Save the project file for the currently loaded project.
709 if( m_active_project )
710 {
712
713 if( shouldSaveProject )
714 {
716
717 if( aSave )
718 mgr.SaveProject();
719 }
720
721 m_active_project = false;
722 mgr.UnloadProject( &Prj() );
723 }
724
725 SetStatusText( "" );
726
727 // Traverse pages in reverse order so deleting them doesn't mess up our iterator.
728 for( int i = (int) m_notebook->GetPageCount() - 1; i >= 0; i-- )
729 {
730 wxWindow* page = m_notebook->GetPage( i );
731
732 if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
733 {
734 if( panel->GetProjectTied() )
735 m_notebook->DeletePage( i );
736 }
737 }
738
741
742 return true;
743}
744
745
746void KICAD_MANAGER_FRAME::OpenJobsFile( const wxFileName& aFileName, bool aCreate,
747 bool aResaveProjectPreferences )
748{
749 for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
750 {
751 if( PANEL_JOBSET* panel = dynamic_cast<PANEL_JOBSET*>( m_notebook->GetPage( i ) ) )
752 {
753 if( aFileName.GetFullPath() == panel->GetFilePath() )
754 {
755 m_notebook->SetSelection( i );
756 return;
757 }
758 }
759 }
760
761 try
762 {
763 std::unique_ptr<JOBSET> jobsFile =
764 std::make_unique<JOBSET>( aFileName.GetFullPath().ToStdString() );
765
766 jobsFile->LoadFromFile();
767
768 if( aCreate && !aFileName.FileExists() )
769 {
770 JOBSET_DESTINATION* dest = jobsFile->AddNewDestination( JOBSET_DESTINATION_T::FOLDER );
771 dest->m_outputHandler->SetOutputPath( aFileName.GetName() );
772 jobsFile->SaveToFile( wxEmptyString, true );
773 }
774
775 PANEL_JOBSET* jobPanel = new PANEL_JOBSET( m_notebook, this, std::move( jobsFile ) );
776 jobPanel->SetProjectTied( true );
777 jobPanel->SetClosable( true );
778 m_notebook->AddPage( jobPanel, aFileName.GetFullName(), true );
780
781 if( aResaveProjectPreferences )
783 }
784 catch( ... )
785 {
786 DisplayErrorMessage( this, _( "Error opening jobs file" ) );
787 }
788}
789
790
791void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
792{
793 // The project file should be valid by the time we get here or something has gone wrong.
794 if( !aProjectFileName.Exists() )
795 return;
796
797 // Any open KIFACE's must be closed if they are not part of the new project.
798 // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
799 // User is prompted here to close those KIWAY_PLAYERs:
800 if( !CloseProject( true ) )
801 return;
802
803 m_active_project = true;
804
805 // NB: when loading a legacy project SETTINGS_MANAGER::LoadProject() will convert it to
806 // current extension. Be very careful with aProjectFileName vs. Prj().GetProjectPath()
807 // from here on out.
808
809 Pgm().GetSettingsManager().LoadProject( aProjectFileName.GetFullPath() );
810 LoadWindowState( aProjectFileName.GetFullName() );
811
812 if( aProjectFileName.IsDirWritable() )
813 SetMruPath( Prj().GetProjectPath() );
814
815 // Save history & window state to disk now. Don't wait around for a crash.
816 KICAD_SETTINGS* settings = kicadSettings();
817 SaveSettings( settings );
818 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
819
821
822 for( const wxString& jobset : Prj().GetLocalSettings().m_OpenJobSets )
823 {
824 wxFileName jobsetFn( jobset );
825 jobsetFn.MakeAbsolute( Prj().GetProjectPath() );
826
827 if( jobsetFn.Exists() )
828 OpenJobsFile( jobsetFn.GetFullPath(), false, false );
829 }
830
831 // Always start with the apps page
832 m_notebook->SetSelection( 0 );
833
834 // Rebuild the list of watched paths.
835 // however this is possible only when the main loop event handler is running,
836 // so we use it to run the rebuild function.
837 wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
838
839 wxPostEvent( this, cmd );
840
841 PrintPrjInfo();
842
843 KIPLATFORM::APP::RegisterApplicationRestart( aProjectFileName.GetFullPath() );
844 m_openSavedWindows = true;
845
846 KIPLATFORM::ENV::AddToRecentDocs( aProjectFileName.GetFullPath() );
847}
848
849
850void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName,
851 bool aCreateStubFiles )
852{
853 wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
854 "Project folder must exist and be writable to create a new project." );
855
856 // If the project is legacy, convert it
857 if( !aProjectFileName.FileExists() )
858 {
859 wxFileName legacyPro( aProjectFileName );
860 legacyPro.SetExt( FILEEXT::LegacyProjectFileExtension );
861
862 if( legacyPro.FileExists() )
863 {
864 GetSettingsManager()->LoadProject( legacyPro.GetFullPath() );
866
867 wxRemoveFile( legacyPro.GetFullPath() );
868 }
869 else
870 {
871 // Copy template project file from template folder.
872 wxString srcFileName = sys_search().FindValidPath( "kicad.kicad_pro" );
873
874 wxFileName destFileName( aProjectFileName );
875 destFileName.SetExt( FILEEXT::ProjectFileExtension );
876
877 // Create a minimal project file if the template project file could not be copied
878 if( !wxFileName::FileExists( srcFileName )
879 || !wxCopyFile( srcFileName, destFileName.GetFullPath() ) )
880 {
881 wxFFile file( destFileName.GetFullPath(), "wb" );
882
883 if( file.IsOpened() )
884 file.Write( wxT( "{\n}\n") );
885
886 // wxFFile dtor will close the file
887 }
888 }
889 }
890
891 // Create a "stub" for a schematic root sheet and a board if requested.
892 // It will avoid messages from the schematic editor or the board editor to create a new file
893 // And forces the user to create main files under the right name for the project manager
894 if( aCreateStubFiles )
895 {
896 wxFileName fn( aProjectFileName.GetFullPath() );
898
899 // If a <project>.kicad_sch file does not exist, create a "stub" file ( minimal schematic
900 // file ).
901 if( !fn.FileExists() )
902 {
903 wxFFile file( fn.GetFullPath(), "wb" );
904
905 if( file.IsOpened() )
906 file.Write( wxString::Format( "(kicad_sch\n"
907 "\t(version %d)\n"
908 "\t(generator \"eeschema\")\n"
909 "\t(generator_version \"%s\")\n"
910 "\t(uuid %s)\n"
911 "\t(paper \"A4\")\n"
912 "\t(lib_symbols)\n"
913 "\t(sheet_instances\n"
914 "\t\t(path \"/\"\n"
915 "\t\t\t(page \"1\")\n"
916 "\t\t)\n"
917 "\t)\n"
918 "\t(embedded_fonts no)\n"
919 ")",
921 KIID().AsString() ) );
922
923 // wxFFile dtor will close the file
924 }
925
926 // If a <project>.kicad_pcb or <project>.brd file does not exist,
927 // create a .kicad_pcb "stub" file
929 wxFileName leg_fn( fn );
930 leg_fn.SetExt( FILEEXT::LegacyPcbFileExtension );
931
932 if( !fn.FileExists() && !leg_fn.FileExists() )
933 {
934 wxFFile file( fn.GetFullPath(), "wb" );
935
936 if( file.IsOpened() )
937 // Create a small dummy file as a stub for pcbnew:
938 file.Write( wxString::Format( "(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n)",
940
941 // wxFFile dtor will close the file
942 }
943 }
944
945 // Save history & window state to disk now. Don't wait around for a crash.
946 KICAD_SETTINGS* settings = kicadSettings();
947 SaveSettings( settings );
948 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
949
950 m_openSavedWindows = true;
951}
952
953
955{
956 // show all files in file dialog (in Kicad all files are editable texts):
957 wxString wildcard = FILEEXT::AllFilesWildcard();
958
959 wxString default_dir = Prj().GetProjectPath();
960
961 wxFileDialog dlg( this, _( "Edit File in Text Editor" ), default_dir, wxEmptyString, wildcard,
962 wxFD_OPEN );
963
964 if( dlg.ShowModal() == wxID_CANCEL )
965 return;
966
967 wxString filename = dlg.GetPath();
968
969 if( !dlg.GetPath().IsEmpty() && !Pgm().GetTextEditor().IsEmpty() )
971}
972
973
975{
977}
978
979
980void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
981{
982 int id = event.GetId();
983 Kiway().SetLanguage( id );
984}
985
986
988{
989 // call my base class
991
992 // tooltips in toolbars
995
996 // update captions
997 int pageId = m_notebook->FindPage( m_launcher );
998
999 if( pageId != wxNOT_FOUND )
1000 m_notebook->SetPageText( pageId, EDITORS_CAPTION );
1001
1002 m_auimgr.GetPane( m_leftWin ).Caption( PROJECT_FILES_CAPTION );
1003 m_auimgr.Update();
1004
1006
1007 PrintPrjInfo();
1008}
1009
1010
1012{
1014
1015 if( m_pcm && ( aFlags & ENVVARS_CHANGED ) )
1016 m_pcm->ReadEnvVar();
1017
1018 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
1019
1020 if( m_lastToolbarIconSize == 0
1022 {
1025 }
1026
1028}
1029
1030
1032{
1033 wxString file = GetProjectFileName();
1034
1035 // empty file string means no project loaded
1036 if( !Prj().IsNullProject() &&
1037 Prj().GetProjectLock() == nullptr )
1038 {
1039 LOCKFILE lockFile( file );
1040
1041 if( !lockFile.Valid() && lockFile.IsLockedByMe() )
1042 {
1043 // If we cannot acquire the lock but we appear to be the one who
1044 // locked it, check to see if there is another KiCad instance running.
1045 // If there is not, then we can override the lock. This could happen if
1046 // KiCad crashed or was interrupted
1047 if( !Pgm().SingleInstance()->IsAnotherRunning() )
1048 {
1049 lockFile.OverrideLock();
1050 }
1051 }
1052
1053 if( !lockFile.Valid() )
1054 {
1055 wxString msg;
1056 msg.Printf( _( "Project '%s' is already open by '%s' at '%s'." ), file, lockFile.GetUsername(),
1057 lockFile.GetHostname() );
1058
1059 if( AskOverrideLock( this, msg ) )
1060 {
1061 lockFile.OverrideLock();
1062 }
1063 }
1064
1065 Prj().SetReadOnly( !lockFile.Valid() || Prj().GetProjectFile().IsReadOnly() );
1066 Prj().SetProjectLock( new LOCKFILE( std::move( lockFile ) ) );
1067 }
1068
1069 wxString title;
1070
1071 if( !file.IsEmpty() )
1072 {
1073 wxFileName fn( file );
1074
1075 title = fn.GetName();
1076
1077 if( Prj().IsReadOnly() )
1078 title += wxS( " " ) + _( "[Read Only]" );
1079 }
1080 else
1081 {
1082 title = _( "[no project loaded]" );
1083 }
1084
1085 if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
1086 title += wxT( " \u2014 " ) + wxString( wxS( "KiCad" ) );
1087 else
1088 title += wxT( " \u2014 " ) + wxString( wxS( "KiCad " ) ) + GetMajorMinorVersion();
1089
1090 SetTitle( title );
1091}
1092
1093
1095{
1097
1098 auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
1099
1100 wxCHECK( settings, /*void*/ );
1101
1102 m_leftWinWidth = settings->m_LeftWinWidth;
1103}
1104
1105
1107{
1109
1110 auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
1111
1112 wxCHECK( settings, /*void*/);
1113
1114 settings->m_LeftWinWidth = m_leftWin->GetSize().x;
1115
1116 if( !m_isClosing )
1117 settings->m_OpenProjects = GetSettingsManager()->GetOpenProjects();
1118}
1119
1120
1122{
1123 // wxStatusBar's wxELLIPSIZE_MIDDLE flag doesn't work (at least on Mac).
1124
1125 wxString status = wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() );
1126 KISTATUSBAR* statusBar = static_cast<KISTATUSBAR*>( GetStatusBar() );
1127 statusBar->SetEllipsedTextField( status, 0 );
1128}
1129
1130
1132{
1133 return m_active_project;
1134}
1135
1136
1137void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
1138{
1144 if( !m_openSavedWindows )
1145 return;
1146
1147 m_openSavedWindows = false;
1148
1149 if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
1150 {
1151 int previousOpenCount =
1152 std::count_if( Prj().GetLocalSettings().m_files.begin(),
1153 Prj().GetLocalSettings().m_files.end(),
1154 [&]( const PROJECT_FILE_STATE& f )
1155 {
1156 return !f.fileName.EndsWith( FILEEXT::ProjectFileExtension ) && f.open;
1157 } );
1158
1159 if( previousOpenCount > 0 )
1160 {
1161 APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
1162 previousOpenCount, this );
1163
1164 // We don't currently support opening more than one view per file
1165 std::set<wxString> openedFiles;
1166
1167 int i = 0;
1168
1169 for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
1170 {
1171 if( file.open && !openedFiles.count( file.fileName ) )
1172 {
1173 progressReporter.Update( i++, wxString::Format( _( "Restoring '%s'" ), file.fileName ) );
1174
1175 openedFiles.insert( file.fileName );
1176 wxFileName fn( file.fileName );
1177
1178 if( fn.GetExt() == FILEEXT::LegacySchematicFileExtension
1179 || fn.GetExt() == FILEEXT::KiCadSchematicFileExtension )
1180 {
1182 }
1183 else if( fn.GetExt() == FILEEXT::LegacyPcbFileExtension
1184 || fn.GetExt() == FILEEXT::KiCadPcbFileExtension )
1185 {
1187 }
1188 }
1189
1190 wxYield();
1191 }
1192 }
1193 }
1194
1195 // clear file states regardless if we opened windows or not due to setting
1197
1198 KICAD_SETTINGS* settings = kicadSettings();
1199
1200 if( !Pgm().GetCommonSettings()->m_DoNotShowAgain.update_check_prompt )
1201 {
1202 auto prompt = new DIALOG_UPDATE_CHECK_PROMPT( this );
1203 prompt->ShowModal();
1204
1206 }
1207
1209 && settings->m_PcmUpdateCheck )
1210 {
1211 if( !m_pcm )
1212 CreatePCM();
1213
1214 m_pcm->RunBackgroundUpdate();
1215 }
1216
1217#ifdef KICAD_UPDATE_CHECK
1218 if( !m_updateManager && settings->m_KiCadUpdateCheck )
1219 {
1220 m_updateManager = std::make_unique<UPDATE_MANAGER>();
1221 m_updateManager->CheckForUpdate( this );
1222 }
1223#endif
1224}
1225
1226
1228{
1229 m_pcmButton = aButton;
1230
1232}
1233
1234
1236{
1237 if( m_pcmButton )
1238 {
1239 if( m_pcmUpdateCount > 0 )
1240 {
1241 m_pcmButton->SetShowBadge( true );
1242 m_pcmButton->SetBadgeText( wxString::Format( "%d", m_pcmUpdateCount ) );
1243 }
1244 else
1245 {
1246 m_pcmButton->SetShowBadge( false );
1247 }
1248
1249 m_pcmButton->Refresh();
1250 }
1251}
1252
1253
1255{
1256 // No idea why, but the same mechanism used in EDA_DRAW_FRAME doesn't work here
1257 // the only thing that seems to work is to blow it all up and start from scratch.
1258 m_auimgr.DetachPane( m_tbLeft );
1259 delete m_tbLeft;
1260 m_tbLeft = nullptr;
1262 m_auimgr.AddPane( m_tbLeft, EDA_PANE().HToolbar().Name( "TopMainToolbar" ).Left()
1263 .Layer( 2 ) );
1264
1265 m_auimgr.Update();
1266}
const char * name
Definition: DXF_plotter.cpp:62
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:115
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:104
@ icon_kicad_16
@ icon_kicad_nightly
@ icon_kicad_32
@ icon_kicad_nightly_32
@ icon_kicad_nightly_16
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
bool IsNightlyVersion()
Check if the build is meant to be nightly.
static TOOL_ACTION paste
Definition: actions.h:80
static TOOL_ACTION saveAs
Definition: actions.h:59
static TOOL_ACTION copy
Definition: actions.h:78
static TOOL_ACTION cut
Definition: actions.h:77
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
wxProgressDialog with the option to also update the application progress on the taskbar
virtual bool Update(int aValue, const wxString &aNewMsg=wxEmptyString, bool *aSkip=nullptr) override
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:108
void UnregisterStatusBar(KISTATUSBAR *aStatusBar)
Removes status bar from handling.
void RegisterStatusBar(KISTATUSBAR *aStatusBar)
Add a status bar for handling.
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
Definition: bitmap_button.h:42
void SetBadgeText(const wxString &aText)
void SetShowBadge(bool aShowBadge)
Handle actions that are shared between different applications.
APPEARANCE m_Appearance
DO_NOT_SHOW_AGAIN m_DoNotShowAgain
The base frame for deriving all KiCad main window classes.
void LoadWindowState(const wxString &aFileName)
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
std::vector< wxFileName > m_AcceptedFiles
SETTINGS_MANAGER * GetSettingsManager() const
wxAuiManager m_auimgr
virtual void RecreateToolbars()
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
ACTION_TOOLBAR * m_tbLeft
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void SetMruPath(const wxString &aPath)
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
Specialization of the wxAuiPaneInfo class for KiCad panels.
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
Calls Store() and then writes the contents of the JSON document to a file.
static TOOL_ACTION viewDroppedGerbers
static TOOL_ACTION editPCB
static TOOL_ACTION loadProject
static TOOL_ACTION editSchematic
static TOOL_ACTION openTextEditor
static TOOL_ACTION archiveProject
static TOOL_ACTION closeProject
static TOOL_ACTION openJobsetFile
static TOOL_ACTION newJobsetFile
Handle actions in the kicad manager frame.
The main KiCad project manager frame.
std::shared_ptr< PLUGIN_CONTENT_MANAGER > m_pcm
void language_change(wxCommandEvent &event)
void SetPcmButton(BITMAP_BUTTON *aButton)
void doCloseWindow() override
void CreateNewProject(const wxFileName &aProjectFileName, bool aCreateStubFiles=true)
Creates a new project by setting up and initial project, schematic, and board files.
const SEARCH_STACK & sys_search() override
Return a SEARCH_STACK pertaining to entire program.
void OnImportEasyEdaProFiles(wxCommandEvent &event)
Open dialog to import EasyEDA Pro schematic and board files.
void ProjectChanged() override
Notification event that the project has changed.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
const wxString SchLegacyFileName()
wxWindow * GetToolCanvas() const override
Canvas access.
void OnImportEasyEdaFiles(wxCommandEvent &event)
Open dialog to import EasyEDA Std schematic and board files.
PROJECT_TREE_PANE * m_leftWin
void OnImportAltiumProjectFiles(wxCommandEvent &event)
Open dialog to import Altium project files.
const wxString GetProjectFileName() const
KICAD_SETTINGS * kicadSettings() const
const wxString SchFileName()
void OnImportEagleFiles(wxCommandEvent &event)
Open dialog to import Eagle schematic and board files.
wxStatusBar * OnCreateStatusBar(int number, long style, wxWindowID id, const wxString &name) override
Create the status line (like a wxStatusBar).
void OnExit(wxCommandEvent &event)
void OpenJobsFile(const wxFileName &aFileName, bool aCreate=false, bool aResaveProjectPreferences=true)
void LoadProject(const wxFileName &aProjectFileName)
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
void OnSize(wxSizeEvent &event) override
virtual void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
void DoWithAcceptedFiles() override
Execute action on accepted dropped file.
void OnOpenFileInTextEditor(wxCommandEvent &event)
APP_SETTINGS_BASE * config() const override
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
const wxString PcbLegacyFileName()
KICAD_MANAGER_FRAME(wxWindow *parent, const wxString &title, const wxPoint &pos, const wxSize &size)
bool CloseProject(bool aSave)
Closes the project, and saves it if aSave is true;.
void onNotebookPageCloseRequest(wxAuiNotebookEvent &evt)
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void OnIdle(wxIdleEvent &event)
void PrintPrjInfo()
Prints the current working directory name and the project name on the text panel.
void SaveOpenJobSetsToLocalSettings(bool aIsExplicitUserSave=false)
void onNotebookPageCountChanged(wxAuiNotebookEvent &evt)
void OnImportCadstarArchiveFiles(wxCommandEvent &event)
Open dialog to import CADSTAR Schematic and PCB Archive files.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
BITMAP_BUTTON * m_pcmButton
PANEL_KICAD_LAUNCHER * m_launcher
void HideTabsIfNeeded()
Hides the tabs for Editor notebook if there is only 1 page.
wxString help_name() override
const wxString PcbFileName()
std::unique_ptr< UPDATE_MANAGER > m_updateManager
wxAuiNotebook * m_notebook
std::vector< wxString > m_OpenProjects
std::vector< std::pair< wxString, wxString > > m_PcmRepositories
Definition: kiid.h:49
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
Definition: kistatusbar.h:45
void SetEllipsedTextField(const wxString &aText, int aFieldId)
Set the text in a field using wxELLIPSIZE_MIDDLE option to adjust the text size to the field size.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:55
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all #KIWAY_PLAYERs.
Definition: kiway.cpp:515
bool OverrideLock(bool aRemoveOnRelease=true)
Force the lock, overwriting the data that existed already.
Definition: lockfile.h:174
bool Valid() const
Definition: lockfile.h:254
wxString GetUsername()
Definition: lockfile.h:236
wxString GetHostname()
Definition: lockfile.h:242
bool IsLockedByMe()
Definition: lockfile.h:227
void RegisterStatusBar(KISTATUSBAR *aStatusBar)
Add a status bar for handling.
void CreateOrUpdate(const wxString &aKey, const wxString &aTitle, const wxString &aDescription, const wxString &aHref=wxEmptyString)
Create a notification with the given parameters or updates an existing one with the same key.
void Remove(const wxString &aKey)
Remove a notification by key.
void UnregisterStatusBar(KISTATUSBAR *aStatusBar)
Remove status bar from handling.
static REPORTER & GetInstance()
Definition: reporter.cpp:108
void SetClosable(bool aYes)
void SetProjectTied(bool aYes)
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:565
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition: pgm_base.h:129
bool m_Quitting
Definition: pgm_base.h:357
virtual NOTIFICATIONS_MANAGER & GetNotificationsManager() const
Definition: pgm_base.h:134
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
wxString GetHelpFileName()
Definition: pgm_kicad.h:63
SEARCH_STACK & SysSearch()
Definition: pgm_kicad.h:61
APP_SETTINGS_BASE * PgmSettings()
Definition: pgm_kicad.h:59
bool ShouldAutoSave() const
Definition: project_file.h:117
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.
std::vector< wxString > m_OpenJobSets
PROJECT_TREE_PANE Window to display the tree files.
void EmptyTreePrj()
Delete all m_TreeProject entries.
void FileWatcherReset()
Reinit the watched paths Should be called after opening a new project to rebuild the list of watched ...
void ReCreateTreePrj()
Create or modify the tree showing project file names.
void SetProjectLock(LOCKFILE *aLockFile)
Definition: project.cpp:468
virtual void SetReadOnly(bool aReadOnly=true)
Definition: project.h:168
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:143
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:149
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition: project.h:210
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:204
Look for files in a number of paths.
Definition: search_stack.h:43
static bool ShowNever(const SELECTION &aSelection)
Always returns false.
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Save a loaded project.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
bool IsProjectOpen() const
Helper for checking if we have a project open.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Save, unload and unregister the given PROJECT.
std::vector< wxString > GetOpenProjects() const
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Call BackupProject() if a new backup is needed according to the current backup policy.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:171
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:173
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:172
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
Master controller class:
Definition: tool_manager.h:62
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:306
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initialize all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
bool AskOverrideLock(wxWindow *aParent, const wxString &aMessage)
Display a dialog indicating the file is already open, with an option to reset the lock.
Definition: confirm.cpp:42
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:194
This file is part of the common library.
#define ENABLE(x)
#define _(s)
Base window classes and related definitions.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define KICAD_MANAGER_FRAME_NAME
KiCad executable names.
const wxString GERBVIEW_EXE
@ KICAD_MAIN_FRAME_T
Definition: frame_type.h:68
wxString FindKicadFile(const wxString &shortname)
Search the executable file shortname in KiCad binary path and return full file name if found or short...
Definition: gestfich.cpp:58
static const std::string LegacySchematicFileExtension
static const std::string GerberJobFileExtension
static const std::string GerberFileExtension
static const std::string ProjectFileExtension
static const std::string LegacyPcbFileExtension
static const std::string LegacyProjectFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string DrillFileExtension
static const std::string KiCadPcbFileExtension
static wxString AllFilesWildcard()
static bool IsGerberFileExtension(const wxString &ext)
@ ID_FILE_LIST_CLEAR
Definition: id.h:62
@ ID_LANGUAGE_CHOICE
Definition: id.h:66
@ ID_FILEMAX
Definition: id.h:60
@ ID_LANGUAGE_CHOICE_END
Definition: id.h:110
@ ID_FILE1
Definition: id.h:59
PGM_KICAD & PgmTop()
Definition: kicad.cpp:80
@ ID_IMPORT_EAGLE_PROJECT
Definition: kicad_id.h:39
@ ID_IMPORT_EASYEDAPRO_PROJECT
Definition: kicad_id.h:41
@ ID_IMPORT_CADSTAR_ARCHIVE_PROJECT
Definition: kicad_id.h:38
@ ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR
Definition: kicad_id.h:37
@ ID_IMPORT_EASYEDA_PROJECT
Definition: kicad_id.h:40
@ ID_IMPORT_ALTIUM_PROJECT
Definition: kicad_id.h:42
EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::language_change) KICAD_MANAGER_FRAME
#define EDITORS_CAPTION
#define ID_INIT_WATCHED_PATHS
#define PROJECT_FILES_CAPTION
File locking utilities.
bool RegisterApplicationRestart(const wxString &aCommandLine)
Registers the application for restart with the OS with the given command line string to pass as args.
Definition: unix/app.cpp:65
void AddToRecentDocs(const wxString &aPath)
PBOOL GetPolicyBool(const wxString &aKey)
Definition: unix/policy.cpp:26
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
Definition: ui_common.cpp:132
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:902
#define POLICY_KEY_PCM
Definition: policy_keys.h:31
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
ACTION_CONDITIONS & Enable(const SELECTION_CONDITION &aCondition)
std::shared_ptr< JOBS_OUTPUT_HANDLER > m_outputHandler
Definition: jobset.h:133
#define ENVVARS_CHANGED
Definition: tools_holder.h:152
Definition of file extensions used in Kicad.