diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index 3f9eb12f01..1274700f87 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -68,9 +68,17 @@ static wxString formatWildcardExt( const wxString& aWildcard ) #endif } - wxString AddFileExtListToFilter( const std::vector& aExts ) { + if( aExts.size() == 0 ) + { + // The "all files" wildcard is different on different systems + wxString filter; + filter << " (" << wxFileSelectorDefaultWildcardStr << ")|" + << wxFileSelectorDefaultWildcardStr; + return filter; + } + wxString files_filter = " ("; // Add extensions to the info message: @@ -136,7 +144,10 @@ const std::string PngFileExtension( "png" ); const std::string JpegFileExtension( "jpg" ); -const wxString AllFilesWildcard( _( "All files (*)|*" ) ); +wxString AllFilesWildcard() +{ + return _( "All files" ) + AddFileExtListToFilter( {} ); +} wxString SchematicSymbolFileWildcard() diff --git a/eeschema/dialogs/dialog_netlist.cpp b/eeschema/dialogs/dialog_netlist.cpp index ac60b8bdea..416543a21d 100644 --- a/eeschema/dialogs/dialog_netlist.cpp +++ b/eeschema/dialogs/dialog_netlist.cpp @@ -632,7 +632,7 @@ bool NETLIST_DIALOG::FilenamePrms( NETLIST_TYPE_ID aNetTypeId, break; default: // custom, NET_TYPE_CUSTOM1 and greater - fileWildcard = AllFilesWildcard; + fileWildcard = AllFilesWildcard(); ret = false; } diff --git a/eeschema/dialogs/dialog_spice_model.cpp b/eeschema/dialogs/dialog_spice_model.cpp index d9d1f3f080..5a6cd6b20f 100644 --- a/eeschema/dialogs/dialog_spice_model.cpp +++ b/eeschema/dialogs/dialog_spice_model.cpp @@ -764,7 +764,7 @@ void DIALOG_SPICE_MODEL::onSelectLibrary( wxCommandEvent& event ) if( searchPath.IsEmpty() ) searchPath = Prj().GetProjectPath(); - wxString wildcards = SpiceLibraryFileWildcard() + "|" + AllFilesWildcard; + wxString wildcards = SpiceLibraryFileWildcard() + "|" + AllFilesWildcard(); wxFileDialog openDlg( this, _( "Select library" ), searchPath, "", wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); diff --git a/gerbview/files.cpp b/gerbview/files.cpp index e83c334061..752afd7004 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -219,7 +219,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) filetypes += _( "Bottom Pad Master (*.GPB)|*.GPB;*.gpb|" ); // All filetypes - filetypes += AllFilesWildcard; + filetypes += AllFilesWildcard(); // Use the current working directory if the file name path does not exist. if( filename.DirExists() ) @@ -391,7 +391,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) filetypes << wxT( "|" ); /* All filetypes */ - filetypes += wxGetTranslation( AllFilesWildcard ); + filetypes += AllFilesWildcard(); /* Use the current working directory if the file name path does not exist. */ if( filename.DirExists() ) diff --git a/include/wildcards_and_files_ext.h b/include/wildcards_and_files_ext.h index f48588a777..3454084a0f 100644 --- a/include/wildcards_and_files_ext.h +++ b/include/wildcards_and_files_ext.h @@ -62,7 +62,7 @@ * are all match if you pass "txt" into the function). * * @param aExts is the list of exts to add to the filter. Do not include the - * leading dot. + * leading dot. Empty means "allow all files". * * @return the appropriate file dialog wildcard filter list. */ @@ -127,7 +127,7 @@ extern const std::string JpegFileExtension; * @{ */ -extern const wxString AllFilesWildcard; +extern wxString AllFilesWildcard(); extern wxString ComponentFileWildcard(); extern wxString PageLayoutDescrFileWildcard(); diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 709d52b479..4d4ec27f49 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -471,7 +471,7 @@ void KICAD_MANAGER_FRAME::OnOpenTextEditor( wxCommandEvent& event ) void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event ) { // show all files in file dialog (in Kicad all files are editable texts): - wxString wildcard = AllFilesWildcard; + wxString wildcard = AllFilesWildcard(); wxString default_dir = Prj().GetProjectPath(); diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 2942666a94..e338f4df28 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -105,7 +105,7 @@ static wxFileName getFootprintFilenameFromUser( wxWindow* aParent, const wxStrin wildCard << KiCadFootprintLibFileWildcard() << wxChar( '|' ) << ModLegacyExportFileWildcard() << wxChar( '|' ) << GedaPcbFootprintLibFileWildcard() << wxChar( '|' ) - << AllFilesWildcard; + << AllFilesWildcard(); wxFileDialog dlg( aParent, FMT_IMPORT_MODULE, aLastPath, wxEmptyString, wildCard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); diff --git a/qa/common/test_wildcards_and_files_ext.cpp b/qa/common/test_wildcards_and_files_ext.cpp index 78e88c59e3..6efdd53361 100644 --- a/qa/common/test_wildcards_and_files_ext.cpp +++ b/qa/common/test_wildcards_and_files_ext.cpp @@ -86,4 +86,22 @@ BOOST_AUTO_TEST_CASE( BasicFilter ) } } +static constexpr bool should_use_windows_filters() +{ +#ifdef __WXMSW__ + return true; +#else + return false; +#endif +} + +BOOST_AUTO_TEST_CASE( AllFilesFilter ) +{ + const auto resp = AddFileExtListToFilter( {} ); + + const std::string exp_filter = should_use_windows_filters() ? " (*.*)|*.*" : " (*)|*"; + + BOOST_CHECK_EQUAL( resp, exp_filter ); +} + BOOST_AUTO_TEST_SUITE_END()