From efe6b04ca21e4b268287d92d81edff588561e339 Mon Sep 17 00:00:00 2001 From: Ashutosh Gangwar Date: Mon, 11 Jun 2018 12:10:00 +0200 Subject: [PATCH] kicad: Open project folder in host OS NEW: Adds support to browse project directory in default file manager in the host OS CHANGED: Main frame's Browse menu now contains third option to Browse Project Files Fixes: lp:1584977 https://bugs.launchpad.net/kicad/+bug/1584977 --- kicad/kicad.h | 2 ++ kicad/mainframe.cpp | 11 +++++++++++ kicad/menubar.cpp | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/kicad/kicad.h b/kicad/kicad.h index eebe582bac..803dcc314d 100644 --- a/kicad/kicad.h +++ b/kicad/kicad.h @@ -117,6 +117,7 @@ enum id_kicad_frm { ID_TO_TEXT_EDITOR, ID_BROWSE_AN_SELECT_FILE, + ID_BROWSE_IN_FILE_EXPLORER, ID_SAVE_AND_ZIP_FILES, ID_READ_ZIP_ARCHIVE, ID_INIT_WATCHED_PATHS, @@ -178,6 +179,7 @@ public: void OnPreferences( wxCommandEvent& aEvent ); void OnOpenTextEditor( wxCommandEvent& event ); void OnOpenFileInTextEditor( wxCommandEvent& event ); + void OnBrowseInFileExplorer( wxCommandEvent& event ); void OnShowHotkeys( wxCommandEvent& event ); void OnFileHistory( wxCommandEvent& event ); diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index ee73254679..ffbe93b61b 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -474,6 +474,17 @@ void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event ) Execute( this, Pgm().GetEditorName(), filename ); } +void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event ) +{ + // open project directory in host OS's file explorer + wxString project_dir = Prj().GetProjectPath(); + + // Quote in case there are spaces in the path. + AddDelimiterString( project_dir ); + + wxLaunchDefaultApplication( project_dir ); +} + void KICAD_MANAGER_FRAME::OnRefresh( wxCommandEvent& event ) { diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index 88fd1641da..ce84340aa2 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -53,6 +53,7 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit ) EVT_MENU( ID_TO_TEXT_EDITOR, KICAD_MANAGER_FRAME::OnOpenTextEditor ) EVT_MENU( ID_BROWSE_AN_SELECT_FILE, KICAD_MANAGER_FRAME::OnOpenFileInTextEditor ) + EVT_MENU( ID_BROWSE_IN_FILE_EXPLORER, KICAD_MANAGER_FRAME::OnBrowseInFileExplorer ) EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, KICAD_MANAGER_FRAME::OnConfigurePaths ) EVT_MENU( ID_EDIT_SYMBOL_LIBRARY_TABLE, KICAD_MANAGER_FRAME::OnEditSymLibTable ) EVT_MENU( ID_EDIT_FOOTPRINT_LIBRARY_TABLE, KICAD_MANAGER_FRAME::OnEditFpLibTable ) @@ -319,6 +320,13 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() _( "Edit local file" ), KiBitmap( browse_files_xpm ) ); + // Browse in file explorer + AddMenuItem( browseMenu, + ID_BROWSE_IN_FILE_EXPLORER, + _( "&Browse Project Files..." ), + _( "Open project directory in file explorer" ), + KiBitmap( open_project_xpm ) ); + // Menu Preferences: wxMenu* preferencesMenu = new wxMenu;