Don't nag the user about file extensions. Just fix it.

Fixes https://gitlab.com/kicad/code/kicad/issues/8067
This commit is contained in:
Jeff Young 2021-03-29 22:10:32 +01:00
parent 7a4f5be37e
commit 2fc34de1be
3 changed files with 19 additions and 14 deletions

View File

@ -249,8 +249,6 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow()
// Ensure filepath is not empty. (In normal use will be caught by grid validators,
// but unedited data from existing files can be bad.)
// @todo What happens when there are invalid file name characters?
if( newRelativeNativeFilename.IsEmpty() )
{
wxMessageBox( _( "A sheet must have a valid file name." ) );
@ -614,16 +612,6 @@ void DIALOG_SHEET_PROPERTIES::OnGridCellChanging( wxGridEvent& event )
wxMessageBox( _( "A sheet must have a file specified." ) );
success = false;
}
else
{
wxFileName fn = textControl->GetValue();
if( fn.GetExt().CmpNoCase( KiCadSchematicFileExtension ) != 0 )
{
wxMessageBox( _( "Sheet filename must have a '.kicad_sch' extension." ) );
success = false;
}
}
}
if( success && control && control->GetValidator() )

View File

@ -471,7 +471,24 @@ void FIELDS_GRID_TABLE<T>::SetValue( int aRow, int aCol, const wxString &aValue
break;
case FDC_VALUE:
field.SetText( aValue );
{
wxString value( aValue );
if( m_parentType == SCH_SHEET_T && aRow == SHEETFILENAME )
{
wxFileName fn( value );
// It's annoying to throw up nag dialogs when the extension isn't right. Just
// fix it.
if( fn.GetExt().CmpNoCase( KiCadSchematicFileExtension ) != 0 )
{
fn.SetExt( KiCadSchematicFileExtension );
value = fn.GetFullPath();
}
}
field.SetText( value );
}
break;
case FDC_SHOWN:

View File

@ -87,7 +87,7 @@ SCH_FIELD_VALIDATOR::SCH_FIELD_VALIDATOR( const SCH_FIELD_VALIDATOR& aValidator
bool SCH_FIELD_VALIDATOR::Validate( wxWindow *aParent )
{
// If window is disabled, simply return
if( !m_validatorWindow->IsEnabled() || !m_validatorWindow->IsShown() )
if( !m_validatorWindow->IsEnabled() )
return true;
wxTextEntry * const text = GetTextEntry();