From a6a9d8eedfe98990ce38eb0d64d55da856e0594c Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 25 Sep 2015 15:38:09 -0400 Subject: [PATCH] Default and most recently used path fixes. (fixes: 1494210) * Rename Eda_FileSelector to EDA_FILE_SELECTOR. * Add optional pointer to wxString to save the most recently used path to EDA_FILE_SELECTOR. * Rename Eda_DirectorySelector to EDA_PATH_SELECTOR. * Replace wxGetCwd() with wxStandardPaths::GetDocumentsDir(). This fixes the windows issue where wxGetCwd() returns the path where the executable files are located. * Add code to handle most recently used path to EDA_BASE_FRAME. * Fix string formatting error in kicad/files-io.cpp. * Remove setting and restoring current working directory when launching GerbView. Setting the CWD has no effect on the launched executable which starts with it's own CWD. * Allow project path to be passed to GerbView when launched from KiCad. * Note: this is a work in progress. Do not expect every path and/or file selection dialog to properly update the most recently used path. The correct solution to this problem requires a much more well though out solution which will not happen until after the next stable release. --- 3d-viewer/3d_canvas.cpp | 6 +- bitmap2component/bitmap2cmp_gui.cpp | 45 ++++++----- common/basicframe.cpp | 7 +- common/eda_doc.cpp | 18 ++--- common/gestfich.cpp | 80 +++++++++++-------- common/hotkeys_basic.cpp | 24 +++--- common/pgm_base.cpp | 6 +- eeschema/dialogs/dialog_bom.cpp | 17 ++-- .../dialogs/dialog_edit_component_in_lib.cpp | 17 ++-- eeschema/dialogs/dialog_eeschema_config.cpp | 6 +- eeschema/dialogs/dialog_netlist.cpp | 16 ++-- eeschema/lib_export.cpp | 4 +- eeschema/libedit_plot_component.cpp | 8 +- eeschema/schframe.cpp | 6 +- gerbview/export_to_pcbnew.cpp | 16 ++-- gerbview/files.cpp | 20 +++-- include/gestfich.h | 72 +++++++++++------ include/wxstruct.h | 6 ++ kicad/files-io.cpp | 16 ++-- kicad/kicad.cpp | 4 +- kicad/mainframe.cpp | 8 +- kicad/prjconfig.cpp | 6 +- kicad/tree_project_frame.cpp | 3 +- .../dialog_edit_module_for_BoardEditor.cpp | 6 +- .../dialog_edit_module_for_Modedit.cpp | 8 +- pcbnew/dialogs/dialog_freeroute_exchange.cpp | 8 +- pcbnew/dialogs/dialog_gendrill.cpp | 6 +- pcbnew/files.cpp | 27 ++++--- pcbnew/librairi.cpp | 8 +- pcbnew/muonde.cpp | 8 +- pcbnew/specctra_export.cpp | 17 ++-- pcbnew/specctra_import.cpp | 17 ++-- 32 files changed, 292 insertions(+), 224 deletions(-) diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index d2de3de163..24d022ac56 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -651,9 +651,9 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event ) mask = wxT( "*." ) + file_ext; fn.SetExt( file_ext ); - FullFileName = EDA_FileSelector( _( "3D Image File Name:" ), fn.GetPath(), - fn.GetFullName(), file_ext, mask, this, - wxFD_SAVE | wxFD_OVERWRITE_PROMPT, true ); + FullFileName = EDA_FILE_SELECTOR( _( "3D Image File Name:" ), fn.GetPath(), + fn.GetFullName(), file_ext, mask, this, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, true ); if( FullFileName.IsEmpty() ) return; diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 0a1a29c16c..2c4bda560f 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2010 jean-pierre.charras - * Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2015 Kicad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,6 +43,7 @@ #include #include + #define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" ) #define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" ) #define KEYWORD_FRAME_SIZEX wxT( "Bmconverter_Size_x" ) @@ -96,7 +97,7 @@ private: void OnExport( wxCommandEvent& event ); /** - * Generate a schematic library which comtains one component: + * Generate a schematic library which contains one component: * the logo */ void OnExportEeschema(); @@ -123,9 +124,9 @@ private: void OnResolutionChange( wxCommandEvent& event ); // called when texts controls which handle the image resolution - // lose the focus, to ensure the rigyht vaules are displayed + // lose the focus, to ensure the right values are displayed // because the m_imageDPI are clipped to acceptable values, and - // the text displayed could be differ duringa text edition + // the text displayed could be differ during text edition // We are using ChangeValue here to avoid generating a wxEVT_TEXT event. void UpdateDPITextValueX( wxMouseEvent& event ) { @@ -249,7 +250,7 @@ void BM2CMP_FRAME::OnPaint( wxPaintEvent& event ) m_BNPicturePanel->PrepareDC( nb_dc ); // OSX crashes with empty bitmaps (on initial refreshes) - if(m_Pict_Bitmap.IsOk() && m_Greyscale_Bitmap.IsOk() && m_BN_Bitmap.IsOk()) + if( m_Pict_Bitmap.IsOk() && m_Greyscale_Bitmap.IsOk() && m_BN_Bitmap.IsOk() ) { pict_dc.DrawBitmap( m_Pict_Bitmap, 0, 0, false ); greyscale_dc.DrawBitmap( m_Greyscale_Bitmap, 0, 0, false ); @@ -258,19 +259,17 @@ void BM2CMP_FRAME::OnPaint( wxPaintEvent& event ) } -/* Called to load a bitmap file - */ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) { wxFileName fn( m_BitmapFileName ); wxString path = fn.GetPath(); - if( path.IsEmpty() || !wxDirExists(path) ) - path = wxGetCwd(); + if( path.IsEmpty() || !wxDirExists( path ) ) + path = m_mruPath; wxFileDialog fileDlg( this, _( "Choose Image" ), path, wxEmptyString, _( "Image Files " ) + wxImage::GetImageExtWildcard(), - wxFD_OPEN ); + wxFD_OPEN | wxFD_FILE_MUST_EXIST ); int diag = fileDlg.ShowModal(); @@ -282,6 +281,8 @@ void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) if( !OpenProjectFiles( std::vector( 1, fullFilename ) ) ) return; + fn = fullFilename; + m_mruPath = fn.GetPath(); m_buttonExport->Enable( true ); SetStatusText( fullFilename ); Refresh(); @@ -349,11 +350,12 @@ bool BM2CMP_FRAME::OpenProjectFiles( const std::vector& aFileSet, int return true; } + void BM2CMP_FRAME::updateImageInfo() { // Note: the image resolution text controls are not modified // here, to avoid a race between text change when entered by user and - // a text change if it is modifed here. + // a text change if it is modified here. int h = m_Pict_Bitmap.GetHeight(); int w = m_Pict_Bitmap.GetWidth(); int nb = m_Pict_Bitmap.GetDepth(); @@ -368,6 +370,7 @@ void BM2CMP_FRAME::updateImageInfo() (double) h / m_imageDPI.y * 25.4 ) ); } + void BM2CMP_FRAME::OnResolutionChange( wxCommandEvent& event ) { long tmp; @@ -387,6 +390,7 @@ void BM2CMP_FRAME::OnResolutionChange( wxCommandEvent& event ) updateImageInfo(); } + void BM2CMP_FRAME::Binarize( double aThreshold ) { unsigned int pixin; @@ -427,10 +431,10 @@ void BM2CMP_FRAME::NegateGreyscaleImage( ) } } -/* Called on Normal/Negative change option */ + void BM2CMP_FRAME::OnOptionsSelection( wxCommandEvent& event ) { - NegateGreyscaleImage( ); + NegateGreyscaleImage(); m_Greyscale_Bitmap = wxBitmap( m_Greyscale_Image ); Binarize( (double)m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() ); Refresh(); @@ -498,7 +502,7 @@ void BM2CMP_FRAME::OnExportLogo() if( outfile == NULL ) { wxString msg; - msg.Printf( _( "File '%s' could not be created" ), GetChars(m_ConvertedFileName) ); + msg.Printf( _( "File '%s' could not be created." ), GetChars( m_ConvertedFileName ) ); wxMessageBox( msg ); return; } @@ -536,7 +540,7 @@ void BM2CMP_FRAME::OnExportPostScript() if( outfile == NULL ) { wxString msg; - msg.Printf( _( "File '%s' could not be created" ), GetChars( m_ConvertedFileName ) ); + msg.Printf( _( "File '%s' could not be created." ), GetChars( m_ConvertedFileName ) ); wxMessageBox( msg ); return; } @@ -554,7 +558,7 @@ void BM2CMP_FRAME::OnExportEeschema() if( path.IsEmpty() || !wxDirExists(path) ) path = ::wxGetCwd(); - wxFileDialog fileDlg( this, _( "Create a lib file for Eeschema" ), + wxFileDialog fileDlg( this, _( "Create a component library file for Eeschema" ), path, wxEmptyString, wxGetTranslation( SchematicLibraryFileWildcard ), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); @@ -573,7 +577,7 @@ void BM2CMP_FRAME::OnExportEeschema() if( outfile == NULL ) { wxString msg; - msg.Printf( _( "File '%s' could not be created" ), GetChars( m_ConvertedFileName ) ); + msg.Printf( _( "File '%s' could not be created." ), GetChars( m_ConvertedFileName ) ); wxMessageBox( msg ); return; } @@ -589,9 +593,9 @@ void BM2CMP_FRAME::OnExportPcbnew() wxString path = fn.GetPath(); if( path.IsEmpty() || !wxDirExists( path ) ) - path = ::wxGetCwd(); + path = m_mruPath; - wxFileDialog fileDlg( this, _( "Create a footprint file for PcbNew" ), + wxFileDialog fileDlg( this, _( "Create a footprint file for Pcbnew" ), path, wxEmptyString, wxGetTranslation( KiCadFootprintLibFileWildcard ), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); @@ -610,13 +614,14 @@ void BM2CMP_FRAME::OnExportPcbnew() if( outfile == NULL ) { wxString msg; - msg.Printf( _( "File '%s' could not be created" ), GetChars( m_ConvertedFileName ) ); + msg.Printf( _( "File '%s' could not be created." ), GetChars( m_ConvertedFileName ) ); wxMessageBox( msg ); return; } ExportFile( outfile, PCBNEW_KICAD_MOD ); fclose( outfile ); + m_mruPath = fn.GetPath(); } diff --git a/common/basicframe.cpp b/common/basicframe.cpp index a9ddf4a311..05af429e5d 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -61,6 +62,8 @@ static const wxChar entryAutoSaveInterval[] = wxT( "AutoSaveInterval" ); /// Configuration file entry for wxAuiManger perspective. static const wxChar entryPerspective[] = wxT( "Perspective" ); +/// Configuration file entry for most recently used path. +static const wxChar entryMruPath[] = wxT( "MostRecentlyUsedPath" ); EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, @@ -76,7 +79,7 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, m_autoSaveState = false; m_autoSaveInterval = -1; m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER ); - + m_mruPath = wxStandardPaths::Get().GetDocumentsDir(); minsize.x = 470; minsize.y = 350; @@ -265,6 +268,7 @@ void EDA_BASE_FRAME::LoadSettings( wxConfigBase* aCfg ) Maximize(); aCfg->Read( baseCfgName + entryPerspective, &m_perspective ); + aCfg->Read( baseCfgName + entryMruPath, &m_mruPath ); } @@ -309,6 +313,7 @@ void EDA_BASE_FRAME::SaveSettings( wxConfigBase* aCfg ) // printf( "perspective(%s): %s\n", // TO_UTF8( m_FrameName + entryPerspective ), TO_UTF8( perspective ) ); aCfg->Write( baseCfgName + entryPerspective, perspective ); + aCfg->Write( baseCfgName + entryMruPath, m_mruPath ); } diff --git a/common/eda_doc.cpp b/common/eda_doc.cpp index 8431d75d4c..d422ab06b2 100644 --- a/common/eda_doc.cpp +++ b/common/eda_doc.cpp @@ -141,15 +141,15 @@ bool GetAssociatedDocument( wxWindow* aParent, if( wxIsWild( fullfilename ) ) { - fullfilename = EDA_FileSelector( _( "Doc Files" ), - wxPathOnly( fullfilename ), - fullfilename, - extension, - mask, - aParent, - wxFD_OPEN, - true, - wxPoint( -1, -1 ) ); + fullfilename = EDA_FILE_SELECTOR( _( "Doc Files" ), + wxPathOnly( fullfilename ), + fullfilename, + extension, + mask, + aParent, + wxFD_OPEN, + true, + wxPoint( -1, -1 ) ); if( fullfilename.IsEmpty() ) return false; } diff --git a/common/gestfich.cpp b/common/gestfich.cpp index bf43091ed7..04f5626af2 100644 --- a/common/gestfich.cpp +++ b/common/gestfich.cpp @@ -58,26 +58,26 @@ void AddDelimiterString( wxString& string ) } -bool EDA_DirectorySelector( const wxString& Title, - wxString& Path, - int flag, - wxWindow* Frame, - const wxPoint& Pos ) +bool EDA_PATH_SELECTOR( const wxString& aTitle, + wxString& aPath, + int aFlags, + wxWindow* aParent, + const wxPoint& aPosition ) { int ii; bool selected = false; - wxDirDialog* DirFrame = new wxDirDialog( Frame, - wxString( Title ), - Path, - flag, - Pos ); + wxDirDialog* DirFrame = new wxDirDialog( aParent, + aTitle, + aPath, + aFlags, + aPosition ); ii = DirFrame->ShowModal(); if( ii == wxID_OK ) { - Path = DirFrame->GetPath(); + aPath = DirFrame->GetPath(); selected = true; } @@ -86,21 +86,22 @@ bool EDA_DirectorySelector( const wxString& Title, } -wxString EDA_FileSelector( const wxString& Title, - const wxString& Path, - const wxString& FileName, - const wxString& Ext, - const wxString& Mask, - wxWindow* Frame, - int flag, - const bool keep_working_directory, - const wxPoint& Pos ) +wxString EDA_FILE_SELECTOR( const wxString& aTitle, + const wxString& aPath, + const wxString& aFileName, + const wxString& aExtension, + const wxString& aWildcard, + wxWindow* aParent, + int aStyle, + const bool aKeepWorkingDirectory, + const wxPoint& aPosition, + wxString* aMruPath ) { wxString fullfilename; wxString curr_cwd = wxGetCwd(); - wxString defaultname = FileName; - wxString defaultpath = Path; - wxString dotted_Ext = wxT(".") + Ext; + wxString defaultname = aFileName; + wxString defaultpath = aPath; + wxString dotted_Ext = wxT(".") + aExtension; #ifdef __WINDOWS__ defaultname.Replace( wxT( "/" ), wxT( "\\" ) ); @@ -108,7 +109,12 @@ wxString EDA_FileSelector( const wxString& Title, #endif if( defaultpath.IsEmpty() ) - defaultpath = wxGetCwd(); + { + if( aMruPath == NULL ) + defaultpath = wxGetCwd(); + else + defaultpath = *aMruPath; + } wxSetWorkingDirectory( defaultpath ); @@ -116,24 +122,30 @@ wxString EDA_FileSelector( const wxString& Title, printf( "defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n", TO_UTF8( defaultpath ), TO_UTF8( defaultname ), - TO_UTF8( Ext ), - TO_UTF8( Mask ), - flag, - keep_working_directory ); + TO_UTF8( aExtension ), + TO_UTF8( aWildcard ), + aStyle, + aKeepWorkingDirectory ); #endif - fullfilename = wxFileSelector( wxString( Title ), + fullfilename = wxFileSelector( aTitle, defaultpath, defaultname, dotted_Ext, - Mask, - flag, // open mode wxFD_OPEN, wxFD_SAVE .. - Frame, - Pos.x, Pos.y ); + aWildcard, + aStyle, // open mode wxFD_OPEN, wxFD_SAVE .. + aParent, + aPosition.x, aPosition.y ); - if( keep_working_directory ) + if( aKeepWorkingDirectory ) wxSetWorkingDirectory( curr_cwd ); + if( !fullfilename.IsEmpty() && aMruPath ) + { + wxFileName fn = fullfilename; + *aMruPath = fn.GetPath(); + } + return fullfilename; } diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 40a4ffef39..04dfd7fbb5 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -749,12 +749,12 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList, #if 0 // pass in the project dir as an argument wxString path = wxPathOnly( Prj().GetProjectFullName() ); #else - wxString path = wxGetCwd(); + wxString path = GetMruPath(); #endif wxFileName fn( aDefaultShortname ); fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); - wxString filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ), + wxString filename = EDA_FILE_SELECTOR( _( "Read Hotkey Configuration File:" ), path, fn.GetFullPath(), ext, @@ -767,6 +767,7 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList, return; ReadHotkeyConfigFile( filename, aDescList ); + SetMruPath( wxFileName( filename ).GetPath() ); } @@ -779,24 +780,25 @@ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( EDA_HOTKEY_CONFIG* aDescList, #if 0 wxString path = wxPathOnly( Prj().GetProjectFullName() ); #else - wxString path = wxGetCwd(); + wxString path = GetMruPath(); #endif wxFileName fn( aDefaultShortname ); fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); - wxString filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ), - path, - fn.GetFullPath(), - ext, - mask, - this, - wxFD_SAVE, - true ); + wxString filename = EDA_FILE_SELECTOR( _( "Write Hotkey Configuration File:" ), + path, + fn.GetFullPath(), + ext, + mask, + this, + wxFD_SAVE, + true ); if( filename.IsEmpty() ) return; WriteHotkeyConfig( aDescList, &filename ); + SetMruPath( wxFileName( filename ).GetPath() ); } diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 36708ccf7b..6322138c31 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -336,9 +336,9 @@ const wxString& PGM_BASE::GetEditorName() #ifdef __WINDOWS__ mask += wxT( ".exe" ); #endif - editorname = EDA_FileSelector( _( "Preferred Editor:" ), wxEmptyString, - wxEmptyString, wxEmptyString, mask, - NULL, wxFD_OPEN, true ); + editorname = EDA_FILE_SELECTOR( _( "Preferred Editor:" ), wxEmptyString, + wxEmptyString, wxEmptyString, mask, + NULL, wxFD_OPEN, true ); } if( !editorname.IsEmpty() ) diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index 490133e80c..11ac1bf5a9 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -483,15 +483,14 @@ wxString DIALOG_BOM::choosePlugin() wxString path = GetOSXKicadDataDir() + wxT( "/plugins" ); #endif - wxString fullFileName = EDA_FileSelector( _( "Plugin files:" ), - path, - wxEmptyString, - wxEmptyString, - mask, - this, - wxFD_OPEN, - true - ); + wxString fullFileName = EDA_FILE_SELECTOR( _( "Plugin files:" ), + path, + wxEmptyString, + wxEmptyString, + mask, + this, + wxFD_OPEN, + true ); if( fullFileName.IsEmpty() ) return wxEmptyString; diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index 63ced982f4..d24d967d8a 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -453,15 +453,14 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e if( !docpath ) docpath = search->LastVisitedPath( wxT( "doc" ) ); - wxString fullFileName = EDA_FileSelector( _( "Doc Files" ), - docpath, - wxEmptyString, - wxEmptyString, - mask, - this, - wxFD_OPEN, - true - ); + wxString fullFileName = EDA_FILE_SELECTOR( _( "Doc Files" ), + docpath, + wxEmptyString, + wxEmptyString, + mask, + this, + wxFD_OPEN, + true ); if( fullFileName.IsEmpty() ) return; diff --git a/eeschema/dialogs/dialog_eeschema_config.cpp b/eeschema/dialogs/dialog_eeschema_config.cpp index 148b035f44..07dab497a0 100644 --- a/eeschema/dialogs/dialog_eeschema_config.cpp +++ b/eeschema/dialogs/dialog_eeschema_config.cpp @@ -387,9 +387,9 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath( wxCommandEvent& event ) wxString abs_path = prj.GetRString( PROJECT::SCH_LIB_PATH ); wxString path; - bool select = EDA_DirectorySelector( _( "Default Path for Libraries" ), - abs_path, wxDD_DEFAULT_STYLE, - this, wxDefaultPosition ); + bool select = EDA_PATH_SELECTOR( _( "Default Path for Libraries" ), + abs_path, wxDD_DEFAULT_STYLE, + this, wxDefaultPosition ); if( !select ) return; diff --git a/eeschema/dialogs/dialog_netlist.cpp b/eeschema/dialogs/dialog_netlist.cpp index 2caac6c154..44dcbdf8cd 100644 --- a/eeschema/dialogs/dialog_netlist.cpp +++ b/eeschema/dialogs/dialog_netlist.cpp @@ -837,14 +837,14 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event ) #else Path = GetOSXKicadDataDir() + wxT( "/plugins" ); #endif - FullFileName = EDA_FileSelector( _( "Plugin files:" ), - Path, - FullFileName, - wxEmptyString, - Mask, - this, - wxFD_OPEN, - true + FullFileName = EDA_FILE_SELECTOR( _( "Plugin files:" ), + Path, + FullFileName, + wxEmptyString, + Mask, + this, + wxFD_OPEN, + true ); if( FullFileName.IsEmpty() ) return; diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp index 022e467591..f80abf517d 100644 --- a/eeschema/lib_export.cpp +++ b/eeschema/lib_export.cpp @@ -49,7 +49,7 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) m_lastDrawItem = NULL; wxFileDialog dlg( this, _( "Import Component" ), m_lastLibImportPath, - wxEmptyString, SchematicLibraryFileWildcard, + m_mruPath, SchematicLibraryFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) @@ -57,6 +57,8 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) wxFileName fn = dlg.GetPath(); + m_mruPath = fn.GetPath(); + std::auto_ptr lib; try diff --git a/eeschema/libedit_plot_component.cpp b/eeschema/libedit_plot_component.cpp index 5399339f33..ccdca67a08 100644 --- a/eeschema/libedit_plot_component.cpp +++ b/eeschema/libedit_plot_component.cpp @@ -71,7 +71,7 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event ) wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() ); - fullFileName = EDA_FileSelector( _( "Filename:" ), pro_dir, + fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir, fn.GetFullName(), file_ext, mask, this, wxFD_SAVE, true ); @@ -94,9 +94,9 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event ) wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() ); - fullFileName = EDA_FileSelector( _( "Filename:" ), pro_dir, - fn.GetFullName(), file_ext, mask, this, - wxFD_SAVE, true ); + fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir, + fn.GetFullName(), file_ext, mask, this, + wxFD_SAVE, true ); if( fullFileName.IsEmpty() ) return; diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 2bc7665f40..3cd6f4e125 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -916,7 +916,7 @@ void SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event ) { // wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() ); - wxString pro_dir = wxGetCwd(); + wxString pro_dir = m_mruPath; wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString, SchematicFileWildcard, @@ -942,6 +942,7 @@ void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event ) wxASSERT_MSG( create_me.IsAbsolute(), wxT( "wxFileDialog returned non-absolute" ) ); OpenProjectFiles( std::vector( 1, create_me.GetFullPath() ), KICTL_CREATE ); + m_mruPath = create_me.GetPath(); } } @@ -949,7 +950,7 @@ void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event ) { // wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() ); - wxString pro_dir = wxGetCwd(); + wxString pro_dir = m_mruPath; wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString, SchematicFileWildcard, @@ -958,6 +959,7 @@ void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event ) if( dlg.ShowModal() != wxID_CANCEL ) { OpenProjectFiles( std::vector( 1, dlg.GetPath() ) ); + m_mruPath = Prj().GetProjectPath(); } } diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index d73a831592..1b4de9f8db 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007-2014 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -44,6 +44,7 @@ #include #include + // Imported function extern const wxString GetPCBDefaultLayerName( LAYER_NUM aLayerNumber ); @@ -174,11 +175,11 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event ) } wxString fileName; - wxString path = wxGetCwd(); + wxString path = m_mruPath; wxFileDialog filedlg( this, _( "Board file name:" ), path, fileName, PcbFileWildcard, - wxFD_SAVE ); + wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( filedlg.ShowModal() == wxID_CANCEL ) return; @@ -195,16 +196,11 @@ void GERBVIEW_FRAME::ExportDataInPcbnewFormat( wxCommandEvent& event ) if( ok != wxID_OK ) return; - if( wxFileExists( fileName ) ) - { - if( !IsOK( this, _( "OK to change the existing file ?" ) ) ) - return; - } + m_mruPath = wxFileName( fileName ).GetPath(); GBR_TO_PCB_EXPORTER gbr_exporter( this, fileName ); - gbr_exporter.ExportPcb( layerdlg->GetLayersLookUpTable(), - layerdlg->GetCopperLayersCount() ); + gbr_exporter.ExportPcb( layerdlg->GetLayersLookUpTable(), layerdlg->GetCopperLayersCount() ); } diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 98f4122d41..2bf2ef1435 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -6,7 +6,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -113,7 +113,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) * the .gbr (.pho in legacy files) extension is the default used in Pcbnew * However there are a lot of other extensions used for gerber files * Because the first letter is usually g, we accept g* as extension - * (Mainly internal copper layers do not have specific extention, + * (Mainly internal copper layers do not have specific extension, * and filenames are like *.g1, *.g2 *.gb1 ...). * Now (2014) Ucamco (the company which manager the Gerber format) encourage * use of .gbr only and the Gerber X2 file format. @@ -144,7 +144,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) if( filename.DirExists() ) currentPath = filename.GetPath(); else - currentPath = wxGetCwd(); + currentPath = m_mruPath; wxFileDialog dlg( this, _( "Open Gerber File" ), @@ -157,13 +157,20 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) return false; dlg.GetPaths( filenamesList ); + + // @todo Take a closer look at the CWD switching here. The current working directory + // gets changed by wxFileDialog because the wxFD_CHANGE_DIR flag is set. Is this the + // appropriate behavior? The current working directory is not returned to the previous + // value so this may be an issue elsewhere. currentPath = wxGetCwd(); + m_mruPath = currentPath; } else { wxFileName filename = aFullFileName; filenamesList.Add( aFullFileName ); currentPath = filename.GetPath(); + m_mruPath = currentPath; } // Read gerber files: each file is loaded on a new GerbView layer @@ -208,6 +215,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) return true; } + bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) { wxString filetypes; @@ -226,7 +234,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) if( filename.DirExists() ) currentPath = filename.GetPath(); else - currentPath = wxGetCwd(); + currentPath = m_mruPath; wxFileDialog dlg( this, _( "Open Drill File" ), @@ -240,12 +248,14 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) dlg.GetPaths( filenamesList ); currentPath = wxGetCwd(); + m_mruPath = currentPath; } else { wxFileName filename = aFullFileName; filenamesList.Add( aFullFileName ); currentPath = filename.GetPath(); + m_mruPath = currentPath; } // Read gerber files: each file is loaded on a new GerbView layer @@ -264,7 +274,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) if( Read_EXCELLON_File( filename.GetFullPath() ) ) { - // Update the list of recentdrill files. + // Update the list of recent drill files. UpdateFileHistory( filename.GetFullPath(), &m_drillFileHistory ); layer = getNextAvailableLayer( layer ); diff --git a/include/gestfich.h b/include/gestfich.h index e0aa0e45d0..e8699b719d 100644 --- a/include/gestfich.h +++ b/include/gestfich.h @@ -57,32 +57,56 @@ bool OpenPDF( const wxString& file ); void OpenFile( const wxString& file ); -bool EDA_DirectorySelector( const wxString& Title, - wxString& Path, - int flag, /* reserve */ - wxWindow* Frame, - const wxPoint& Pos ); - -/* Selection file dialog box: - * Dialog title - * Default path - * default filename - * default filename extension - * filter for filename list - * parent frame - * wxFD_SAVE, wxFD_OPEN .. - * true = keep the current path +/** + * Function EDA_PATH_SELECTOR + * + * is a helper function that wraps wxDirDialog. + * + * @param aTitle is a string to display in the dialog title bar. + * @param aPath is a string contain the default path for the path dialog. This string also + * contains the result of the wxDirDialog when the OK button is used to dismiss + * the dialog. + * @param aFlags is the style of the path dialog, wxDD_???. + * @param aParaent is the parent window of the dialog. + * @param aPosition is the position of the dialog. + * @return true if a path was selected. */ -wxString EDA_FileSelector( const wxString& Title, - const wxString& Path, - const wxString& FileName, - const wxString& Ext, - const wxString& Mask, - wxWindow* Frame, - int flag, - const bool keep_working_directory, - const wxPoint& Pos = wxPoint( -1, -1 ) ); +bool EDA_PATH_SELECTOR( const wxString& aTitle, + wxString& aPath, + int aFlags, /* reserve */ + wxWindow* aParent, + const wxPoint& aPosition = wxDefaultPosition ); +/** + * Function EDA_FILE_SELECTOR + * + * is a helper function that wraps a call to wxFileSelector. + * + * @param aTitle is a string to display in the dialog title bar. + * @param aPath is a string contain the default path for the path dialog. + * @param aFileName is a string containing the default file name. + * @param aExtension is a string containing the default file extension. + * @param aWildcard is a string containing the default wildcard. + * @param aParaent is the parent window of the dialog. + * @param aFlags is the style of the path dialog, wxFD_???. + * @param aKeepWorkingDirectory determines if current working directory should be set to the + * user selected path. + * @param aPosition is the position of the dialog. + * @param aMruPath is a pointer to a string to copy the path selected by the user when + * the OK button is pressed to dismiss the dialog. This can be NULL. + * @return the full path and file name of the selected file or wxEmptyString if the user + * pressed the cancel button to dismiss the dialog. + */ +wxString EDA_FILE_SELECTOR( const wxString& aTitle, + const wxString& aPath, + const wxString& aFileName, + const wxString& aExtension, + const wxString& aWildcard, + wxWindow* aParent, + int aStyle, + const bool aKeepWorkingDirectory, + const wxPoint& aPosition = wxDefaultPosition, + wxString* aMruPath = NULL ); EDA_LIST_DIALOG* GetFileNames( char* Directory, char* Mask ); diff --git a/include/wxstruct.h b/include/wxstruct.h index 184218a5d9..ab5ff7c3e3 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -152,6 +152,8 @@ protected: wxString m_perspective; ///< wxAuiManager perspective. + wxString m_mruPath; ///< Most recently used path. + /** * Function onAutoSaveTimer * handles the auto save timer event. @@ -362,6 +364,10 @@ public: */ void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL ); + void SetMruPath( const wxString& aPath ) { m_mruPath = aPath; } + + wxString GetMruPath() const { return m_mruPath; } + /** * Function ReCreateMenuBar * Creates recreates the menu bar. diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp index 11e83205a3..42c8b05abc 100644 --- a/kicad/files-io.cpp +++ b/kicad/files-io.cpp @@ -176,7 +176,7 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) // Prepare the zip file wxString zipfilename = zip.GetFullPath(); - wxFFileOutputStream ostream(zipfilename); + wxFFileOutputStream ostream( zipfilename ); wxZipOutputStream zipstream( ostream ); // Build list of filenames to put in zip archive @@ -199,11 +199,11 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) curr_fn.MakeRelativeTo( currdirname ); currFilename = curr_fn.GetFullPath(); - msg.Printf(_( "Archive file <%s>" ), GetChars( currFilename ) ); + msg.Printf( _( "Archive file <%s>" ), GetChars( currFilename ) ); PrintMsg( msg ); // Read input file and add it to the zip file: - wxFSFile* infile = fsfile.OpenFile(currFilename); + wxFSFile* infile = fsfile.OpenFile( currFilename ); if( infile ) { @@ -213,20 +213,20 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) int zippedsize = zipstream.GetSize() - zipBytesCnt; zipBytesCnt = zipstream.GetSize(); PrintMsg( wxT(" ") ); - msg.Printf( _( "(%d bytes, compressed %d bytes)\n"), - infile->GetStream()->GetSize(), zippedsize ); + msg.Printf( _( "(%lu bytes, compressed %d bytes)\n" ), + (unsigned long)infile->GetStream()->GetSize(), zippedsize ); PrintMsg( msg ); delete infile; } else - PrintMsg( _(" >>Error\n") ); + PrintMsg( _( " >>Error\n" ) ); } zipBytesCnt = ostream.GetSize(); if( zipstream.Close() ) { - msg.Printf( _("\nZip archive <%s> created (%d bytes)" ), + msg.Printf( _( "\nZip archive <%s> created (%d bytes)" ), GetChars( zipfilename ), zipBytesCnt ); PrintMsg( msg ); PrintMsg( wxT( "\n** end **\n" ) ); @@ -234,7 +234,7 @@ void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) else { msg.Printf( wxT( "Unable to create archive <%s>, abort\n" ), - GetChars( zipfilename ) ); + GetChars( zipfilename ) ); PrintMsg( msg ); } diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 21f103983e..5bd4e3ab92 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -162,7 +162,7 @@ bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) { GetFileHistory().RemoveFileFromHistory( 0 ); - wxFileName namelessProject( wxGetCwd(), NAMELESS_PROJECT, + wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, ProjectFileExtension ); frame->SetProjectFileName( namelessProject.GetFullPath() ); @@ -181,7 +181,7 @@ bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) } else // there is no history { - wxFileName namelessProject( wxGetCwd(), NAMELESS_PROJECT, + wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, ProjectFileExtension ); frame->SetProjectFileName( namelessProject.GetFullPath() ); diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index e4da9a453c..1c427473cc 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -42,6 +42,8 @@ #include #include +#include + #define TREE_FRAME_WIDTH_ENTRY wxT( "LeftWinWidth" ) @@ -410,16 +412,12 @@ void KICAD_MANAGER_FRAME::OnRunPageLayoutEditor( wxCommandEvent& event ) -#include void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event ) { // Gerbview is called without any file to open, because we do not know // the list and the name of files to open (if any...). // however we run it in the path of the project - wxString cwd = wxGetCwd(); - wxSetWorkingDirectory( Prj().GetProjectPath() ); - Execute( this, GERBVIEW_EXE, wxEmptyString ); - wxSetWorkingDirectory( cwd ); + Execute( this, GERBVIEW_EXE, Prj().GetProjectPath() ); } diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index 5d0267fef9..c8ed495991 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -240,9 +240,9 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) style = wxFD_OPEN | wxFD_FILE_MUST_EXIST; } - wxString default_dir = wxGetCwd(); + wxString default_dir = GetMruPath(); wxFileDialog dlg( this, title, default_dir, wxEmptyString, - ProjectFileWildcard, style ); + ProjectFileWildcard, style ); if( dlg.ShowModal() == wxID_CANCEL ) return; @@ -333,6 +333,8 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) if( !wxFileName( prj_filename ).IsDirWritable() ) title += _( " [Read Only]" ); + else + SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. SetTitle( title ); diff --git a/kicad/tree_project_frame.cpp b/kicad/tree_project_frame.cpp index f1a10514a6..70aa25663a 100644 --- a/kicad/tree_project_frame.cpp +++ b/kicad/tree_project_frame.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -595,7 +596,7 @@ void TREE_PROJECT_FRAME::ReCreateTreePrj() if( !fn.IsOk() ) { fn.Clear(); - fn.SetPath( ::wxGetCwd() ); + fn.SetPath( wxStandardPaths::Get().GetDocumentsDir() ); fn.SetName( NAMELESS_PROJECT ); fn.SetExt( ProjectFileExtension ); } diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 90dd783445..e5fad8ccbd 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -479,9 +479,9 @@ void DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile() fileFilters += wxChar( '|' ); fileFilters += wxGetTranslation( IDF3DFileWildcard ); - wxString filename = EDA_FileSelector( _( "3D Shape:" ), initialpath, - wxEmptyString, wxEmptyString, - fileFilters, this, wxFD_OPEN, true ); + wxString filename = EDA_FILE_SELECTOR( _( "3D Shape:" ), initialpath, + wxEmptyString, wxEmptyString, + fileFilters, this, wxFD_OPEN, true ); if( filename.IsEmpty() ) return; diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index cddef8afbb..a2f4acb12f 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -349,10 +349,10 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile() fileFilters += wxChar( '|' ); fileFilters += wxGetTranslation( IDF3DFileWildcard ); - wxString filename = EDA_FileSelector( _( "3D Shape:" ), initialpath, - wxEmptyString, wxEmptyString, - wxGetTranslation( fileFilters ), - this, wxFD_OPEN, true ); + wxString filename = EDA_FILE_SELECTOR( _( "3D Shape:" ), initialpath, + wxEmptyString, wxEmptyString, + wxGetTranslation( fileFilters ), + this, wxFD_OPEN, true ); if( filename.IsEmpty() ) return; diff --git a/pcbnew/dialogs/dialog_freeroute_exchange.cpp b/pcbnew/dialogs/dialog_freeroute_exchange.cpp index 9740f37a32..f84bd7e29c 100644 --- a/pcbnew/dialogs/dialog_freeroute_exchange.cpp +++ b/pcbnew/dialogs/dialog_freeroute_exchange.cpp @@ -191,10 +191,10 @@ const wxString DIALOG_FREEROUTE::createDSN_File() fn.SetExt( dsn_ext ); wxString mask = wxT( "*." ) + dsn_ext; - wxString fullFileName = EDA_FileSelector( _( "Specctra DSN file:" ), - fn.GetPath(), fn.GetFullName(), - dsn_ext, mask, - this, wxFD_SAVE, false ); + wxString fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN file:" ), + fn.GetPath(), fn.GetFullName(), + dsn_ext, mask, + this, wxFD_SAVE, false ); if( !fullFileName.IsEmpty() ) { diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp index cdd3f74f1d..c3a7d2d771 100644 --- a/pcbnew/dialogs/dialog_gendrill.cpp +++ b/pcbnew/dialogs/dialog_gendrill.cpp @@ -6,7 +6,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2012 Jean_Pierre Charras - * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -42,6 +42,8 @@ #include #include +#include + // Keywords for read and write config #define ZerosFormatKey wxT( "DrillZerosFormat" ) @@ -391,7 +393,7 @@ void DIALOG_GENDRILL::OnGenReportFile( wxCommandEvent& event ) wxString defaultPath = m_plotOpts.GetOutputDirectory(); if( defaultPath.IsEmpty() ) - defaultPath = ::wxGetCwd(); + defaultPath = wxStandardPaths::Get().GetDocumentsDir(); wxFileDialog dlg( this, _( "Save Drill Report File" ), defaultPath, fn.GetFullName(), wxGetTranslation( ReportFileWildcard ), diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index b9c7dbba33..582ffd28ec 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2011 Wayne Stambaugh + * Copyright (C) 2011-2015 Wayne Stambaugh * Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or @@ -52,6 +52,8 @@ #include #include +#include + //#define USE_INSTRUMENTATION true #define USE_INSTRUMENTATION false @@ -114,7 +116,7 @@ bool AskLoadBoardFileName( wxWindow* aParent, int* aCtl, wxString* aFileName, bo } else { - path = wxGetCwd(); + path = wxStandardPaths::Get().GetDocumentsDir(); // leave name empty } @@ -309,21 +311,22 @@ void PCB_EDIT_FRAME::Files_io_from_id( int id ) break; case ID_NEW_BOARD: - { - if( !Clear_Pcb( true ) ) - break; + { + if( !Clear_Pcb( true ) ) + break; - wxFileName fn( wxGetCwd(), wxT( "noname" ), ProjectFileExtension ); + wxFileName fn( wxStandardPaths::Get().GetDocumentsDir(), wxT( "noname" ), + ProjectFileExtension ); - Prj().SetProjectFullName( fn.GetFullPath() ); + Prj().SetProjectFullName( fn.GetFullPath() ); - fn.SetExt( PcbFileExtension ); + fn.SetExt( PcbFileExtension ); - GetBoard()->SetFileName( fn.GetFullPath() ); - UpdateTitle(); - ReCreateLayerBox(); - } + GetBoard()->SetFileName( fn.GetFullPath() ); + UpdateTitle(); + ReCreateLayerBox(); break; + } case ID_SAVE_BOARD: if( ! GetBoard()->GetFileName().IsEmpty() ) diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index fe6963a717..6f7ed87d5d 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -27,8 +27,10 @@ * @brief Manage module (footprint) libraries. */ -#include #include +#include + +#include #include #include #include @@ -105,7 +107,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module() // Some day it might be useful save the last library type selected along with the path. static int lastFilterIndex = 0; - wxString lastOpenedPathForLoading; + wxString lastOpenedPathForLoading = m_mruPath; wxConfigBase* config = Kiface().KifaceSettings(); if( config ) @@ -308,7 +310,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule ) if( config ) { wxString path; - config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path ); + config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path, m_mruPath ); fn.SetPath( path ); } diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 2c100c1ad7..11ba66880f 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -844,10 +844,10 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event ) static wxString lastpath; // To remember the last open path during a session wxString mask = wxT( "*.*" ); - wxString FullFileName = EDA_FileSelector( _( "Read descr shape file" ), - lastpath, FullFileName, - wxEmptyString, mask, - this, wxFD_OPEN, true ); + wxString FullFileName = EDA_FILE_SELECTOR( _( "Read descr shape file" ), + lastpath, FullFileName, + wxEmptyString, mask, + this, wxFD_OPEN, true ); if( FullFileName.IsEmpty() ) return; diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 76bbc2b4eb..e0e0ca6fa9 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -137,15 +137,14 @@ void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event ) name += dsn_ext; - fullFileName = EDA_FileSelector( _( "Specctra DSN file:" ), - path, - name, // name.ext without path! - dsn_ext, - mask, - this, - wxFD_SAVE, - false - ); + fullFileName = EDA_FILE_SELECTOR( _( "Specctra DSN file:" ), + path, + name, // name.ext without path! + dsn_ext, + mask, + this, + wxFD_SAVE, + false ); if( fullFileName == wxEmptyString ) return; diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index 65e16006b5..b8e2d86090 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -81,15 +81,14 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) wxFileName::SplitPath( fullFileName, &path, &name, &ext ); name += sessionExt; - fullFileName = EDA_FileSelector( _( "Merge Specctra Session file:" ), - path, - name, - sessionExt, - mask, - this, - wxFD_OPEN, - false - ); + fullFileName = EDA_FILE_SELECTOR( _( "Merge Specctra Session file:" ), + path, + name, + sessionExt, + mask, + this, + wxFD_OPEN, + false ); if( fullFileName == wxEmptyString ) return;