KiCad: do not create noname.pro when no project file is defined.

* Disable Eeschema, Component Editor, Pcbnew, and Footprint Editor toolbar
  buttons and menu entries to prevent them from creating project, schematic,
  and/or board files.
This commit is contained in:
Chris Pavlina 2015-08-03 16:56:37 -04:00 committed by Wayne Stambaugh
parent 4739c54f0e
commit 21b0818e58
4 changed files with 36 additions and 14 deletions

View File

@ -109,9 +109,9 @@ enum id_kicad_frm {
ID_TO_SCH,
ID_TO_SCH_LIB_EDITOR,
ID_TO_CVPCB,
ID_TO_PCB,
ID_TO_PCB_FP_EDITOR,
ID_TO_CVPCB,
ID_TO_GERBVIEW,
ID_TO_BITMAP_CONVERTER,
ID_TO_PCB_CALCULATOR,
@ -132,6 +132,7 @@ enum id_kicad_frm {
ID_KICADMANAGER_END_LIST
};
/**
* Class KICAD_MANAGER_FRAME
* is the main KiCad project manager frame. It is not a KIWAY_PLAYER.
@ -219,6 +220,7 @@ public:
void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
void OnUpdateRequiresProject( wxUpdateUIEvent& event );
void CreateNewProject( const wxString& aPrjFullFileName, bool aTemplateSelector );
@ -294,6 +296,8 @@ private:
EDA_HOTKEY_CONFIG* m_manager_Hokeys_Descr;
void language_change( wxCommandEvent& event );
bool m_active_project;
};

View File

@ -50,6 +50,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME )
{
m_active_project = false;
m_leftWinWidth = 60;
m_manager_Hokeys_Descr = NULL;

View File

@ -104,6 +104,8 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
EVT_UPDATE_UI( ID_SELECT_DEFAULT_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdateDefaultPdfBrowser )
EVT_UPDATE_UI( ID_SELECT_PREFERED_PDF_BROWSER,
KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser )
EVT_UPDATE_UI_RANGE( ID_TO_SCH, ID_TO_PCB_FP_EDITOR,
KICAD_MANAGER_FRAME::OnUpdateRequiresProject )
END_EVENT_TABLE()
@ -359,28 +361,23 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
wxMenu* toolsMenu = new wxMenu;
msg = AddHotkeyName( _( "Run Eeschema" ), kicad_Manager_Hokeys_Descr, HK_RUN_EESCHEMA );
AddMenuItem( toolsMenu, ID_TO_SCH, msg,
KiBitmap( eeschema_xpm ) );
AddMenuItem( toolsMenu, ID_TO_SCH, msg, KiBitmap( eeschema_xpm ) );
msg = AddHotkeyName( _( "Run Library Editor" ),
kicad_Manager_Hokeys_Descr, HK_RUN_LIBEDIT );
AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg,
KiBitmap( libedit_xpm ) );
AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg, KiBitmap( libedit_xpm ) );
msg = AddHotkeyName( _( "Run Pcbnew" ),
kicad_Manager_Hokeys_Descr, HK_RUN_PCBNEW );
AddMenuItem( toolsMenu, ID_TO_PCB, msg,
KiBitmap( pcbnew_xpm ) );
AddMenuItem( toolsMenu, ID_TO_PCB, msg, KiBitmap( pcbnew_xpm ) );
msg = AddHotkeyName( _( "Run Footprint Editor" ),
kicad_Manager_Hokeys_Descr, HK_RUN_FPEDITOR );
AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg,
KiBitmap( module_editor_xpm ) );
AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg, KiBitmap( module_editor_xpm ) );
msg = AddHotkeyName( _( "Run Gerbview" ),
kicad_Manager_Hokeys_Descr, HK_RUN_GERBVIEW );
AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg,
KiBitmap( icon_gerbview_small_xpm ) );
AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg, KiBitmap( icon_gerbview_small_xpm ) );
msg = AddHotkeyName( _( "Run Bitmap2Component" ),
kicad_Manager_Hokeys_Descr, HK_RUN_BM2COMPONENT );

View File

@ -198,6 +198,10 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName,
// wxFile dtor will close the file
}
// Enable the toolbar and menubar buttons and clear the help text.
m_active_project = true;
m_MessagesBox->Clear();
}
@ -218,11 +222,12 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
ClearMsg();
bool newProject = ( evt_id == ID_NEW_PROJECT ) ||
( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE );
if( evt_id != wxID_ANY )
{
int style;
bool newProject = ( evt_id == ID_NEW_PROJECT ) ||
( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE );
if( newProject )
{
@ -310,8 +315,17 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
// Either this is the first time kicad has been run or one of the projects in the
// history list is no longer valid. This prevents kicad from automatically creating
// a noname.pro file in the same folder as the kicad binary.
if( wxFileName( prj_filename ).GetFullName().IsSameAs( nameless_prj ) )
if( wxFileName( prj_filename ).GetFullName().IsSameAs( nameless_prj ) && !newProject )
{
m_active_project = false;
m_MessagesBox->SetValue( _( "To proceed, you can use the File menu to start a new project." ) );
return;
}
else
{
m_active_project = true;
m_MessagesBox->Clear();
}
Prj().ConfigLoad( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams );
@ -374,3 +388,9 @@ void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
// GeneralGroupName, s_KicadManagerParams );
Prj().ConfigSave( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams );
}
void KICAD_MANAGER_FRAME::OnUpdateRequiresProject( wxUpdateUIEvent& event )
{
event.Enable( m_active_project );
}