mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
Make more use of shared dialogs.
This commit is contained in:
parent
892f9031d7
commit
cf5c00bcf2
@ -68,6 +68,8 @@ void PANEL_IMAGE_EDITOR::OnGreyScaleConvert( wxCommandEvent& event )
|
|||||||
*/
|
*/
|
||||||
bool PANEL_IMAGE_EDITOR::CheckValues()
|
bool PANEL_IMAGE_EDITOR::CheckValues()
|
||||||
{
|
{
|
||||||
|
wxWindow* host = wxGetTopLevelParent( this );
|
||||||
|
|
||||||
#define MIN_SIZE 15 // Min size in pixels after scaling (50 mils)
|
#define MIN_SIZE 15 // Min size in pixels after scaling (50 mils)
|
||||||
#define MAX_SIZE 6000 // Max size in pixels after scaling (20 inches)
|
#define MAX_SIZE 6000 // Max size in pixels after scaling (20 inches)
|
||||||
double tmp;
|
double tmp;
|
||||||
@ -76,7 +78,7 @@ bool PANEL_IMAGE_EDITOR::CheckValues()
|
|||||||
// Test number correctness
|
// Test number correctness
|
||||||
if( !msg.ToDouble( &tmp ) || tmp < 0.0 )
|
if( !msg.ToDouble( &tmp ) || tmp < 0.0 )
|
||||||
{
|
{
|
||||||
wxMessageBox( _( "Incorrect scale number" ) );
|
DisplayErrorMessage( host, _( "Scale must be a positive number." ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,10 +88,10 @@ bool PANEL_IMAGE_EDITOR::CheckValues()
|
|||||||
|
|
||||||
if( size_min < MIN_SIZE ) // if the size is too small, the image will be hard to locate
|
if( size_min < MIN_SIZE ) // if the size is too small, the image will be hard to locate
|
||||||
{
|
{
|
||||||
wxMessageDialog( wxGetTopLevelParent( this ),
|
DisplayErrorMessage( host, wxString::Format( _( "This scale results in an image which is too small "
|
||||||
wxString::Format( _( "This scale results in an image which is too "
|
"(%.2f mm or %.1f mil)." ),
|
||||||
"small (%.2f mm or %.1f mil)." ),
|
25.4 / 300 * size_min,
|
||||||
25.4 / 300 * size_min, 1000.0 / 300.0 * size_min ) );
|
1000.0 / 300.0 * size_min ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +100,10 @@ bool PANEL_IMAGE_EDITOR::CheckValues()
|
|||||||
if( size_max > MAX_SIZE )
|
if( size_max > MAX_SIZE )
|
||||||
{
|
{
|
||||||
// the actual size is 25.4/300 * size_max in mm
|
// the actual size is 25.4/300 * size_max in mm
|
||||||
if( !IsOK( wxGetTopLevelParent( this ),
|
if( !IsOK( host, wxString::Format( _( "This scale results in an image which is very large "
|
||||||
wxString::Format( _( "This scale results in an image which is very large "
|
"(%.1f mm or %.2f in). Are you sure?" ),
|
||||||
"(%.1f mm or %.2f in). Are you sure?" ),
|
25.4 / 300 * size_max,
|
||||||
25.4 / 300 * size_max, size_max / 300.0 ) ) )
|
size_max / 300.0 ) ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1314,19 +1314,13 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnOutputFileBrowseClicked( wxCommandEvent& even
|
|||||||
|
|
||||||
wxFileName file = wxFileName( saveDlg.GetPath() );
|
wxFileName file = wxFileName( saveDlg.GetPath() );
|
||||||
wxString defaultPath = fn.GetPathWithSep();
|
wxString defaultPath = fn.GetPathWithSep();
|
||||||
wxString msg;
|
|
||||||
msg.Printf( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath );
|
|
||||||
|
|
||||||
wxMessageDialog dialog( this, msg, _( "BOM Output File" ),
|
if( IsOK( this, wxString::Format( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
|
||||||
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
||||||
|
|
||||||
if( dialog.ShowModal() == wxID_YES )
|
|
||||||
{
|
{
|
||||||
if( !file.MakeRelativeTo( defaultPath ) )
|
if( !file.MakeRelativeTo( defaultPath ) )
|
||||||
{
|
{
|
||||||
wxMessageBox( _( "Cannot make path relative (target volume different from schematic "
|
DisplayErrorMessage( this, _( "Cannot make path relative (target volume different from schematic "
|
||||||
"file volume)!" ),
|
"file volume)!" ) );
|
||||||
_( "BOM Output File" ), wxOK | wxICON_ERROR );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,19 +77,6 @@ void IMPORT_PROJ_HELPER::FindEmptyTargetDir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IMPORT_PROJ_HELPER::OutputCopyError( const wxFileName& aSrc, const wxFileName& aFileCopy )
|
|
||||||
{
|
|
||||||
wxString msg;
|
|
||||||
msg.Printf( _( "Cannot copy file '%s'\n"
|
|
||||||
"to '%s'\n"
|
|
||||||
"The project cannot be imported." ),
|
|
||||||
aSrc.GetFullPath(), aFileCopy.GetFullPath() );
|
|
||||||
|
|
||||||
wxMessageDialog fileCopyErrorDlg( m_frame, msg, _( "Error" ), wxOK_DEFAULT | wxICON_ERROR );
|
|
||||||
fileCopyErrorDlg.ShowModal();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SCOPED_FILE_REMOVER
|
class SCOPED_FILE_REMOVER
|
||||||
{
|
{
|
||||||
wxString m_file;
|
wxString m_file;
|
||||||
|
@ -68,7 +68,6 @@ private:
|
|||||||
std::vector<wxString> m_schExtenstions;
|
std::vector<wxString> m_schExtenstions;
|
||||||
std::vector<wxString> m_pcbExtenstions;
|
std::vector<wxString> m_pcbExtenstions;
|
||||||
|
|
||||||
void OutputCopyError( const wxFileName& aSrc, const wxFileName& aFileCopy );
|
|
||||||
void ImportIndividualFile( KICAD_T aKicad_T, int aImportedFileType );
|
void ImportIndividualFile( KICAD_T aKicad_T, int aImportedFileType );
|
||||||
|
|
||||||
void doImport( const wxString& aFile, FRAME_T aFrameType, int aImportedFileType );
|
void doImport( const wxString& aFile, FRAME_T aFrameType, int aImportedFileType );
|
||||||
|
@ -324,15 +324,11 @@ bool PGM_KICAD::OnPgmInit()
|
|||||||
{
|
{
|
||||||
wxFileName tmp = parser.GetParam( 0 );
|
wxFileName tmp = parser.GetParam( 0 );
|
||||||
|
|
||||||
if( tmp.GetExt() != FILEEXT::ProjectFileExtension
|
if( tmp.GetExt() != FILEEXT::ProjectFileExtension && tmp.GetExt() != FILEEXT::LegacyProjectFileExtension )
|
||||||
&& tmp.GetExt() != FILEEXT::LegacyProjectFileExtension )
|
|
||||||
{
|
{
|
||||||
wxString msg;
|
DisplayErrorMessage( nullptr, wxString::Format( _( "File '%s'\n"
|
||||||
|
"does not appear to be a KiCad project file." ),
|
||||||
msg.Printf( _( "File '%s'\ndoes not appear to be a valid KiCad project file." ),
|
tmp.GetFullPath() ) );
|
||||||
tmp.GetFullPath() );
|
|
||||||
wxMessageDialog dlg( nullptr, msg, _( "Error" ), wxOK | wxICON_EXCLAMATION );
|
|
||||||
dlg.ShowModal();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -314,27 +314,18 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent )
|
|||||||
fn.AppendDir( fn.GetName() );
|
fn.AppendDir( fn.GetName() );
|
||||||
|
|
||||||
// Check if the project directory is empty if it already exists.
|
// Check if the project directory is empty if it already exists.
|
||||||
|
if( !fn.DirExists() && !fn.Mkdir() )
|
||||||
if( !fn.DirExists() )
|
|
||||||
{
|
{
|
||||||
if( !fn.Mkdir() )
|
DisplayErrorMessage( m_frame, wxString::Format( _( "Folder '%s' could not be created.\n\n"
|
||||||
{
|
"Make sure you have write permissions and try again." ),
|
||||||
wxString msg;
|
fn.GetPath() ) );
|
||||||
msg.Printf( _( "Folder '%s' could not be created.\n\n"
|
return -1;
|
||||||
"Make sure you have write permissions and try again." ),
|
|
||||||
fn.GetPath() );
|
|
||||||
DisplayErrorMessage( m_frame, msg );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !fn.IsDirWritable() )
|
if( !fn.IsDirWritable() )
|
||||||
{
|
{
|
||||||
wxString msg;
|
DisplayErrorMessage( m_frame, wxString::Format( _( "Insufficient permissions to write to folder '%s'." ),
|
||||||
|
fn.GetPath() ) );
|
||||||
msg.Printf( _( "Insufficient permissions to write to folder '%s'." ), fn.GetPath() );
|
|
||||||
wxMessageDialog msgDlg( m_frame, msg, _( "Error" ), wxICON_ERROR | wxOK | wxCENTER );
|
|
||||||
msgDlg.ShowModal();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,13 +366,7 @@ int KICAD_MANAGER_CONTROL::NewFromTemplate( const TOOL_EVENT& aEvent )
|
|||||||
// create a project
|
// create a project
|
||||||
if( !ps.GetSelectedTemplate()->CreateProject( fn, &errorMsg ) )
|
if( !ps.GetSelectedTemplate()->CreateProject( fn, &errorMsg ) )
|
||||||
{
|
{
|
||||||
wxMessageDialog createDlg( m_frame, _( "A problem occurred creating new project from template." ),
|
DisplayErrorMessage( m_frame, _( "A problem occurred creating new project from template." ), errorMsg );
|
||||||
_( "Error" ), wxOK | wxICON_ERROR );
|
|
||||||
|
|
||||||
if( !errorMsg.empty() )
|
|
||||||
createDlg.SetExtendedMessage( errorMsg );
|
|
||||||
|
|
||||||
createDlg.ShowModal();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,19 +742,16 @@ int KICAD_MANAGER_CONTROL::SaveProjectAs( const TOOL_EVENT& aEvent )
|
|||||||
|
|
||||||
if( !wxMkdir( newProjectDir.GetFullPath() ) )
|
if( !wxMkdir( newProjectDir.GetFullPath() ) )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Folder '%s' could not be created.\n\n"
|
DisplayErrorMessage( m_frame, wxString::Format( _( "Folder '%s' could not be created.\n\n"
|
||||||
"Please make sure you have write permissions and try again." ),
|
"Please make sure you have sufficient permissions." ),
|
||||||
newProjectDir.GetPath() );
|
newProjectDir.GetPath() ) );
|
||||||
DisplayErrorMessage( m_frame, msg );
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !newProjectDir.IsDirWritable() )
|
if( !newProjectDir.IsDirWritable() )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Insufficient permissions to write to folder '%s'." ),
|
DisplayErrorMessage( m_frame, wxString::Format( _( "Insufficient permissions to write to folder '%s'." ),
|
||||||
newProjectDir.GetFullPath() );
|
newProjectDir.GetFullPath() ) );
|
||||||
wxMessageDialog msgDlg( m_frame, msg, _( "Error!" ), wxICON_ERROR | wxOK | wxCENTER );
|
|
||||||
msgDlg.ShowModal();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,17 +187,14 @@ void DIALOG_GEN_FOOTPRINT_POSITION::onOutputDirectoryBrowseClicked( wxCommandEve
|
|||||||
|
|
||||||
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
||||||
|
|
||||||
wxMessageDialog dialog( this, _( "Use a relative path?"), _( "Plot Output Directory" ),
|
if( IsOK( this, _( "Use a relative path?" ) ) )
|
||||||
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
||||||
|
|
||||||
if( dialog.ShowModal() == wxID_YES )
|
|
||||||
{
|
{
|
||||||
wxString boardFilePath = ( (wxFileName) m_editFrame->GetBoard()->GetFileName() ).GetPath();
|
wxString boardFilePath = ( (wxFileName) m_editFrame->GetBoard()->GetFileName() ).GetPath();
|
||||||
|
|
||||||
if( !dirName.MakeRelativeTo( boardFilePath ) )
|
if( !dirName.MakeRelativeTo( boardFilePath ) )
|
||||||
{
|
{
|
||||||
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
|
DisplayErrorMessage( this, _( "Cannot make path relative (target volume different from board "
|
||||||
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
"file volume)!" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,17 +273,13 @@ void DIALOG_GENDRILL::onOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
|||||||
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
||||||
wxFileName fn( Prj().AbsolutePath( m_board->GetFileName() ) );
|
wxFileName fn( Prj().AbsolutePath( m_board->GetFileName() ) );
|
||||||
wxString defaultPath = fn.GetPathWithSep();
|
wxString defaultPath = fn.GetPathWithSep();
|
||||||
wxString msg;
|
|
||||||
msg.Printf( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath );
|
|
||||||
|
|
||||||
wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
if( IsOK( this, wxString::Format( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
|
||||||
|
|
||||||
if( dialog.ShowModal() == wxID_YES )
|
|
||||||
{
|
{
|
||||||
if( !dirName.MakeRelativeTo( defaultPath ) )
|
if( !dirName.MakeRelativeTo( defaultPath ) )
|
||||||
{
|
{
|
||||||
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
|
DisplayErrorMessage( this, _( "Cannot make path relative (target volume different from board "
|
||||||
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
"file volume)!" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <board_design_settings.h>
|
#include <board_design_settings.h>
|
||||||
#include <pcb_layer_box_selector.h>
|
#include <pcb_layer_box_selector.h>
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
#include <confirm.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some handy preset values for common outset distances.
|
* Some handy preset values for common outset distances.
|
||||||
@ -171,19 +172,13 @@ bool DIALOG_OUTSET_ITEMS::TransferDataFromWindow()
|
|||||||
{
|
{
|
||||||
if( m_outset.GetIntValue() <= 0 )
|
if( m_outset.GetIntValue() <= 0 )
|
||||||
{
|
{
|
||||||
wxString msg = _( "Outset must be a positive value." );
|
DisplayErrorMessage( this, _( "Outset must be a positive value." ) );
|
||||||
|
|
||||||
wxMessageDialog errdlg( this, msg, _( "Error" ) );
|
|
||||||
errdlg.ShowModal();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_lineWidth.GetIntValue() <= 0 )
|
if( m_lineWidth.GetIntValue() <= 0 )
|
||||||
{
|
{
|
||||||
wxString msg = _( "Line width must be a positive value." );
|
DisplayErrorMessage( this, _( "Line width must be a positive value." ) );
|
||||||
|
|
||||||
wxMessageDialog errdlg( this, msg, _( "Error" ) );
|
|
||||||
errdlg.ShowModal();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,12 +785,7 @@ void DIALOG_PLOT::onOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
|||||||
// Test if making the path relative is possible before asking the user if they want to do it
|
// Test if making the path relative is possible before asking the user if they want to do it
|
||||||
if( relPathTest.MakeRelativeTo( defaultPath ) )
|
if( relPathTest.MakeRelativeTo( defaultPath ) )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath );
|
if( IsOK( this, wxString::Format( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath ) ) )
|
||||||
|
|
||||||
wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
|
|
||||||
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
||||||
|
|
||||||
if( dialog.ShowModal() == wxID_YES )
|
|
||||||
dirName.MakeRelativeTo( defaultPath );
|
dirName.MakeRelativeTo( defaultPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,10 +441,8 @@ int BOARD_EDITOR_CONTROL::ExportNetlist( const TOOL_EVENT& aEvent )
|
|||||||
|
|
||||||
if( !fn.IsDirWritable() )
|
if( !fn.IsDirWritable() )
|
||||||
{
|
{
|
||||||
wxString msg;
|
DisplayErrorMessage( m_frame, wxString::Format( _( "Insufficient permissions to folder '%s'." ),
|
||||||
|
fn.GetPath() ) );
|
||||||
msg.Printf( _( "Path `%s` is read only." ), fn.GetPath() );
|
|
||||||
wxMessageDialog( m_frame, msg, _( "I/O Error" ), wxOK | wxCENTER | wxICON_EXCLAMATION );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,10 +463,7 @@ int BOARD_EDITOR_CONTROL::ExportNetlist( const TOOL_EVENT& aEvent )
|
|||||||
const wxString& netname = pad->GetShortNetname();
|
const wxString& netname = pad->GetShortNetname();
|
||||||
|
|
||||||
if( !netname.IsEmpty() )
|
if( !netname.IsEmpty() )
|
||||||
{
|
component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(), pad->GetPinType() );
|
||||||
component->AddNet( pad->GetNumber(), netname, pad->GetPinFunction(),
|
|
||||||
pad->GetPinType() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::ordered_map<wxString, wxString> fields;
|
nlohmann::ordered_map<wxString, wxString> fields;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user