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