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,
ID_TO_SCH_LIB_EDITOR, ID_TO_SCH_LIB_EDITOR,
ID_TO_CVPCB,
ID_TO_PCB, ID_TO_PCB,
ID_TO_PCB_FP_EDITOR, ID_TO_PCB_FP_EDITOR,
ID_TO_CVPCB,
ID_TO_GERBVIEW, ID_TO_GERBVIEW,
ID_TO_BITMAP_CONVERTER, ID_TO_BITMAP_CONVERTER,
ID_TO_PCB_CALCULATOR, ID_TO_PCB_CALCULATOR,
@ -132,6 +132,7 @@ enum id_kicad_frm {
ID_KICADMANAGER_END_LIST ID_KICADMANAGER_END_LIST
}; };
/** /**
* Class KICAD_MANAGER_FRAME * Class KICAD_MANAGER_FRAME
* is the main KiCad project manager frame. It is not a KIWAY_PLAYER. * is the main KiCad project manager frame. It is not a KIWAY_PLAYER.
@ -219,6 +220,7 @@ public:
void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event ); void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event ); void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
void OnUpdateRequiresProject( wxUpdateUIEvent& event );
void CreateNewProject( const wxString& aPrjFullFileName, bool aTemplateSelector ); void CreateNewProject( const wxString& aPrjFullFileName, bool aTemplateSelector );
@ -294,6 +296,8 @@ private:
EDA_HOTKEY_CONFIG* m_manager_Hokeys_Descr; EDA_HOTKEY_CONFIG* m_manager_Hokeys_Descr;
void language_change( wxCommandEvent& event ); 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, EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME ) KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME )
{ {
m_active_project = false;
m_leftWinWidth = 60; m_leftWinWidth = 60;
m_manager_Hokeys_Descr = NULL; 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_DEFAULT_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdateDefaultPdfBrowser )
EVT_UPDATE_UI( ID_SELECT_PREFERED_PDF_BROWSER, EVT_UPDATE_UI( ID_SELECT_PREFERED_PDF_BROWSER,
KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser ) KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser )
EVT_UPDATE_UI_RANGE( ID_TO_SCH, ID_TO_PCB_FP_EDITOR,
KICAD_MANAGER_FRAME::OnUpdateRequiresProject )
END_EVENT_TABLE() END_EVENT_TABLE()
@ -359,28 +361,23 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
wxMenu* toolsMenu = new wxMenu; wxMenu* toolsMenu = new wxMenu;
msg = AddHotkeyName( _( "Run Eeschema" ), kicad_Manager_Hokeys_Descr, HK_RUN_EESCHEMA ); msg = AddHotkeyName( _( "Run Eeschema" ), kicad_Manager_Hokeys_Descr, HK_RUN_EESCHEMA );
AddMenuItem( toolsMenu, ID_TO_SCH, msg, AddMenuItem( toolsMenu, ID_TO_SCH, msg, KiBitmap( eeschema_xpm ) );
KiBitmap( eeschema_xpm ) );
msg = AddHotkeyName( _( "Run Library Editor" ), msg = AddHotkeyName( _( "Run Library Editor" ),
kicad_Manager_Hokeys_Descr, HK_RUN_LIBEDIT ); kicad_Manager_Hokeys_Descr, HK_RUN_LIBEDIT );
AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg, AddMenuItem( toolsMenu, ID_TO_SCH_LIB_EDITOR, msg, KiBitmap( libedit_xpm ) );
KiBitmap( libedit_xpm ) );
msg = AddHotkeyName( _( "Run Pcbnew" ), msg = AddHotkeyName( _( "Run Pcbnew" ),
kicad_Manager_Hokeys_Descr, HK_RUN_PCBNEW ); kicad_Manager_Hokeys_Descr, HK_RUN_PCBNEW );
AddMenuItem( toolsMenu, ID_TO_PCB, msg, AddMenuItem( toolsMenu, ID_TO_PCB, msg, KiBitmap( pcbnew_xpm ) );
KiBitmap( pcbnew_xpm ) );
msg = AddHotkeyName( _( "Run Footprint Editor" ), msg = AddHotkeyName( _( "Run Footprint Editor" ),
kicad_Manager_Hokeys_Descr, HK_RUN_FPEDITOR ); kicad_Manager_Hokeys_Descr, HK_RUN_FPEDITOR );
AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg, AddMenuItem( toolsMenu, ID_TO_PCB_FP_EDITOR, msg, KiBitmap( module_editor_xpm ) );
KiBitmap( module_editor_xpm ) );
msg = AddHotkeyName( _( "Run Gerbview" ), msg = AddHotkeyName( _( "Run Gerbview" ),
kicad_Manager_Hokeys_Descr, HK_RUN_GERBVIEW ); kicad_Manager_Hokeys_Descr, HK_RUN_GERBVIEW );
AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg, AddMenuItem( toolsMenu, ID_TO_GERBVIEW, msg, KiBitmap( icon_gerbview_small_xpm ) );
KiBitmap( icon_gerbview_small_xpm ) );
msg = AddHotkeyName( _( "Run Bitmap2Component" ), msg = AddHotkeyName( _( "Run Bitmap2Component" ),
kicad_Manager_Hokeys_Descr, HK_RUN_BM2COMPONENT ); 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 // 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(); ClearMsg();
bool newProject = ( evt_id == ID_NEW_PROJECT ) ||
( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE );
if( evt_id != wxID_ANY ) if( evt_id != wxID_ANY )
{ {
int style; int style;
bool newProject = ( evt_id == ID_NEW_PROJECT ) ||
( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE );
if( newProject ) 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 // 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 // history list is no longer valid. This prevents kicad from automatically creating
// a noname.pro file in the same folder as the kicad binary. // 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; return;
}
else
{
m_active_project = true;
m_MessagesBox->Clear();
}
Prj().ConfigLoad( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams ); Prj().ConfigLoad( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams );
@ -374,3 +388,9 @@ void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
// GeneralGroupName, s_KicadManagerParams ); // GeneralGroupName, s_KicadManagerParams );
Prj().ConfigSave( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams ); Prj().ConfigSave( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams );
} }
void KICAD_MANAGER_FRAME::OnUpdateRequiresProject( wxUpdateUIEvent& event )
{
event.Enable( m_active_project );
}