Symlib table: Need button handler for files
The folder button handler works will for footprint libraries but we needed a specific class for the schematic libraries as well. Fixes: lp:1818346 * https://bugs.launchpad.net/kicad/+bug/1818346
This commit is contained in:
parent
db31b7902a
commit
38be0fccb7
|
@ -305,10 +305,12 @@ void GRID_CELL_URL_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
|
||||||
class TEXT_BUTTON_FILE_BROWSER : public wxComboCtrl
|
class TEXT_BUTTON_FILE_BROWSER : public wxComboCtrl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TEXT_BUTTON_FILE_BROWSER( wxWindow* aParent, DIALOG_SHIM* aParentDlg, wxString* aCurrentDir ) :
|
TEXT_BUTTON_FILE_BROWSER( wxWindow* aParent, DIALOG_SHIM* aParentDlg,
|
||||||
|
wxString* aCurrentDir, wxString* aExt = nullptr ) :
|
||||||
wxComboCtrl( aParent ),
|
wxComboCtrl( aParent ),
|
||||||
m_dlg( aParentDlg ),
|
m_dlg( aParentDlg ),
|
||||||
m_currentDir( aCurrentDir )
|
m_currentDir( aCurrentDir ),
|
||||||
|
m_ext( aExt )
|
||||||
{
|
{
|
||||||
SetButtonBitmaps( KiBitmap( folder_xpm ) );
|
SetButtonBitmaps( KiBitmap( folder_xpm ) );
|
||||||
}
|
}
|
||||||
|
@ -328,18 +330,33 @@ protected:
|
||||||
else
|
else
|
||||||
path = ExpandEnvVarSubstitutions( path );
|
path = ExpandEnvVarSubstitutions( path );
|
||||||
|
|
||||||
wxDirDialog dlg( nullptr, _( "Select Path" ), path,
|
if( m_ext )
|
||||||
|
{
|
||||||
|
wxFileDialog dlg( nullptr, _( "Select a File" ), path, wxEmptyString, *m_ext,
|
||||||
|
wxFD_FILE_MUST_EXIST | wxFD_OPEN );
|
||||||
|
|
||||||
|
if( dlg.ShowModal() == wxID_OK )
|
||||||
|
{
|
||||||
|
SetValue( dlg.GetPath() );
|
||||||
|
*m_currentDir = dlg.GetPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxDirDialog dlg( nullptr, _( "Select Path" ), path,
|
||||||
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
|
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_OK )
|
if( dlg.ShowModal() == wxID_OK )
|
||||||
{
|
{
|
||||||
SetValue( dlg.GetPath() );
|
SetValue( dlg.GetPath() );
|
||||||
*m_currentDir = dlg.GetPath();
|
*m_currentDir = dlg.GetPath();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DIALOG_SHIM* m_dlg;
|
DIALOG_SHIM* m_dlg;
|
||||||
wxString* m_currentDir;
|
wxString* m_currentDir;
|
||||||
|
wxString* m_ext;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -352,3 +369,12 @@ void GRID_CELL_PATH_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GRID_CELL_SYMLIB_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
|
||||||
|
wxEvtHandler* aEventHandler )
|
||||||
|
{
|
||||||
|
m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_currentDir, &m_ext );
|
||||||
|
|
||||||
|
wxGridCellEditor::Create(aParent, aId, aEventHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,8 @@ PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent,
|
||||||
wxGridCellAttr* attr;
|
wxGridCellAttr* attr;
|
||||||
|
|
||||||
attr = new wxGridCellAttr;
|
attr = new wxGridCellAttr;
|
||||||
attr->SetEditor( new GRID_CELL_PATH_EDITOR( m_parent, &m_lastBrowseDir ) );
|
attr->SetEditor( new GRID_CELL_SYMLIB_EDITOR( m_parent, &m_lastBrowseDir,
|
||||||
|
SchematicLibraryFileWildcard() ) );
|
||||||
g->SetColAttr( COL_URI, attr );
|
g->SetColAttr( COL_URI, attr );
|
||||||
|
|
||||||
attr = new wxGridCellAttr;
|
attr = new wxGridCellAttr;
|
||||||
|
|
|
@ -141,4 +141,27 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class GRID_CELL_SYMLIB_EDITOR : public GRID_CELL_TEXT_BUTTON
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GRID_CELL_SYMLIB_EDITOR( DIALOG_SHIM* aParent, wxString* aCurrentDir, const wxString& aExt ) :
|
||||||
|
m_dlg( aParent ),
|
||||||
|
m_currentDir( aCurrentDir ),
|
||||||
|
m_ext( aExt )
|
||||||
|
{ }
|
||||||
|
|
||||||
|
wxGridCellEditor* Clone() const override
|
||||||
|
{
|
||||||
|
return new GRID_CELL_SYMLIB_EDITOR( m_dlg, m_currentDir, m_ext );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
DIALOG_SHIM* m_dlg;
|
||||||
|
wxString* m_currentDir;
|
||||||
|
wxString m_ext;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // GRID_TEXT_BUTTON_HELPERS_H
|
#endif // GRID_TEXT_BUTTON_HELPERS_H
|
||||||
|
|
Loading…
Reference in New Issue