KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_manager_frame.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2013 CERN (www.cern.ch)
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include "kicad_id.h"
27#include "pcm.h"
28#include "pgm_kicad.h"
29#include "project_tree_pane.h"
31
32#include <advanced_config.h>
34#include <bitmaps.h>
35#include <build_version.h>
36#include <confirm.h>
41#include <eda_base_frame.h>
42#include <executable_names.h>
43#include <file_history.h>
44#include <policy_keys.h>
45#include <gestfich.h>
46#include <kiplatform/app.h>
48#include <kiplatform/policy.h>
49#include <build_version.h>
50#include <kiway.h>
51#include <kiway_express.h>
52#include <launch_ext.h>
53#include <lockfile.h>
55#include <reporter.h>
57#include <sch_file_versions.h>
59#include <tool/action_manager.h>
60#include <tool/action_toolbar.h>
61#include <tool/common_control.h>
63#include <tool/tool_manager.h>
69#include <widgets/kistatusbar.h>
70#include <wx/ffile.h>
71#include <wx/filedlg.h>
72#include <wx/dnd.h>
73#include <wx/process.h>
74#include <wx/snglinst.h>
75#include <atomic>
76#include <update_manager.h>
77#include <jobs/jobset.h>
78
79#include <../pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h> // for SEXPR_BOARD_FILE_VERSION def
80
81
82#ifdef __WXMAC__
83#include <MacTypes.h>
84#include <ApplicationServices/ApplicationServices.h>
85#endif
86
87#include "kicad_manager_frame.h"
89
91
92
93#define EDITORS_CAPTION _( "Editors" )
94#define PROJECT_FILES_CAPTION _( "Project Files" )
95
96#define ID_INIT_WATCHED_PATHS 52913
97
98#define SEP() wxFileName::GetPathSeparator()
99
100
101// Menubar and toolbar event table
102BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
103 // Window events
106
107 // Menu events
108 EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
116
117 // Range menu events
119 KICAD_MANAGER_FRAME::language_change )
120
122 EVT_MENU( ID_FILE_LIST_CLEAR, KICAD_MANAGER_FRAME::OnClearFileHistory )
123
124 // Special functions
125 EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
126
127 // Drop files event
128 EVT_DROP_FILES( KICAD_MANAGER_FRAME::OnDropFiles )
129
130END_EVENT_TABLE()
131
132// See below the purpose of this include
133#include <wx/xml/xml.h>
134
135KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
136 const wxPoint& pos, const wxSize& size ) :
139 m_active_project( false ),
140 m_leftWin( nullptr ),
141 m_launcher( nullptr ),
142 m_lastToolbarIconSize( 0 ),
143 m_pcmButton( nullptr ),
144 m_pcmUpdateCount( 0 )
145{
146 const int defaultLeftWinWidth = FromDIP( 250 );
147
148 m_leftWinWidth = defaultLeftWinWidth; // Default value
149 m_aboutTitle = "KiCad";
150
151 // JPC: A very ugly hack to fix an issue on Linux: if the wxbase315u_xml_gcc_custom.so is
152 // used **only** in PCM, it is not found in some cases at run time.
153 // So just use it in the main module to avoid a not found issue
154 // wxbase315u_xml_gcc_custom shared object when launching Kicad
155 wxXmlDocument dummy;
156
157 // Create the status line (bottom of the frame). Left half is for project name; right half
158 // is for Reporter (currently used by archiver/unarchiver and PCM).
159 // Note: this is a KISTATUSBAR status bar. Therefore the specified number of fields
160 // is the extra number of fields, not the full field count.
161 // We need here 2 fields: the extra fiels to display the project name, and another field
162 // to display a info (specific to Windows) using the FIELD_OFFSET_BGJOB_TEXT id offset (=1)
163 // So the extra field count is 1
164 CreateStatusBar( 1 );
167 GetStatusBar()->SetFont( KIUI::GetStatusFont( this ) );
168
169 // Give an icon
170 wxIcon icon;
171 wxIconBundle icon_bundle;
172
173 if( IsNightlyVersion())
174 {
175 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly, 48 ) );
176 icon_bundle.AddIcon( icon );
177 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly, 128 ) );
178 icon_bundle.AddIcon( icon );
179 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly, 256 ) );
180 icon_bundle.AddIcon( icon );
181 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_32 ) );
182 icon_bundle.AddIcon( icon );
183 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_nightly_16 ) );
184 icon_bundle.AddIcon( icon );
185 }
186 else
187 {
188 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad, 48 ) );
189 icon_bundle.AddIcon( icon );
190 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad, 128 ) );
191 icon_bundle.AddIcon( icon );
192 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad, 256 ) );
193 icon_bundle.AddIcon( icon );
194 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_32 ) );
195 icon_bundle.AddIcon( icon );
196 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_kicad_16 ) );
197 icon_bundle.AddIcon( icon );
198 }
199
200 SetIcons( icon_bundle );
201
202 // Load the settings
203 LoadSettings( config() );
204
205 // Left window: is the box which display tree project
206 m_leftWin = new PROJECT_TREE_PANE( this );
207
208 setupTools();
209 setupUIConditions();
210
211 m_toolbarSettings = GetToolbarSettings<KICAD_MANAGER_TOOLBAR_SETTINGS>( "kicad-toolbars" );
212 configureToolbars();
213 RecreateToolbars();
214 ReCreateMenuBar();
215
216 m_auimgr.SetManagedWindow( this );
217 m_auimgr.SetFlags( wxAUI_MGR_LIVE_RESIZE );
218
219 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( "TopMainToolbar" ).Left().Layer( 2 ) );
220
221 // BestSize() does not always set the actual pane size of m_leftWin to the required value.
222 // It happens when m_leftWin is too large (roughly > 1/3 of the kicad manager frame width.
223 // (Well, BestSize() sets the best size... not the window size)
224 // A trick is to use MinSize() to set the required pane width,
225 // and after give a reasonable MinSize value
226 m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer( 1 )
227 .Caption( PROJECT_FILES_CAPTION ).PaneBorder( false )
228 .MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) );
229
230 wxSize client_size = GetClientSize();
231 m_notebook = new wxAuiNotebook( this, wxID_ANY, wxPoint( client_size.x, client_size.y ),
232 FromDIP( wxSize( 700, 590 ) ),
233 wxAUI_NB_TOP | wxAUI_NB_CLOSE_ON_ALL_TABS | wxAUI_NB_TAB_MOVE
234 | wxAUI_NB_SCROLL_BUTTONS | wxNO_BORDER );
235
236 m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CLOSE, &KICAD_MANAGER_FRAME::onNotebookPageCloseRequest, this );
237 m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CLOSED, &KICAD_MANAGER_FRAME::onNotebookPageCountChanged, this );
238 m_launcher = new PANEL_KICAD_LAUNCHER( m_notebook );
239
240 m_notebook->Freeze();
241 m_launcher->SetClosable( false );
242 m_notebook->AddPage( m_launcher, EDITORS_CAPTION, false );
243 m_notebook->SetTabCtrlHeight( 0 );
244 m_notebook->Thaw();
245
246 m_auimgr.AddPane( m_notebook, EDA_PANE().Canvas().Name( "Editors" ).Center().Caption( EDITORS_CAPTION )
247 .PaneBorder( false ).MinSize( m_notebook->GetBestSize() ) );
248
249 m_auimgr.Update();
250
251 // Now the actual m_leftWin size is set, give it a reasonable min width
252 m_auimgr.GetPane( m_leftWin ).MinSize( defaultLeftWinWidth, -1 );
253
254
255 wxSizer* mainSizer = GetSizer();
256
257 // Only fit the initial window size the first time KiCad is run.
258 if( mainSizer && config()->m_Window.state.size_x == 0 && config()->m_Window.state.size_y == 0 )
259 {
260 Layout();
261 mainSizer->Fit( this );
262 Center();
263 }
264
265 if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
266 SetTitle( wxT( "KiCad" ) );
267 else
268 SetTitle( wxString( "KiCad " ) + GetMajorMinorVersion() );
269
270 // Do not let the messages window have initial focus
271 m_leftWin->SetFocus();
272
273 // Init for dropping files
276
277 // Gerber files
278 // Note that all gerber files are aliased as GerberFileExtension
282
283 DragAcceptFiles( true );
284
285 // Ensure the window is on top
286 Raise();
287
288 Bind( wxEVT_DPI_CHANGED,
289 [&]( wxDPIChangedEvent& )
290 {
291 m_auimgr.Update();
292
293 // Don't skip, otherwise the frame gets too big
294 } );
295}
296
297
299{
301 Unbind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
302
303 m_notebook->Unbind( wxEVT_AUINOTEBOOK_PAGE_CLOSE, &KICAD_MANAGER_FRAME::onNotebookPageCloseRequest, this );
304 m_notebook->Unbind( wxEVT_AUINOTEBOOK_PAGE_CLOSED, &KICAD_MANAGER_FRAME::onNotebookPageCountChanged, this );
305
308
309 // Shutdown all running tools
310 if( m_toolManager )
311 m_toolManager->ShutdownAllTools();
312
313 if( m_pcm )
314 m_pcm->StopBackgroundUpdate();
315
316 delete m_actions;
317 delete m_toolManager;
318 delete m_toolDispatcher;
319
320 m_auimgr.UnInit();
321}
322
324{
325 if( m_notebook->GetPageCount() == 1 )
326 m_notebook->SetTabCtrlHeight( 0 );
327 else
328 m_notebook->SetTabCtrlHeight( -1 );
329}
330
331
333{
335}
336
337
339{
340 wxAuiNotebook* notebook = (wxAuiNotebook*) evt.GetEventObject();
341 wxWindow* page = notebook->GetPage( evt.GetSelection() );
342
343 if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
344 {
345 if( panel->GetClosable() )
346 {
347 if( !panel->GetCanClose() )
348 evt.Veto();
349
350 CallAfter(
351 [this]()
352 {
354 } );
355 }
356 else
357 {
358 evt.Veto();
359 }
360 }
361}
362
363
364wxStatusBar* KICAD_MANAGER_FRAME::OnCreateStatusBar( int number, long style, wxWindowID id,
365 const wxString& name )
366{
367 return new KISTATUSBAR( number, this, id );
368}
369
370
372{
373 // creates the PLUGIN_CONTENT_MANAGER, if not exists
374 if( m_pcm )
375 return;
376
377 m_pcm = std::make_shared<PLUGIN_CONTENT_MANAGER>(
378 [this]( int aUpdateCount )
379 {
380 m_pcmUpdateCount = aUpdateCount;
381
382 if( aUpdateCount > 0 )
383 {
385 wxS( "pcm" ),
386 _( "PCM Updates Available" ),
387 wxString::Format( _( "%d package update(s) avaliable" ), aUpdateCount ),
388 wxT( "" ) );
389 }
390 else
391 {
392 Pgm().GetNotificationsManager().Remove( wxS( "pcm" ) );
393 }
394
395 CallAfter(
396 [this]()
397 {
399 } );
400 });
401
402 m_pcm->SetRepositoryList( kicadSettings()->m_PcmRepositories );
403}
404
405
407{
408 // Create the manager
410 m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
412
414
415 // Attach the events to the tool dispatcher
417 Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
418
419 // Register tools
420 m_toolManager->RegisterTool( new COMMON_CONTROL );
421 m_toolManager->RegisterTool( new KICAD_MANAGER_CONTROL );
422 m_toolManager->InitTools();
423}
424
425
427{
429
430 ACTION_MANAGER* manager = m_toolManager->GetActionManager();
431
432 wxASSERT( manager );
433
434 auto activeProject =
435 [this] ( const SELECTION& )
436 {
437 return m_active_project;
438 };
439
440#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
441
442 ACTION_CONDITIONS activeProjectCond;
443 activeProjectCond.Enable( activeProject );
444
445 manager->SetConditions( ACTIONS::saveAs, activeProjectCond );
446 manager->SetConditions( KICAD_MANAGER_ACTIONS::closeProject, activeProjectCond );
447 manager->SetConditions( KICAD_MANAGER_ACTIONS::archiveProject, activeProjectCond );
448 manager->SetConditions( KICAD_MANAGER_ACTIONS::newJobsetFile, activeProjectCond );
449 manager->SetConditions( KICAD_MANAGER_ACTIONS::openJobsetFile, activeProjectCond );
450
451 // These are just here for text boxes, search boxes, etc. in places such as the standard
452 // file dialogs.
456
457#undef ENABLE
458}
459
460
462{
463 return m_leftWin;
464}
465
466
468{
470 wxASSERT( ret );
471 return ret;
472}
473
474
476{
477 KICAD_SETTINGS* ret = dynamic_cast<KICAD_SETTINGS*>( config() );
478 wxASSERT( ret );
479 return ret;
480}
481
482
484{
486 : wxString( wxEmptyString );
487}
488
489
491{
492 wxFileName fn( GetProjectFileName() );
493
495 return fn.GetFullPath();
496}
497
498
500{
501 wxFileName fn( GetProjectFileName() );
502
504 return fn.GetFullPath();
505}
506
507
509{
510 wxFileName fn( GetProjectFileName() );
511
512 fn.SetExt( FILEEXT::PcbFileExtension );
513 return fn.GetFullPath();
514}
515
516
518{
519 wxFileName fn( GetProjectFileName() );
520
522 return fn.GetFullPath();
523}
524
525
527{
528 m_leftWin->ReCreateTreePrj();
529}
530
531
536
537
539{
540 return PgmTop().GetHelpFileName();
541}
542
543
544void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event )
545{
546 if( m_auimgr.GetManagedWindow() )
547 m_auimgr.Update();
548
549 PrintPrjInfo();
550
551#if defined( _WIN32 )
552 KISTATUSBAR* statusBar = static_cast<KISTATUSBAR*>( GetStatusBar() );
554#endif
555
556 event.Skip();
557}
558
559
561{
562 // All fileNames are now in m_AcceptedFiles vector.
563 // Check if contains a project file name and load project.
564 // If not, open files in dedicated app.
565 for( const wxFileName& fileName : m_AcceptedFiles )
566 {
567 wxString ext = fileName.GetExt();
568
570 {
571 wxString fn = fileName.GetFullPath();
572 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( fileName.GetExt() ), &fn );
573
574 return;
575 }
576 }
577
578 // Then stock gerber files in gerberFiles and run action for other files.
579 wxString gerberFiles;
580
581 // Gerbview editor should be able to open Gerber and drill files
582 for( const wxFileName& fileName : m_AcceptedFiles )
583 {
584 wxString ext = fileName.GetExt();
585
588 {
589 gerberFiles += wxT( '\"' );
590 gerberFiles += fileName.GetFullPath() + wxT( '\"' );
591 gerberFiles = gerberFiles.Pad( 1 );
592 }
593 else
594 {
595 wxString fn = fileName.GetFullPath();
596 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( fileName.GetExt() ), &fn );
597 }
598 }
599
600 // Execute Gerbviewer
601 if( !gerberFiles.IsEmpty() )
602 {
603 wxString fullEditorName = FindKicadFile( GERBVIEW_EXE );
604
605 if( wxFileExists( fullEditorName ) )
606 {
607 wxString command = fullEditorName + " " + gerberFiles;
608 m_toolManager->RunAction<wxString*>( *m_acceptedExts.at( FILEEXT::GerberFileExtension ), &command );
609 }
610 }
611}
612
613
614bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
615{
616 KICAD_SETTINGS* settings = kicadSettings();
618
619 for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
620 {
621 wxWindow* page = m_notebook->GetPage( i );
622
623 if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
624 {
625 if( !panel->GetCanClose() )
626 return false;
627 }
628 }
629
630 // CloseProject will recursively ask all the open editors if they need to save changes.
631 // If any of them cancel then we need to cancel closing the KICAD_MANAGER_FRAME.
632 if( CloseProject( true ) )
633 {
634 // Don't propagate event to frames which have already been closed
635 aEvent.StopPropagation();
636
637 return true;
638 }
639 else
640 {
641 if( aEvent.CanVeto() )
642 aEvent.Veto();
643
644 return false;
645 }
646}
647
648
650{
651#ifdef _WINDOWS_
652 // For some obscure reason, on Windows, when killing Kicad from the Windows task manager
653 // if a editor frame (schematic, library, board editor or fp editor) is open and has
654 // some edition to save, OnCloseWindow is run twice *at the same time*, creating race
655 // conditions between OnCloseWindow() code.
656 // Therefore I added (JPC) a ugly hack to discard the second call (unwanted) during
657 // execution of the first call (only one call is right).
658 // Note also if there is no change made in editors, this behavior does not happen.
659 static std::atomic<unsigned int> lock_close_event( 0 );
660
661 if( ++lock_close_event > 1 ) // Skip extra calls
662 {
663 return;
664 }
665#endif
666
667 m_leftWin->Show( false );
668 Pgm().m_Quitting = true;
669
670 Destroy();
671
672#ifdef _WINDOWS_
673 lock_close_event = 0; // Reenable event management
674#endif
675}
676
677
679{
681
682 if( !aIsExplicitUserSave && !cfg.ShouldAutoSave() )
683 return;
684
685 cfg.m_OpenJobSets.clear();
686
687 for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
688 {
689 if( PANEL_JOBSET* jobset = dynamic_cast<PANEL_JOBSET*>( m_notebook->GetPage( i ) ) )
690 {
691 wxFileName jobsetFn( jobset->GetFilePath() );
692 jobsetFn.MakeRelativeTo( Prj().GetProjectPath() );
693 cfg.m_OpenJobSets.emplace_back( jobsetFn.GetFullPath() );
694 }
695 }
696
697 cfg.SaveToFile( Prj().GetProjectPath() );
698}
699
700
701void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
702{
703 Close( true );
704}
705
706
708{
709 if( !Kiway().PlayersClose( false ) )
710 return false;
711
712 // Save the project file for the currently loaded project.
713 if( m_active_project )
714 {
716
717 if( Prj().GetLocalSettings().ShouldAutoSave() && Prj().GetProjectFile().ShouldAutoSave() )
718 {
720
721 if( aSave )
722 mgr.SaveProject();
723 }
724
725 m_active_project = false;
726 mgr.UnloadProject( &Prj() );
727 }
728
729 SetStatusText( "" );
730
731 // Traverse pages in reverse order so deleting them doesn't mess up our iterator.
732 for( int i = (int) m_notebook->GetPageCount() - 1; i >= 0; i-- )
733 {
734 wxWindow* page = m_notebook->GetPage( i );
735
736 if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
737 {
738 if( panel->GetProjectTied() )
739 m_notebook->DeletePage( i );
740 }
741 }
742
743 m_leftWin->EmptyTreePrj();
745
746 return true;
747}
748
749
750void KICAD_MANAGER_FRAME::OpenJobsFile( const wxFileName& aFileName, bool aCreate,
751 bool aResaveProjectPreferences )
752{
753 for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
754 {
755 if( PANEL_JOBSET* panel = dynamic_cast<PANEL_JOBSET*>( m_notebook->GetPage( i ) ) )
756 {
757 if( aFileName.GetFullPath() == panel->GetFilePath() )
758 {
759 m_notebook->SetSelection( i );
760 return;
761 }
762 }
763 }
764
765 try
766 {
767 std::unique_ptr<JOBSET> jobsFile = std::make_unique<JOBSET>( aFileName.GetFullPath().ToStdString() );
768
769 jobsFile->LoadFromFile();
770
771 if( aCreate && !aFileName.FileExists() )
772 {
773 JOBSET_DESTINATION* dest = jobsFile->AddNewDestination( JOBSET_DESTINATION_T::FOLDER );
774 dest->m_outputHandler->SetOutputPath( aFileName.GetName() );
775 jobsFile->SaveToFile( wxEmptyString, true );
776 }
777
778 PANEL_JOBSET* jobPanel = new PANEL_JOBSET( m_notebook, this, std::move( jobsFile ) );
779 jobPanel->SetProjectTied( true );
780 jobPanel->SetClosable( true );
781 m_notebook->AddPage( jobPanel, aFileName.GetFullName(), true );
783
784 if( aResaveProjectPreferences )
786 }
787 catch( ... )
788 {
789 DisplayErrorMessage( this, _( "Error opening jobs file" ) );
790 }
791}
792
793
794void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
795{
796 // The project file should be valid by the time we get here or something has gone wrong.
797 if( !aProjectFileName.Exists() )
798 return;
799
800 // Any open KIFACE's must be closed if they are not part of the new project.
801 // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
802 // User is prompted here to close those KIWAY_PLAYERs:
803 if( !CloseProject( true ) )
804 return;
805
806 m_active_project = true;
807
808 // NB: when loading a legacy project SETTINGS_MANAGER::LoadProject() will convert it to
809 // current extension. Be very careful with aProjectFileName vs. Prj().GetProjectPath()
810 // from here on out.
811
812 Pgm().GetSettingsManager().LoadProject( aProjectFileName.GetFullPath() );
813 LoadWindowState( aProjectFileName.GetFullName() );
814
815 if( aProjectFileName.IsDirWritable() )
816 SetMruPath( Prj().GetProjectPath() );
817
818 // Save history & window state to disk now. Don't wait around for a crash.
819 KICAD_SETTINGS* settings = kicadSettings();
820 SaveSettings( settings );
821 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
822
823 m_leftWin->ReCreateTreePrj();
824
825 for( const wxString& jobset : Prj().GetLocalSettings().m_OpenJobSets )
826 {
827 wxFileName jobsetFn( jobset );
828 jobsetFn.MakeAbsolute( Prj().GetProjectPath() );
829
830 if( jobsetFn.Exists() )
831 OpenJobsFile( jobsetFn.GetFullPath(), false, false );
832 }
833
834 // Always start with the apps page
835 m_notebook->SetSelection( 0 );
836
837 // Rebuild the list of watched paths.
838 // however this is possible only when the main loop event handler is running,
839 // so we use it to run the rebuild function.
840 wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
841
842 wxPostEvent( this, cmd );
843
844 PrintPrjInfo();
845
846 KIPLATFORM::APP::RegisterApplicationRestart( aProjectFileName.GetFullPath() );
847 m_openSavedWindows = true;
848
849 KIPLATFORM::ENV::AddToRecentDocs( aProjectFileName.GetFullPath() );
850}
851
852
853void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName, bool aCreateStubFiles )
854{
855 wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
856 "Project folder must exist and be writable to create a new project." );
857
858 // If the project is legacy, convert it
859 if( !aProjectFileName.FileExists() )
860 {
861 wxFileName legacyPro( aProjectFileName );
862 legacyPro.SetExt( FILEEXT::LegacyProjectFileExtension );
863
864 if( legacyPro.FileExists() )
865 {
866 GetSettingsManager()->LoadProject( legacyPro.GetFullPath() );
868
869 wxRemoveFile( legacyPro.GetFullPath() );
870 }
871 else
872 {
873 // Copy template project file from template folder.
874 wxString srcFileName = sys_search().FindValidPath( "kicad.kicad_pro" );
875
876 wxFileName destFileName( aProjectFileName );
877 destFileName.SetExt( FILEEXT::ProjectFileExtension );
878
879 // Create a minimal project file if the template project file could not be copied
880 if( !wxFileName::FileExists( srcFileName )
881 || !wxCopyFile( srcFileName, destFileName.GetFullPath() ) )
882 {
883 wxFFile file( destFileName.GetFullPath(), "wb" );
884
885 if( file.IsOpened() )
886 file.Write( wxT( "{\n}\n") );
887
888 // wxFFile dtor will close the file
889 }
890 }
891 }
892
893 // Create a "stub" for a schematic root sheet and a board if requested.
894 // It will avoid messages from the schematic editor or the board editor to create a new file
895 // And forces the user to create main files under the right name for the project manager
896 if( aCreateStubFiles )
897 {
898 wxFileName fn( aProjectFileName.GetFullPath() );
900
901 // If a <project>.kicad_sch file does not exist, create a "stub" file ( minimal schematic
902 // file ).
903 if( !fn.FileExists() )
904 {
905 wxFFile file( fn.GetFullPath(), "wb" );
906
907 if( file.IsOpened() )
908 {
909 file.Write( wxString::Format( "(kicad_sch\n"
910 "\t(version %d)\n"
911 "\t(generator \"eeschema\")\n"
912 "\t(generator_version \"%s\")\n"
913 "\t(uuid %s)\n"
914 "\t(paper \"A4\")\n"
915 "\t(lib_symbols)\n"
916 "\t(sheet_instances\n"
917 "\t\t(path \"/\"\n"
918 "\t\t\t(page \"1\")\n"
919 "\t\t)\n"
920 "\t)\n"
921 "\t(embedded_fonts no)\n"
922 ")",
924 KIID().AsString() ) );
925 }
926
927 // wxFFile dtor will close the file
928 }
929
930 // If a <project>.kicad_pcb or <project>.brd file does not exist,
931 // create a .kicad_pcb "stub" file
933 wxFileName leg_fn( fn );
934 leg_fn.SetExt( FILEEXT::LegacyPcbFileExtension );
935
936 if( !fn.FileExists() && !leg_fn.FileExists() )
937 {
938 wxFFile file( fn.GetFullPath(), "wb" );
939
940 if( file.IsOpened() )
941 {
942 // Create a small dummy file as a stub for pcbnew:
943 file.Write( wxString::Format( "(kicad_pcb (version %d) (generator \"pcbnew\") (generator_version \"%s\")\n)",
945 }
946
947 // wxFFile dtor will close the file
948 }
949 }
950
951 // Save history & window state to disk now. Don't wait around for a crash.
952 KICAD_SETTINGS* settings = kicadSettings();
953 SaveSettings( settings );
954 settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) );
955
956 m_openSavedWindows = true;
957}
958
959
961{
962 // show all files in file dialog (in Kicad all files are editable texts):
963 wxString wildcard = FILEEXT::AllFilesWildcard();
964
965 wxString default_dir = Prj().GetProjectPath();
966
967 wxFileDialog dlg( this, _( "Edit File in Text Editor" ), default_dir, wxEmptyString, wildcard,
968 wxFD_OPEN );
969
970 if( dlg.ShowModal() == wxID_CANCEL )
971 return;
972
973 wxString filename = dlg.GetPath();
974
975 if( !dlg.GetPath().IsEmpty() && !Pgm().GetTextEditor().IsEmpty() )
976 m_toolManager->RunAction<wxString*>( KICAD_MANAGER_ACTIONS::openTextEditor, &filename );
977}
978
979
980void KICAD_MANAGER_FRAME::OnEditAdvancedCfg( wxCommandEvent& WXUNUSED( event ) )
981{
982 DIALOG_EDIT_CFG dlg( this );
983 dlg.ShowModal();
984}
985
986
988{
989 m_leftWin->ReCreateTreePrj();
990}
991
992
993void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
994{
995 int id = event.GetId();
996 Kiway().SetLanguage( id );
997}
998
999
1001{
1002 // call my base class
1004
1005 // tooltips in toolbars
1007 m_launcher->CreateLaunchers();
1008
1009 // update captions
1010 int pageId = m_notebook->FindPage( m_launcher );
1011
1012 if( pageId != wxNOT_FOUND )
1013 m_notebook->SetPageText( pageId, EDITORS_CAPTION );
1014
1015 m_auimgr.GetPane( m_leftWin ).Caption( PROJECT_FILES_CAPTION );
1016 m_auimgr.Update();
1017
1018 m_leftWin->FileWatcherReset();
1019
1020 PrintPrjInfo();
1021}
1022
1023
1025{
1027
1028 if( m_pcm && ( aFlags & ENVVARS_CHANGED ) )
1029 m_pcm->ReadEnvVar();
1030
1031 COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
1032
1033 if( m_lastToolbarIconSize == 0
1035 {
1038 }
1039
1040 m_leftWin->ReCreateTreePrj();
1041}
1042
1043
1045{
1046 wxString file = GetProjectFileName();
1047
1048 // empty file string means no project loaded
1049 if( !Prj().IsNullProject() &&
1050 Prj().GetProjectLock() == nullptr )
1051 {
1052 LOCKFILE lockFile( file );
1053
1054 if( !lockFile.Valid() && lockFile.IsLockedByMe() )
1055 {
1056 // If we cannot acquire the lock but we appear to be the one who
1057 // locked it, check to see if there is another KiCad instance running.
1058 // If there is not, then we can override the lock. This could happen if
1059 // KiCad crashed or was interrupted
1060 if( !Pgm().SingleInstance()->IsAnotherRunning() )
1061 {
1062 lockFile.OverrideLock();
1063 }
1064 }
1065
1066 if( !lockFile.Valid() )
1067 {
1068 wxString msg;
1069 msg.Printf( _( "Project '%s' is already open by '%s' at '%s'." ), file, lockFile.GetUsername(),
1070 lockFile.GetHostname() );
1071
1072 if( AskOverrideLock( this, msg ) )
1073 {
1074 lockFile.OverrideLock();
1075 }
1076 }
1077
1078 Prj().SetReadOnly( !lockFile.Valid() || Prj().GetProjectFile().IsReadOnly() );
1079 Prj().SetProjectLock( new LOCKFILE( std::move( lockFile ) ) );
1080 }
1081
1082 wxString title;
1083
1084 if( !file.IsEmpty() )
1085 {
1086 wxFileName fn( file );
1087
1088 title = fn.GetName();
1089
1090 if( Prj().IsReadOnly() )
1091 title += wxS( " " ) + _( "[Read Only]" );
1092 }
1093 else
1094 {
1095 title = _( "[no project loaded]" );
1096 }
1097
1098 if( ADVANCED_CFG::GetCfg().m_HideVersionFromTitle )
1099 title += wxT( " \u2014 " ) + wxString( wxS( "KiCad" ) );
1100 else
1101 title += wxT( " \u2014 " ) + wxString( wxS( "KiCad " ) ) + GetMajorMinorVersion();
1102
1103 SetTitle( title );
1104}
1105
1106
1108{
1110
1111 auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
1112
1113 wxCHECK( settings, /*void*/ );
1114
1115 m_leftWinWidth = settings->m_LeftWinWidth;
1116}
1117
1118
1120{
1122
1123 auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
1124
1125 wxCHECK( settings, /*void*/);
1126
1127 settings->m_LeftWinWidth = m_leftWin->GetSize().x;
1128
1129 if( !m_isClosing )
1130 settings->m_OpenProjects = GetSettingsManager()->GetOpenProjects();
1131}
1132
1133
1135{
1136 // wxStatusBar's wxELLIPSIZE_MIDDLE flag doesn't work (at least on Mac).
1137
1138 wxString status = wxString::Format( _( "Project: %s" ), Prj().GetProjectFullName() );
1139 KISTATUSBAR* statusBar = static_cast<KISTATUSBAR*>( GetStatusBar() );
1140 statusBar->SetEllipsedTextField( status, 0 );
1141}
1142
1143
1148
1149
1150void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
1151{
1157 if( !m_openSavedWindows )
1158 return;
1159
1160 m_openSavedWindows = false;
1161
1162 if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
1163 {
1164 int previousOpenCount =
1165 std::count_if( Prj().GetLocalSettings().m_files.begin(),
1166 Prj().GetLocalSettings().m_files.end(),
1167 [&]( const PROJECT_FILE_STATE& f )
1168 {
1169 return !f.fileName.EndsWith( FILEEXT::ProjectFileExtension ) && f.open;
1170 } );
1171
1172 if( previousOpenCount > 0 )
1173 {
1174 APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
1175 previousOpenCount, this );
1176
1177 // We don't currently support opening more than one view per file
1178 std::set<wxString> openedFiles;
1179
1180 int i = 0;
1181
1182 for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
1183 {
1184 if( file.open && !openedFiles.count( file.fileName ) )
1185 {
1186 progressReporter.Update( i++, wxString::Format( _( "Restoring '%s'" ), file.fileName ) );
1187
1188 openedFiles.insert( file.fileName );
1189 wxFileName fn( file.fileName );
1190
1191 if( fn.GetExt() == FILEEXT::LegacySchematicFileExtension
1192 || fn.GetExt() == FILEEXT::KiCadSchematicFileExtension )
1193 {
1195 }
1196 else if( fn.GetExt() == FILEEXT::LegacyPcbFileExtension
1197 || fn.GetExt() == FILEEXT::KiCadPcbFileExtension )
1198 {
1200 }
1201 }
1202
1203 wxYield();
1204 }
1205 }
1206 }
1207
1208 // clear file states regardless if we opened windows or not due to setting
1210
1211 KICAD_SETTINGS* settings = kicadSettings();
1212
1213 if( !Pgm().GetCommonSettings()->m_DoNotShowAgain.update_check_prompt )
1214 {
1215 auto prompt = new DIALOG_UPDATE_CHECK_PROMPT( this );
1216 prompt->ShowModal();
1217
1219 }
1220
1222 && settings->m_PcmUpdateCheck )
1223 {
1224 if( !m_pcm )
1225 CreatePCM();
1226
1227 m_pcm->RunBackgroundUpdate();
1228 }
1229
1230#ifdef KICAD_UPDATE_CHECK
1231 if( !m_updateManager && settings->m_KiCadUpdateCheck )
1232 {
1233 m_updateManager = std::make_unique<UPDATE_MANAGER>();
1234 m_updateManager->CheckForUpdate( this );
1235 }
1236#endif
1237
1238 // This little diddy is needed to get the window put into the Mac dock icon's context menu.
1239 Raise();
1240}
1241
1242
1244{
1245 m_pcmButton = aButton;
1246
1248}
1249
1250
1252{
1253 if( m_pcmButton )
1254 {
1255 if( m_pcmUpdateCount > 0 )
1256 {
1257 m_pcmButton->SetShowBadge( true );
1258 m_pcmButton->SetBadgeText( wxString::Format( "%d", m_pcmUpdateCount ) );
1259 }
1260 else
1261 {
1262 m_pcmButton->SetShowBadge( false );
1263 }
1264
1265 m_pcmButton->Refresh();
1266 }
1267}
1268
1269
1271{
1272 // No idea why, but the same mechanism used in EDA_DRAW_FRAME doesn't work here
1273 // the only thing that seems to work is to blow it all up and start from scratch.
1274 m_auimgr.DetachPane( m_tbLeft );
1275 delete m_tbLeft;
1276 m_tbLeft = nullptr;
1278 m_auimgr.AddPane( m_tbLeft, EDA_PANE().HToolbar().Name( "TopMainToolbar" ).Left()
1279 .Layer( 2 ) );
1280
1281 m_auimgr.Update();
1282}
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
DO_NOT_SHOW_AGAIN m_DoNotShowAgain
The base frame for deriving all KiCad main window classes.
void LoadWindowState(const wxString &aFileName)
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
std::vector< wxFileName > m_AcceptedFiles
SETTINGS_MANAGER * GetSettingsManager() const
wxAuiManager m_auimgr
virtual void RecreateToolbars()
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
ACTION_TOOLBAR * m_tbLeft
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
void SetMruPath(const wxString &aPath)
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
Specialization of the wxAuiPaneInfo class for KiCad panels.
void SetOutputPath(const wxString &aPath)
Definition jobs_output.h:53
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 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 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)
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:45
void SetEllipsedTextField(const wxString &aText, int aFieldId)
Set the text in a field using wxELLIPSIZE_MIDDLE option to adjust the text size to the field size.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
virtual void SetLanguage(int aLanguage)
Change the language and then calls ShowChangedLanguage() on all #KIWAY_PLAYERs.
Definition kiway.cpp:515
bool OverrideLock(bool aRemoveOnRelease=true)
Force the lock, overwriting the data that existed already.
Definition lockfile.h:174
bool Valid() const
Definition lockfile.h:254
wxString GetUsername()
Definition lockfile.h:236
wxString GetHostname()
Definition lockfile.h:242
bool IsLockedByMe()
Definition lockfile.h:227
void RegisterStatusBar(KISTATUSBAR *aStatusBar)
Add a status bar for handling.
void CreateOrUpdate(const wxString &aKey, const wxString &aTitle, const wxString &aDescription, const wxString &aHref=wxEmptyString)
Create a notification with the given parameters or updates an existing one with the same key.
void Remove(const wxString &aKey)
Remove a notification by key.
void UnregisterStatusBar(KISTATUSBAR *aStatusBar)
Remove status bar from handling.
static REPORTER & GetInstance()
Definition reporter.cpp:96
void SetClosable(bool aYes)
void SetProjectTied(bool aYes)
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:576
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition pgm_base.h:129
bool m_Quitting
Definition pgm_base.h:357
virtual NOTIFICATIONS_MANAGER & GetNotificationsManager() const
Definition pgm_base.h:134
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:125
wxString GetHelpFileName()
Definition pgm_kicad.h:63
SEARCH_STACK & SysSearch()
Definition pgm_kicad.h:61
APP_SETTINGS_BASE * PgmSettings()
Definition pgm_kicad.h:59
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:481
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:156
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:162
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:194
This file is part of the common library.
#define ENABLE(x)
#define _(s)
Base window classes and related definitions.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define KICAD_MANAGER_FRAME_NAME
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:81
@ 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:913
#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)
std::shared_ptr< JOBS_OUTPUT_HANDLER > m_outputHandler
Definition jobset.h:133
#define ENVVARS_CHANGED
Definition of file extensions used in Kicad.