Make image file extension filtering case-insensitive
Replace wxImage::GetImageExtWildcard() with a new FILEEXT::ImageFileWildcard() function that uses KiCad's formatWildcardExt() to generate case-insensitive file patterns on GTK (e.g., [pP][nN][gG] instead of just png). This allows selecting image files with uppercase extensions like .JPG or .PNG in the Place Image dialogs across eeschema, pcbnew, pl_editor, and bitmap2component. Fixes https://gitlab.com/kicad/code/kicad/-/issues/21254
This commit is contained in:
@@ -399,8 +399,7 @@ void BITMAP2CMP_FRAME::OnLoadFile()
|
||||
path = m_mruPath;
|
||||
|
||||
wxFileDialog fileDlg( this, _( "Choose Image" ), path, wxEmptyString,
|
||||
_( "Image Files" ) + wxS( " " )+ wxImage::GetImageExtWildcard(),
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||
FILEEXT::ImageFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||
|
||||
if( fileDlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
@@ -570,6 +570,12 @@ wxString FILEEXT::JpegFileWildcard()
|
||||
}
|
||||
|
||||
|
||||
wxString FILEEXT::ImageFileWildcard()
|
||||
{
|
||||
return _( "Image files" ) + AddFileExtListToFilter( { "png", "jpg", "jpeg", "bmp", "gif" } );
|
||||
}
|
||||
|
||||
|
||||
wxString FILEEXT::HotkeyFileWildcard()
|
||||
{
|
||||
return _( "Hotkey file" ) + AddFileExtListToFilter( { HotkeyFileExtension } );
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
#include <import_gfx/dialog_import_gfx_sch.h>
|
||||
#include <sync_sheet_pin/sheet_synchronization_agent.h>
|
||||
#include <string_utils.h>
|
||||
//#include <wildcards_and_files_ext.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
@@ -1184,7 +1184,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||
m_toolMgr->RunAction( ACTIONS::selectionClear );
|
||||
|
||||
wxFileDialog dlg( m_frame, _( "Choose Image" ), m_mruPath, wxEmptyString,
|
||||
_( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN );
|
||||
FILEEXT::ImageFileWildcard(), wxFD_OPEN );
|
||||
|
||||
bool cancelled = false;
|
||||
|
||||
|
||||
@@ -286,6 +286,7 @@ public:
|
||||
static wxString WorkbookFileWildcard();
|
||||
static wxString PngFileWildcard();
|
||||
static wxString JpegFileWildcard();
|
||||
static wxString ImageFileWildcard();
|
||||
static wxString HotkeyFileWildcard();
|
||||
static wxString JobsetFileWildcard();
|
||||
|
||||
|
||||
@@ -843,8 +843,7 @@ DS_DATA_ITEM* PL_EDITOR_FRAME::AddDrawingSheetItem( int aType )
|
||||
case DS_DATA_ITEM::DS_BITMAP:
|
||||
{
|
||||
wxFileDialog fileDlg( this, _( "Choose Image" ), m_mruImagePath, wxEmptyString,
|
||||
_( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
|
||||
wxFD_OPEN );
|
||||
FILEEXT::ImageFileWildcard(), wxFD_OPEN );
|
||||
|
||||
if( fileDlg.ShowModal() != wxID_OK )
|
||||
return nullptr;
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include <view/view.h>
|
||||
#include <widgets/appearance_controls.h>
|
||||
#include <widgets/wx_infobar.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <wx/filedlg.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
@@ -749,8 +750,7 @@ int DRAWING_TOOL::PlaceReferenceImage( const TOOL_EVENT& aEvent )
|
||||
m_toolMgr->RunAction( ACTIONS::selectionClear );
|
||||
|
||||
wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString,
|
||||
_( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
|
||||
wxFD_OPEN );
|
||||
FILEEXT::ImageFileWildcard(), wxFD_OPEN );
|
||||
bool cancelled = false;
|
||||
|
||||
RunMainStack(
|
||||
|
||||
Reference in New Issue
Block a user