Kicad: fast switch to an other project sharing the same folder.
If a .pro file is inside the current project, double clicking on this .pro file switches to this project. (It happens when 2 projects share the same folder).
This commit is contained in:
parent
8cb94f09c3
commit
7fa5456d71
|
@ -99,6 +99,7 @@ enum id_kicad_frm {
|
||||||
ID_PROJECT_TREE,
|
ID_PROJECT_TREE,
|
||||||
ID_PROJECT_TXTEDIT,
|
ID_PROJECT_TXTEDIT,
|
||||||
ID_PROJECT_TREE_REFRESH,
|
ID_PROJECT_TREE_REFRESH,
|
||||||
|
ID_PROJECT_SWITCH_TO_OTHER,
|
||||||
ID_PROJECT_NEWDIR,
|
ID_PROJECT_NEWDIR,
|
||||||
ID_PROJECT_DELETE,
|
ID_PROJECT_DELETE,
|
||||||
ID_PROJECT_RENAME,
|
ID_PROJECT_RENAME,
|
||||||
|
|
|
@ -117,6 +117,7 @@ BEGIN_EVENT_TABLE( TREE_PROJECT_FRAME, wxSashLayoutWindow )
|
||||||
EVT_TREE_ITEM_EXPANDED( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnExpand )
|
EVT_TREE_ITEM_EXPANDED( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnExpand )
|
||||||
EVT_TREE_ITEM_RIGHT_CLICK( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnRight )
|
EVT_TREE_ITEM_RIGHT_CLICK( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnRight )
|
||||||
EVT_MENU( ID_PROJECT_TXTEDIT, TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor )
|
EVT_MENU( ID_PROJECT_TXTEDIT, TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor )
|
||||||
|
EVT_MENU( ID_PROJECT_SWITCH_TO_OTHER, TREE_PROJECT_FRAME::OnSwitchToSelectedProject )
|
||||||
EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnCreateNewDirectory )
|
EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnCreateNewDirectory )
|
||||||
EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile )
|
EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile )
|
||||||
EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile )
|
EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile )
|
||||||
|
@ -176,6 +177,19 @@ void TREE_PROJECT_FRAME::RemoveFilter( const wxString& filter )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TREE_PROJECT_FRAME::OnSwitchToSelectedProject( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
TREEPROJECT_ITEM* tree_data = GetSelectedData();
|
||||||
|
|
||||||
|
if( !tree_data )
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxString prj_filename = tree_data->GetFileName();
|
||||||
|
|
||||||
|
m_Parent->LoadProject( prj_filename );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TREE_PROJECT_FRAME::OnCreateNewDirectory( wxCommandEvent& event )
|
void TREE_PROJECT_FRAME::OnCreateNewDirectory( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
// Get the root directory name:
|
// Get the root directory name:
|
||||||
|
@ -678,6 +692,16 @@ void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
|
||||||
switch( tree_id )
|
switch( tree_id )
|
||||||
{
|
{
|
||||||
case TREE_PROJECT:
|
case TREE_PROJECT:
|
||||||
|
// Add a swith to an other project option only if the selected item
|
||||||
|
// is not the root item (current project)
|
||||||
|
if( curr_item != m_TreeProject->GetRootItem() )
|
||||||
|
{
|
||||||
|
AddMenuItem( &popupMenu, ID_PROJECT_SWITCH_TO_OTHER,
|
||||||
|
_( "&Switch to this Project" ),
|
||||||
|
_( "Close all editors, and switch to the selected project" ),
|
||||||
|
KiBitmap( open_project_xpm ) );
|
||||||
|
popupMenu.AppendSeparator();
|
||||||
|
}
|
||||||
AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
|
AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
|
||||||
_( "New D&irectory..." ),
|
_( "New D&irectory..." ),
|
||||||
_( "Create a New Directory" ),
|
_( "Create a New Directory" ),
|
||||||
|
@ -777,12 +801,12 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
|
||||||
|
|
||||||
void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
|
void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
|
||||||
{
|
{
|
||||||
TREEPROJECT_ITEM* tree_data = GetSelectedData();
|
TREEPROJECT_ITEM* selected_item = GetSelectedData();
|
||||||
|
|
||||||
if( !tree_data )
|
if( !selected_item )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tree_data->Activate( this );
|
selected_item->Activate( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,12 @@ private:
|
||||||
*/
|
*/
|
||||||
void OnCreateNewDirectory( wxCommandEvent& event );
|
void OnCreateNewDirectory( wxCommandEvent& event );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch to a other project selected from the tree project
|
||||||
|
* (by selecting an other .pro file inside the current project folder)
|
||||||
|
*/
|
||||||
|
void OnSwitchToSelectedProject( wxCommandEvent& event );
|
||||||
|
|
||||||
void ClearFilters()
|
void ClearFilters()
|
||||||
{
|
{
|
||||||
m_filters.clear();
|
m_filters.clear();
|
||||||
|
|
|
@ -164,18 +164,21 @@ bool TREEPROJECT_ITEM::Delete( bool check )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
|
||||||
{
|
{
|
||||||
wxString sep = wxFileName().GetPathSeparator();
|
wxString sep = wxFileName().GetPathSeparator();
|
||||||
wxString fullFileName = GetFileName();
|
wxString fullFileName = GetFileName();
|
||||||
wxTreeItemId id = GetId();
|
wxTreeItemId id = GetId();
|
||||||
|
|
||||||
KICAD_MANAGER_FRAME* frame = prjframe->m_Parent;
|
KICAD_MANAGER_FRAME* frame = aTreePrjFrame->m_Parent;
|
||||||
wxASSERT( frame );
|
wxASSERT( frame );
|
||||||
|
|
||||||
switch( GetType() )
|
switch( GetType() )
|
||||||
{
|
{
|
||||||
case TREE_PROJECT:
|
case TREE_PROJECT:
|
||||||
|
// Select a new project if this is not the current project:
|
||||||
|
if( id != aTreePrjFrame->m_TreeProject->GetRootItem() )
|
||||||
|
frame->LoadProject( fullFileName );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TREE_DIRECTORY:
|
case TREE_DIRECTORY:
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
|
|
||||||
bool Rename( const wxString& name, bool check = true );
|
bool Rename( const wxString& name, bool check = true );
|
||||||
bool Delete( bool check = true );
|
bool Delete( bool check = true );
|
||||||
void Activate( TREE_PROJECT_FRAME* prjframe );
|
void Activate( TREE_PROJECT_FRAME* aTreePrjFrame );
|
||||||
void SetState( int state );
|
void SetState( int state );
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue