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"
30#include "local_history_pane.h"
32
33#include <advanced_config.h>
35#include <bitmaps.h>
36#include <build_version.h>
37#include <confirm.h>
41#include <local_history.h>
42#include <wx/msgdlg.h>
43#include <eda_base_frame.h>
44#include <executable_names.h>
45#include <file_history.h>
46#include <local_history.h>
47#include <policy_keys.h>
48#include <gestfich.h>
49#include <kiplatform/app.h>
51#include <kiplatform/policy.h>
52#include <build_version.h>
53#include <kiway.h>
54#include <kiway_express.h>
55#include <launch_ext.h>
56#include <lockfile.h>
58#include <reporter.h>
60#include <sch_file_versions.h>
62#include <tool/action_manager.h>
63#include <tool/action_toolbar.h>
64#include <tool/common_control.h>
66#include <tool/tool_manager.h>
72#include <widgets/kistatusbar.h>
73#include <wx/ffile.h>
74#include <wx/filedlg.h>
75#include <wx/dnd.h>
76#include <wx/process.h>
77#include <wx/snglinst.h>
78#include <atomic>
79#include <update_manager.h>
80#include <jobs/jobset.h>
81
82#include <../pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h> // for SEXPR_BOARD_FILE_VERSION def
83
84
85#ifdef __WXMAC__
86#include <MacTypes.h>
87#include <ApplicationServices/ApplicationServices.h>
88#endif
89
90#include "kicad_manager_frame.h"
92
94
95
96#define EDITORS_CAPTION _( "Editors" )
97#define PROJECT_FILES_CAPTION _( "Project Files" )
98
99#define ID_INIT_WATCHED_PATHS 52913
100
101#define SEP() wxFileName::GetPathSeparator()
102
103
104// Menubar and toolbar event table
105BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
106 // Window events
109
110 // Menu events
111 EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
119
120 // Range menu events
122 KICAD_MANAGER_FRAME::language_change )
123
125 EVT_MENU( ID_FILE_LIST_CLEAR, KICAD_MANAGER_FRAME::OnClearFileHistory )
126
127 // Special functions
128 EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
129
130 // Drop files event
131 EVT_DROP_FILES( KICAD_MANAGER_FRAME::OnDropFiles )
132
133END_EVENT_TABLE()
134
135// See below the purpose of this include
136#include <wx/xml/xml.h>
137
138KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
139 const wxPoint& pos, const wxSize& size ) :
142 m_active_project( false ),
143 m_showHistoryPanel( false ),
144 m_leftWin( nullptr ),
145 m_historyPane( nullptr ),
146 m_launcher( nullptr ),
147 m_lastToolbarIconSize( 0 ),
148 m_pcmButton( nullptr ),
149 m_pcmUpdateCount( 0 )
150{
151 const int defaultLeftWinWidth = FromDIP( 250 );
152
153 m_leftWinWidth = defaultLeftWinWidth; // Default value
154 m_aboutTitle = "KiCad";
155
156 // JPC: A very ugly hack to fix an issue on Linux: if the wxbase315u_xml_gcc_custom.so is
157 // used **only** in PCM, it is not found in some cases at run time.
158 // So just use it in the main module to avoid a not found issue
159 // wxbase315u_xml_gcc_custom shared object when launching Kicad
160 wxXmlDocument dummy;
161
162 // Create the status line (bottom of the frame). Left half is for project name; right half
163 // is for Reporter (currently used by archiver/unarchiver and PCM).
164 // Note: this is a KISTATUSBAR status bar. Therefore the specified number of fields
165 // is the extra number of fields, not the full field count.
166 // We need here 2 fields: the extra fiels to display the project name, and another field
167 // to display a info (specific to Windows) using the FIELD_OFFSET_BGJOB_TEXT id offset (=1)
168 // So the extra field count is 1
169 CreateStatusBar( 1 );
172 GetStatusBar()->SetFont( KIUI::GetStatusFont( this ) );
173
174 // Give an icon
175 wxIcon icon;
176 wxIconBundle icon_bundle;
177
178 if( IsNightlyVersion())
179 {
180 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly, 48 ) );
181 icon_bundle.AddIcon( icon );
182 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly, 128 ) );
183 icon_bundle.AddIcon( icon );
184 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly, 256 ) );
185 icon_bundle.AddIcon( icon );
186 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_32 ) );
187 icon_bundle.AddIcon( icon );
188 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_16 ) );
189 icon_bundle.AddIcon( icon );
190 }
191 else
192 {
193 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad, 48 ) );
194 icon_bundle.AddIcon( icon );
195 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad, 128 ) );
196 icon_bundle.AddIcon( icon );
197 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad, 256 ) );
198 icon_bundle.AddIcon( icon );
199 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_32 ) );
200 icon_bundle.AddIcon( icon );
201 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_16 ) );
202 icon_bundle.AddIcon( icon );
203 }
204
205 SetIcons( icon_bundle );
206
207 // Load the settings
208 LoadSettings( config() );
209
210 // Left window: is the box which display tree project
211 m_leftWin = new PROJECT_TREE_PANE( this );
212
213 setupTools();
214 setupUIConditions();
215
216 m_toolbarSettings = GetToolbarSettings<KICAD_MANAGER_TOOLBAR_SETTINGS>( "kicad-toolbars" );
217 configureToolbars();
218 RecreateToolbars();
219 ReCreateMenuBar();
220
221 m_auimgr.SetManagedWindow( this );
222 m_auimgr.SetFlags( wxAUI_MGR_LIVE_RESIZE );
223
224 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( "TopMainToolbar" ).Left().Layer( 2 ) );
225
226 // BestSize() does not always set the actual pane size of m_leftWin to the required value.
227 // It happens when m_leftWin is too large (roughly > 1/3 of the kicad manager frame width.
228 // (Well, BestSize() sets the best size... not the window size)
229 // A trick is to use MinSize() to set the required pane width,
230 // and after give a reasonable MinSize value
231 m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer( 1 )
232 .Caption( PROJECT_FILES_CAPTION ).PaneBorder( false )
233 .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) );
234
235 m_historyPane = new LOCAL_HISTORY_PANE( this );
236 m_auimgr.AddPane( m_historyPane,
237 EDA_PANE().Palette().Name( "LocalHistory" ).Left().Layer( 1 ).Position( 1 )
238 .Caption( _( "Local History" ) ).PaneBorder( false )
239 .Floatable( false ).Movable( false ).CloseButton( true ).Hide() );
240
241 if( m_showHistoryPanel )
242 m_auimgr.GetPane( m_historyPane ).Show();
243
244 wxSize client_size = GetClientSize();
245 m_notebook = new wxAuiNotebook( this, wxID_ANY, wxPoint( client_size.x, client_size.y ),
246 FromDIP( wxSize( 700, 590 ) ),
247 wxAUI_NB_TOP | wxAUI_NB_CLOSE_ON_ALL_TABS | wxAUI_NB_TAB_MOVE
248 | wxAUI_NB_SCROLL_BUTTONS | wxNO_BORDER );
249
250 m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CLOSE, &KICAD_MANAGER_FRAME::onNotebookPageCloseRequest, this );
251 m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CLOSED, &KICAD_MANAGER_FRAME::onNotebookPageCountChanged, this );
252 m_launcher = new PANEL_KICAD_LAUNCHER( m_notebook );
253
254 m_notebook->Freeze();
255 m_launcher->SetClosable( false );
256 m_notebook->AddPage( m_launcher, EDITORS_CAPTION, false );
257 m_notebook->SetTabCtrlHeight( 0 );
258 m_notebook->Thaw();
259
260 m_auimgr.AddPane( m_notebook, EDA_PANE().Canvas().Name( "Editors" ).Center().Caption( EDITORS_CAPTION )
261 .PaneBorder( false ).MinSize( m_notebook->GetBestSize() ) );
262
263 m_auimgr.Update();
264
265 // Now the actual m_leftWin size is set, give it a reasonable min width
266 m_auimgr.GetPane( m_leftWin ).MinSize( defaultLeftWinWidth, -1 );
267
268
269 wxSizer* mainSizer = GetSizer();
270
271 // Only fit the initial window size the first time KiCad is run.
272 if( mainSizer && config()->m_Window.state.size_x == 0 && config()->m_Window.state.size_y == 0 )
273 {
274 Layout();
275 mainSizer->Fit( this );
276 Center();
277 }
278
279 if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
280 SetTitle( wxT( "KiCad" ) );
281 else
282 SetTitle( wxString( "KiCad " ) + GetMajorMinorVersion() );
283
284 // Do not let the messages window have initial focus
285 m_leftWin->SetFocus();
286
287 // Init for dropping files
290
291 // Gerber files
292 // Note that all gerber files are aliased as GerberFileExtension
296
297 DragAcceptFiles( true );
298
299 // Ensure the window is on top
300 Raise();
301
302 Bind( wxEVT_DPI_CHANGED,
303 [&]( wxDPIChangedEvent& )
304 {
305 m_auimgr.Update();
306
307 // Don't skip, otherwise the frame gets too big
308 } );
309}
310
311
313{
315 Unbind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
316
317 m_notebook->Unbind( wxEVT_AUINOTEBOOK_PAGE_CLOSE, &KICAD_MANAGER_FRAME::onNotebookPageCloseRequest, this );
318 m_notebook->Unbind( wxEVT_AUINOTEBOOK_PAGE_CLOSED, &KICAD_MANAGER_FRAME::onNotebookPageCountChanged, this );
319
322
323 // Shutdown all running tools
324 if( m_toolManager )
325 m_toolManager->ShutdownAllTools();
326
327 if( m_pcm )
328 m_pcm->StopBackgroundUpdate();
329
330 delete m_actions;
331 delete m_toolManager;
332 delete m_toolDispatcher;
333
334 m_auimgr.UnInit();
335}
336
338{
339 if( m_notebook->GetPageCount() == 1 )
340 m_notebook->SetTabCtrlHeight( 0 );
341 else
342 m_notebook->SetTabCtrlHeight( -1 );
343}
344
345
347{
349}
350
351
353{
354 wxAuiNotebook* notebook = (wxAuiNotebook*) evt.GetEventObject();
355 wxWindow* page = notebook->GetPage( evt.GetSelection() );
356
357 if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
358 {
359 if( panel->GetClosable() )
360 {
361 if( !panel->GetCanClose() )
362 evt.Veto();
363
364 CallAfter(
365 [this]()
366 {
368 } );
369 }
370 else
371 {
372 evt.Veto();
373 }
374 }
375}
376
377
378wxStatusBar* KICAD_MANAGER_FRAME::OnCreateStatusBar( int number, long style, wxWindowID id,
379 const wxString& name )
380{
381 return new KISTATUSBAR( number, this, id );
382}
383
384
386{
387 // creates the PLUGIN_CONTENT_MANAGER, if not exists
388 if( m_pcm )
389 return;
390
391 m_pcm = std::make_shared<PLUGIN_CONTENT_MANAGER>(
392 [this]( int aUpdateCount )
393 {
394 m_pcmUpdateCount = aUpdateCount;
395
396 if( aUpdateCount > 0 )
397 {
399 wxS( "pcm" ),
400 _( "PCM Updates Available" ),
401 wxString::Format( _( "%d package update(s) available" ), aUpdateCount ),
402 wxT( "" ) );
403 }
404 else
405 {
406 Pgm().GetNotificationsManager().Remove( wxS( "pcm" ) );
407 }
408
409 CallAfter(
410 [this]()
411 {
413 } );
414 });
415
416 m_pcm->SetRepositoryList( kicadSettings()->m_PcmRepositories );
417}
418
419
421{
422 // Create the manager
424 m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
426
428
429 // Attach the events to the tool dispatcher
431 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
432
433 // Register tools
434 m_toolManager->RegisterTool( new COMMON_CONTROL );
435 m_toolManager->RegisterTool( new KICAD_MANAGER_CONTROL );
436 m_toolManager->InitTools();
437}
438
439
441{
443
444 ACTION_MANAGER* manager = m_toolManager->GetActionManager();
445
446 wxASSERT( manager );
447
448 auto activeProject =
449 [this] ( const SELECTION& )
450 {
451 return m_active_project;
452 };
453
454#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
455
456 ACTION_CONDITIONS activeProjectCond;
457 activeProjectCond.Enable( activeProject );
458
459 manager->SetConditions( ACTIONS::saveAs, activeProjectCond );
460 manager->SetConditions( KICAD_MANAGER_ACTIONS::closeProject, activeProjectCond );
461 manager->SetConditions( KICAD_MANAGER_ACTIONS::archiveProject, activeProjectCond );
462 manager->SetConditions( KICAD_MANAGER_ACTIONS::newJobsetFile, activeProjectCond );
463 manager->SetConditions( KICAD_MANAGER_ACTIONS::openJobsetFile, activeProjectCond );
464
465 auto historyCond =
466 [this]( const SELECTION& )
467 {
468 return HistoryPanelShown();
469 };
470
472 ACTION_CONDITIONS().Check( historyCond ) );
473
474 // These are just here for text boxes, search boxes, etc. in places such as the standard
475 // file dialogs.
479
480#undef ENABLE
481}
482
483
485{
486 return m_leftWin;
487}
488
489
491{
493 wxASSERT( ret );
494 return ret;
495}
496
497
499{
500 KICAD_SETTINGS* ret = dynamic_cast<KICAD_SETTINGS*>( config() );
501 wxASSERT( ret );
502 return ret;
503}
504
505
507{
509 : wxString( wxEmptyString );
510}
511
512
514{
515 wxFileName fn( GetProjectFileName() );
516
518 return fn.GetFullPath();
519}
520
521
523{
524 wxFileName fn( GetProjectFileName() );
525
527 return fn.GetFullPath();
528}
529
530
532{
533 wxFileName fn( GetProjectFileName() );
534
535 fn.SetExt( FILEEXT::PcbFileExtension );
536 return fn.GetFullPath();
537}
538
539
541{
542 wxFileName fn( GetProjectFileName() );
543
545 return fn.GetFullPath();
546}
547
548
550{
551 m_leftWin->ReCreateTreePrj();
552}
553
554
559
560
562{
563 return PgmTop().GetHelpFileName();
564}
565
566
567void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event )
568{
569 if( m_auimgr.GetManagedWindow() )
570 m_auimgr.Update();
571
572 PrintPrjInfo();
573
574#if defined( _WIN32 )
575 KISTATUSBAR* statusBar = static_cast<KISTATUSBAR*>( GetStatusBar() );
577#endif
578
579 event.Skip();
580}
581
582
584{
585 // All fileNames are now in m_AcceptedFiles vector.
586 // Check if contains a project file name and load project.
587 // If not, open files in dedicated app.
588 for( const wxFileName& fileName : m_AcceptedFiles )
589 {
590 wxString ext = fileName.GetExt();
591
593 {
594 wxString fn = fileName.GetFullPath();
595 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( fileName.GetExt() ), &fn );
596
597 return;
598 }
599 }
600
601 // Then stock gerber files in gerberFiles and run action for other files.
602 wxString gerberFiles;
603
604 // Gerbview editor should be able to open Gerber and drill files
605 for( const wxFileName& fileName : m_AcceptedFiles )
606 {
607 wxString ext = fileName.GetExt();
608
611 {
612 gerberFiles += wxT( '\"' );
613 gerberFiles += fileName.GetFullPath() + wxT( '\"' );
614 gerberFiles = gerberFiles.Pad( 1 );
615 }
616 else
617 {
618 wxString fn = fileName.GetFullPath();
619 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( fileName.GetExt() ), &fn );
620 }
621 }
622
623 // Execute Gerbviewer
624 if( !gerberFiles.IsEmpty() )
625 {
626 wxString fullEditorName = FindKicadFile( GERBVIEW_EXE );
627
628 if( wxFileExists( fullEditorName ) )
629 {
630 wxString command = fullEditorName + " " + gerberFiles;
631 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( FILEEXT::GerberFileExtension ), &command );
632 }
633 }
634}
635
636
637bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
638{
639 KICAD_SETTINGS* settings = kicadSettings();
641
642 for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
643 {
644 wxWindow* page = m_notebook->GetPage( i );
645
646 if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
647 {
648 if( !panel->GetCanClose() )
649 return false;
650 }
651 }
652
653 // CloseProject will recursively ask all the open editors if they need to save changes.
654 // If any of them cancel then we need to cancel closing the KICAD_MANAGER_FRAME.
655 if( CloseProject( true ) )
656 {
657 // Don't propagate event to frames which have already been closed
658 aEvent.StopPropagation();
659
660 return true;
661 }
662 else
663 {
664 if( aEvent.CanVeto() )
665 aEvent.Veto();
666
667 return false;
668 }
669}
670
671
673{
674#ifdef _WINDOWS_
675 // For some obscure reason, on Windows, when killing Kicad from the Windows task manager
676 // if a editor frame (schematic, library, board editor or fp editor) is open and has
677 // some edition to save, OnCloseWindow is run twice *at the same time*, creating race
678 // conditions between OnCloseWindow() code.
679 // Therefore I added (JPC) a ugly hack to discard the second call (unwanted) during
680 // execution of the first call (only one call is right).
681 // Note also if there is no change made in editors, this behavior does not happen.
682 static std::atomic<unsigned int> lock_close_event( 0 );
683
684 if( ++lock_close_event > 1 ) // Skip extra calls
685 {
686 return;
687 }
688#endif
689
690 m_leftWin->Show( false );
691 Pgm().m_Quitting = true;
692
693 Destroy();
694
695#ifdef _WINDOWS_
696 lock_close_event = 0; // Reenable event management
697#endif
698}
699
700
702{
704
705 if( !aIsExplicitUserSave && !cfg.ShouldAutoSave() )
706 return;
707
708 cfg.m_OpenJobSets.clear();
709
710 for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
711 {
712 if( PANEL_JOBSET* jobset = dynamic_cast<PANEL_JOBSET*>( m_notebook->GetPage( i ) ) )
713 {
714 wxFileName jobsetFn( jobset->GetFilePath() );
715 jobsetFn.MakeRelativeTo( Prj().GetProjectPath() );
716 cfg.m_OpenJobSets.emplace_back( jobsetFn.GetFullPath() );
717 }
718 }
719
720 cfg.SaveToFile( Prj().GetProjectPath() );
721}
722
723
724void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
725{
726 Close( true );
727}
728
729
731{
732 if( !Kiway().PlayersClose( false ) )
733 return false;
734
735 // Save the project file for the currently loaded project.
736 if( m_active_project )
737 {
739
740 if( Prj().GetLocalSettings().ShouldAutoSave() && Prj().GetProjectFile().ShouldAutoSave() )
741 {
743
744 if( aSave )
745 mgr.SaveProject();
746 }
747
748 m_active_project = false;
749 // Enforce local history size limit (if enabled) once all pending saves/backups are done.
750 if( Pgm().GetCommonSettings() && Pgm().GetCommonSettings()->m_Backup.enabled )
751 {
753
754 if( limit > 0 )
755 Kiway().LocalHistory().EnforceSizeLimit( Prj().GetProjectPath(), (size_t) limit );
756 }
757
758 mgr.UnloadProject( &Prj() );
759 }
760
761 SetStatusText( "" );
762
763 // Traverse pages in reverse order so deleting them doesn't mess up our iterator.
764 for( int i = (int) m_notebook->GetPageCount() - 1; i >= 0; i-- )
765 {
766 wxWindow* page = m_notebook->GetPage( i );
767
768 if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
769 {
770 if( panel->GetProjectTied() )
771 m_notebook->DeletePage( i );
772 }
773 }
774
775 m_leftWin->EmptyTreePrj();
777
778 return true;
779}
780
781
782void KICAD_MANAGER_FRAME::OpenJobsFile( const wxFileName& aFileName, bool aCreate,
783 bool aResaveProjectPreferences )
784{
785 for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
786 {
787 if( PANEL_JOBSET* panel = dynamic_cast<PANEL_JOBSET*>( m_notebook->GetPage( i ) ) )
788 {
789 if( aFileName.GetFullPath() == panel->GetFilePath() )
790 {
791 m_notebook->SetSelection( i );
792 return;
793 }
794 }
795 }
796
797 try
798 {
799 std::unique_ptr<JOBSET> jobsFile = std::make_unique<JOBSET>( aFileName.GetFullPath().ToStdString() );
800
801 jobsFile->LoadFromFile();
802
803 if( aCreate && !aFileName.FileExists() )
804 {
805 JOBSET_DESTINATION* dest = jobsFile->AddNewDestination( JOBSET_DESTINATION_T::FOLDER );
806 dest->m_outputHandler->SetOutputPath( aFileName.GetName() );
807 jobsFile->SaveToFile( wxEmptyString, true );
808 }
809
810 PANEL_JOBSET* jobPanel = new PANEL_JOBSET( m_notebook, this, std::move( jobsFile ) );
811 jobPanel->SetProjectTied( true );
812 jobPanel->SetClosable( true );
813 m_notebook->AddPage( jobPanel, aFileName.GetFullName(), true );
815
816 if( aResaveProjectPreferences )
818 }
819 catch( ... )
820 {
821 DisplayErrorMessage( this, _( "Error opening jobs file" ) );
822 }
823}
824
825
826void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
827{
828 // The project file should be valid by the time we get here or something has gone wrong.
829 if( !aProjectFileName.Exists() )
830 return;
831
832 // Any open KIFACE's must be closed if they are not part of the new project.
833 // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
834 // User is prompted here to close those KIWAY_PLAYERs:
835 if( !CloseProject( true ) )
836 return;
837
838 m_active_project = true;
839
840 // NB: when loading a legacy project SETTINGS_MANAGER::LoadProject() will convert it to
841 // current extension. Be very careful with aProjectFileName vs. Prj().GetProjectPath()
842 // from here on out.
843
844 Pgm().GetSettingsManager().LoadProject( aProjectFileName.GetFullPath() );
845 LoadWindowState( aProjectFileName.GetFullName() );
846
847 if( aProjectFileName.IsDirWritable() )
848 SetMruPath( Prj().GetProjectPath() );
849
850 Kiway().LocalHistory().Init( Prj().GetProjectPath() );
851
852 if( Kiway().LocalHistory().HeadNewerThanLastSave( Prj().GetProjectPath() ) )
853 {
854 wxString head = Kiway().LocalHistory().GetHeadHash( Prj().GetProjectPath() );
855 if( wxMessageBox( _( "A newer local history snapshot is available. Restore it?" ),
856 _( "Restore" ), wxYES_NO | wxICON_QUESTION, this ) == wxYES )
857 Kiway().LocalHistory().RestoreCommit( Prj().GetProjectPath(), head, this );
858 }
859
860 // Save history & window state to disk now. Don't wait around for a crash.
861 KICAD_SETTINGS* settings = kicadSettings();
862 SaveSettings( settings );
863 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
864
865 m_leftWin->ReCreateTreePrj();
866 m_historyPane->RefreshHistory( Prj().GetProjectPath() );
867
868 for( const wxString& jobset : Prj().GetLocalSettings().m_OpenJobSets )
869 {
870 wxFileName jobsetFn( jobset );
871 jobsetFn.MakeAbsolute( Prj().GetProjectPath() );
872
873 if( jobsetFn.Exists() )
874 OpenJobsFile( jobsetFn.GetFullPath(), false, false );
875 }
876
877 // Always start with the apps page
878 m_notebook->SetSelection( 0 );
879
880 // Rebuild the list of watched paths.
881 // however this is possible only when the main loop event handler is running,
882 // so we use it to run the rebuild function.
883 wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
884
885 wxPostEvent( this, cmd );
886
887 PrintPrjInfo();
888
889 KIPLATFORM::APP::RegisterApplicationRestart( aProjectFileName.GetFullPath() );
890 m_openSavedWindows = true;
891
892 KIPLATFORM::ENV::AddToRecentDocs( aProjectFileName.GetFullPath() );
893
894 // Now that we have a new project, trigger a library preload, which will load in any
895 // project-specific symbol and footprint libraries into the manager
896 CallAfter( [&]()
897 {
898 KIFACE *schface = Kiway().KiFACE( KIWAY::FACE_SCH );
899 schface->PreloadLibraries( &Kiway() );
900
902 } );
903}
904
905
906void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName, bool aCreateStubFiles )
907{
908 wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
909 "Project folder must exist and be writable to create a new project." );
910
911 // If the project is legacy, convert it
912 if( !aProjectFileName.FileExists() )
913 {
914 wxFileName legacyPro( aProjectFileName );
915 legacyPro.SetExt( FILEEXT::LegacyProjectFileExtension );
916
917 if( legacyPro.FileExists() )
918 {
919 GetSettingsManager()->LoadProject( legacyPro.GetFullPath() );
921
922 wxRemoveFile( legacyPro.GetFullPath() );
923 }
924 else
925 {
926 // Copy template project file from template folder.
927 wxString srcFileName = sys_search().FindValidPath( "kicad.kicad_pro" );
928
929 wxFileName destFileName( aProjectFileName );
930 destFileName.SetExt( FILEEXT::ProjectFileExtension );
931
932 // Create a minimal project file if the template project file could not be copied
933 if( !wxFileName::FileExists( srcFileName )
934 || !wxCopyFile( srcFileName, destFileName.GetFullPath() ) )
935 {
936 wxFFile file( destFileName.GetFullPath(), "wb" );
937
938 if( file.IsOpened() )
939 file.Write( wxT( "{\n}\n") );
940
941 // wxFFile dtor will close the file
942 }
943 }
944 }
945
946 // Create a "stub" for a schematic root sheet and a board if requested.
947 // It will avoid messages from the schematic editor or the board editor to create a new file
948 // And forces the user to create main files under the right name for the project manager
949 if( aCreateStubFiles )
950 {
951 wxFileName fn( aProjectFileName.GetFullPath() );
953
954 // If a <project>.kicad_sch file does not exist, create a "stub" file ( minimal schematic
955 // file ).
956 if( !fn.FileExists() )
957 {
958 wxFFile file( fn.GetFullPath(), "wb" );
959
960 if( file.IsOpened() )
961 {
962 file.Write( wxString::Format( "(kicad_sch\n"
963 "\t(version %d)\n"
964 "\t(generator \"eeschema\")\n"
965 "\t(generator_version \"%s\")\n"
966 "\t(uuid %s)\n"
967 "\t(paper \"A4\")\n"
968 "\t(lib_symbols)\n"
969 "\t(sheet_instances\n"
970 "\t\t(path \"/\"\n"
971 "\t\t\t(page \"1\")\n"
972 "\t\t)\n"
973 "\t)\n"
974 "\t(embedded_fonts no)\n"
975 ")",
977 KIID().AsString() ) );
978 }
979
980 // wxFFile dtor will close the file
981 }
982
983 // If a <project>.kicad_pcb or <project>.brd file does not exist,
984 // create a .kicad_pcb "stub" file
986 wxFileName leg_fn( fn );
987 leg_fn.SetExt( FILEEXT::LegacyPcbFileExtension );
988
989 if( !fn.FileExists() && !leg_fn.FileExists() )
990 {
991 wxFFile file( fn.GetFullPath(), "wb" );
992
993 if( file.IsOpened() )
994 {
995 // Create a small dummy file as a stub for pcbnew:
996 file.Write( wxString::Format( "(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n)",
998 }
999
1000 // wxFFile dtor will close the file
1001 }
1002 }
1003
1004 // Save history & window state to disk now. Don't wait around for a crash.
1005 KICAD_SETTINGS* settings = kicadSettings();
1006 SaveSettings( settings );
1007 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
1008
1009 m_openSavedWindows = true;
1010}
1011
1012
1014{
1015 // show all files in file dialog (in Kicad all files are editable texts):
1016 wxString wildcard = FILEEXT::AllFilesWildcard();
1017
1018 wxString default_dir = Prj().GetProjectPath();
1019
1020 wxFileDialog dlg( this, _( "Edit File in Text Editor" ), default_dir, wxEmptyString, wildcard,
1021 wxFD_OPEN );
1022
1023 if( dlg.ShowModal() == wxID_CANCEL )
1024 return;
1025
1026 wxString filename = dlg.GetPath();
1027
1028 if( !dlg.GetPath().IsEmpty() && !Pgm().GetTextEditor().IsEmpty() )
1029 m_toolManager->RunAction<wxString*>( KICAD_MANAGER_ACTIONS::openTextEditor, &filename );
1030}
1031
1032
1033void KICAD_MANAGER_FRAME::OnEditAdvancedCfg( wxCommandEvent& WXUNUSED( event ) )
1034{
1035 DIALOG_EDIT_CFG dlg( this );
1036 dlg.ShowModal();
1037}
1038
1039
1041{
1042 m_leftWin->ReCreateTreePrj();
1043}
1044
1045
1046void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
1047{
1048 int id = event.GetId();
1049 Kiway().SetLanguage( id );
1050}
1051
1052
1054{
1055 // call my base class
1057
1058 // tooltips in toolbars
1060 m_launcher->CreateLaunchers();
1061
1062 // update captions
1063 int pageId = m_notebook->FindPage( m_launcher );
1064
1065 if( pageId != wxNOT_FOUND )
1066 m_notebook->SetPageText( pageId, EDITORS_CAPTION );
1067
1068 m_auimgr.GetPane( m_leftWin ).Caption( PROJECT_FILES_CAPTION );
1069 m_auimgr.Update();
1070
1071 m_leftWin->FileWatcherReset();
1072
1073 PrintPrjInfo();
1074}
1075
1076
1078{
1080
1081 if( m_pcm && ( aFlags & ENVVARS_CHANGED ) )
1082 m_pcm->ReadEnvVar();
1083
1084 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
1085
1086 if( m_lastToolbarIconSize == 0
1088 {
1091 }
1092
1093 m_leftWin->ReCreateTreePrj();
1094}
1095
1096
1098{
1099 wxString file = GetProjectFileName();
1100
1101 // empty file string means no project loaded
1102 if( !Prj().IsNullProject() &&
1103 Prj().GetProjectLock() == nullptr )
1104 {
1105 LOCKFILE lockFile( file );
1106
1107 if( !lockFile.Valid() && lockFile.IsLockedByMe() )
1108 {
1109 // If we cannot acquire the lock but we appear to be the one who
1110 // locked it, check to see if there is another KiCad instance running.
1111 // If there is not, then we can override the lock. This could happen if
1112 // KiCad crashed or was interrupted
1113 if( !Pgm().SingleInstance()->IsAnotherRunning() )
1114 {
1115 lockFile.OverrideLock();
1116 }
1117 }
1118
1119 if( !lockFile.Valid() )
1120 {
1121 wxString msg;
1122 msg.Printf( _( "Project '%s' is already open by '%s' at '%s'." ), file, lockFile.GetUsername(),
1123 lockFile.GetHostname() );
1124
1125 if( AskOverrideLock( this, msg ) )
1126 {
1127 lockFile.OverrideLock();
1128 }
1129 }
1130
1131 Prj().SetReadOnly( !lockFile.Valid() || Prj().GetProjectFile().IsReadOnly() );
1132 Prj().SetProjectLock( new LOCKFILE( std::move( lockFile ) ) );
1133 }
1134
1135 wxString title;
1136
1137 if( !file.IsEmpty() )
1138 {
1139 wxFileName fn( file );
1140
1141 title = fn.GetName();
1142
1143 if( Prj().IsReadOnly() )
1144 title += wxS( " " ) + _( "[Read Only]" );
1145 }
1146 else
1147 {
1148 title = _( "[no project loaded]" );
1149 }
1150
1151 if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
1152 title += wxT( " \u2014 " ) + wxString( wxS( "KiCad" ) );
1153 else
1154 title += wxT( " \u2014 " ) + wxString( wxS( "KiCad " ) ) + GetMajorMinorVersion();
1155
1156 SetTitle( title );
1157}
1158
1159
1161{
1163
1164 auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
1165
1166 wxCHECK( settings, /*void*/ );
1167
1168 m_leftWinWidth = settings->m_LeftWinWidth;
1169 m_showHistoryPanel = settings->m_ShowHistoryPanel;
1170}
1171
1172
1174{
1176
1177 auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
1178
1179 wxCHECK( settings, /*void*/);
1180
1181 settings->m_LeftWinWidth = m_leftWin->GetSize().x;
1182 settings->m_ShowHistoryPanel = m_historyPane &&
1183 m_auimgr.GetPane( m_historyPane ).IsShown();
1184
1185 if( !m_isClosing )
1186 settings->m_OpenProjects = GetSettingsManager()->GetOpenProjects();
1187}
1188
1189
1191{
1192 // wxStatusBar's wxELLIPSIZE_MIDDLE flag doesn't work (at least on Mac).
1193
1194 wxString status = wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() );
1195 KISTATUSBAR* statusBar = static_cast<KISTATUSBAR*>( GetStatusBar() );
1196 statusBar->SetEllipsedTextField( status, 0 );
1197}
1198
1199
1204
1205
1206void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
1207{
1213 if( !m_openSavedWindows )
1214 return;
1215
1216 m_openSavedWindows = false;
1217
1218 if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
1219 {
1220 int previousOpenCount =
1221 std::count_if( Prj().GetLocalSettings().m_files.begin(),
1222 Prj().GetLocalSettings().m_files.end(),
1223 [&]( const PROJECT_FILE_STATE& f )
1224 {
1225 return !f.fileName.EndsWith( FILEEXT::ProjectFileExtension ) && f.open;
1226 } );
1227
1228 if( previousOpenCount > 0 )
1229 {
1230 APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
1231 previousOpenCount, this );
1232
1233 // We don't currently support opening more than one view per file
1234 std::set<wxString> openedFiles;
1235
1236 int i = 0;
1237
1238 for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
1239 {
1240 if( file.open && !openedFiles.count( file.fileName ) )
1241 {
1242 progressReporter.Update( i++, wxString::Format( _( "Restoring '%s'" ), file.fileName ) );
1243
1244 openedFiles.insert( file.fileName );
1245 wxFileName fn( file.fileName );
1246
1247 if( fn.GetExt() == FILEEXT::LegacySchematicFileExtension
1248 || fn.GetExt() == FILEEXT::KiCadSchematicFileExtension )
1249 {
1251 }
1252 else if( fn.GetExt() == FILEEXT::LegacyPcbFileExtension
1253 || fn.GetExt() == FILEEXT::KiCadPcbFileExtension )
1254 {
1256 }
1257 }
1258
1259 wxYield();
1260 }
1261 }
1262 }
1263
1264 // clear file states regardless if we opened windows or not due to setting
1266
1267 KICAD_SETTINGS* settings = kicadSettings();
1268
1270 && settings->m_PcmUpdateCheck )
1271 {
1272 if( !m_pcm )
1273 CreatePCM();
1274
1275 m_pcm->RunBackgroundUpdate();
1276 }
1277
1278#ifdef KICAD_UPDATE_CHECK
1279 if( !m_updateManager && settings->m_KiCadUpdateCheck )
1280 {
1281 m_updateManager = std::make_unique<UPDATE_MANAGER>();
1282 m_updateManager->CheckForUpdate( this );
1283 }
1284#endif
1285
1286 // This little diddy is needed to get the window put into the Mac dock icon's context menu.
1287 Raise();
1288}
1289
1290
1292{
1293 m_pcmButton = aButton;
1294
1296}
1297
1298
1300{
1301 if( m_pcmButton )
1302 {
1303 if( m_pcmUpdateCount > 0 )
1304 {
1305 m_pcmButton->SetShowBadge( true );
1306 m_pcmButton->SetBadgeText( wxString::Format( "%d", m_pcmUpdateCount ) );
1307 }
1308 else
1309 {
1310 m_pcmButton->SetShowBadge( false );
1311 }
1312
1313 m_pcmButton->Refresh();
1314 }
1315}
1316
1317
1319{
1320 // No idea why, but the same mechanism used in EDA_DRAW_FRAME doesn't work here
1321 // the only thing that seems to work is to blow it all up and start from scratch.
1322 m_auimgr.DetachPane( m_tbLeft );
1323 delete m_tbLeft;
1324 m_tbLeft = nullptr;
1326 m_auimgr.AddPane( m_tbLeft, EDA_PANE().HToolbar().Name( "TopMainToolbar" ).Left()
1327 .Layer( 2 ) );
1328
1329 m_auimgr.Update();
1330}
1331
1332
1334{
1335 wxAuiPaneInfo& pane = m_auimgr.GetPane( m_historyPane );
1336 bool show = !pane.IsShown();
1337 pane.Show( show );
1338
1339 if( show )
1340 m_historyPane->RefreshHistory( Prj().GetProjectPath() );
1341
1342 m_auimgr.Update();
1343}
1344
1345
1347{
1348 if( !Kiway().PlayersClose( true ) )
1349 return;
1350
1351 Kiway().LocalHistory().RestoreCommit( Prj().GetProjectPath(), aHash, this );
1352 m_leftWin->ReCreateTreePrj();
1353 m_openSavedWindows = true;
1354 m_historyPane->RefreshHistory( Prj().GetProjectPath() );
1355}
1356
1357
1359{
1360 return m_historyPane && m_auimgr.GetPane( m_historyPane ).IsShown();
1361}
const char * name
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_nightly
@ 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.
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.
Handle actions that are shared between different applications.
APPEARANCE m_Appearance
AUTO_BACKUP m_Backup
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.
void SetOutputPath(const wxString &aPath)
Definition jobs_output.h:55
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 loadProject
static TOOL_ACTION showLocalHistory
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 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
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 RestoreCommitFromHistory(const wxString &aHash)
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()
void OnEditAdvancedCfg(wxCommandEvent &event)
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)
LOCAL_HISTORY_PANE * m_historyPane
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
std::unique_ptr< UPDATE_MANAGER > m_updateManager
std::vector< wxString > m_OpenProjects
Definition kiid.h:49
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
Definition kistatusbar.h:46
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.
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all #KIWAY_PLAYERs.
Definition kiway.cpp:526
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
Definition kiway.cpp:206
@ FACE_SCH
eeschema DSO
Definition kiway.h:299
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
Definition kiway.h:404
wxString GetHeadHash(const wxString &aProjectPath)
Return the current head commit hash.
bool RestoreCommit(const wxString &aProjectPath, const wxString &aHash, wxWindow *aParent=nullptr)
Restore the project files to the state recorded by the given commit hash.
bool EnforceSizeLimit(const wxString &aProjectPath, size_t aMaxBytes)
Enforce total size limit by rebuilding trimmed history keeping newest commits whose cumulative unique...
bool Init(const wxString &aProjectPath)
Initialize the local history repository for the given project path.
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:96
void SetClosable(bool aYes)
void SetProjectTied(bool aYes)
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:537
void PreloadDesignBlockLibraries(KIWAY *aKiway)
Starts a background job to preload the global and project design block libraries.
Definition pgm_base.cpp:871
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition pgm_base.h:134
bool m_Quitting
Definition pgm_base.h:369
virtual NOTIFICATIONS_MANAGER & GetNotificationsManager() const
Definition pgm_base.h:139
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:128
wxString GetHelpFileName()
Definition pgm_kicad.h:63
SEARCH_STACK & SysSearch()
Definition pgm_kicad.h:61
APP_SETTINGS_BASE * PgmSettings()
Definition pgm_kicad.h:59
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 SetProjectLock(LOCKFILE *aLockFile)
Definition project.cpp:476
virtual void SetReadOnly(bool aReadOnly=true)
Definition project.h:169
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition project.cpp:159
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:165
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
Definition project.h:211
Look for files in a number of paths.
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
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
virtual void DispatchWxEvent(wxEvent &aEvent)
Process wxEvents (mostly UI events), translate them to TOOL_EVENTs, and make tools handle those.
Master controller class:
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
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:202
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
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
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:85
@ ID_EDIT_ADVANCED_CFG
Definition kicad_id.h:38
@ ID_IMPORT_EAGLE_PROJECT
Definition kicad_id.h:40
@ ID_IMPORT_EASYEDAPRO_PROJECT
Definition kicad_id.h:42
@ ID_IMPORT_CADSTAR_ARCHIVE_PROJECT
Definition kicad_id.h:39
@ ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR
Definition kicad_id.h:37
@ ID_IMPORT_EASYEDA_PROJECT
Definition kicad_id.h:41
@ ID_IMPORT_ALTIUM_PROJECT
Definition kicad_id.h:43
#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)
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
#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:946
#define POLICY_KEY_PCM
Definition policy_keys.h:31
#define SEXPR_SCHEMATIC_FILE_VERSION
Schematic file version.
T * GetToolbarSettings(const wxString &aFilename)
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)
unsigned long long limit_total_size
Maximum total size of backups (bytes), 0 for unlimited.
std::shared_ptr< JOBS_OUTPUT_HANDLER > m_outputHandler
Definition jobset.h:136
Implement a participant in the KIWAY alchemy.
Definition kiway.h:155
virtual void PreloadLibraries(KIWAY *aKiway)
Definition kiway.h:258
#define ENVVARS_CHANGED
Definition of file extensions used in Kicad.