Confirm only once when multi-deleting files
Also do not open empty popup window.
This commit is contained in:
parent
952e7a5fb4
commit
59c971e1e1
|
@ -118,7 +118,6 @@ bool PGM_KICAD::OnPgmInit()
|
|||
|
||||
if( it != GetLocalEnvVariables().end() && it->second.GetValue() != wxEmptyString )
|
||||
m_bm.m_search.Insert( it->second.GetValue(), 0 );
|
||||
|
||||
// The KICAD_USER_TEMPLATE_DIR takes precedence over KICAD_TEMPLATE_DIR and the search
|
||||
// stack template path.
|
||||
it = GetLocalEnvVariables().find( "KICAD_USER_TEMPLATE_DIR" );
|
||||
|
|
|
@ -705,7 +705,8 @@ void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
|
|||
_( "Print the contents of the file" ), KiBitmap( print_button_xpm ) );
|
||||
}
|
||||
|
||||
PopupMenu( &popup_menu );
|
||||
if( popup_menu.GetMenuItemCount() > 0 )
|
||||
PopupMenu( &popup_menu );
|
||||
}
|
||||
|
||||
|
||||
|
@ -738,9 +739,29 @@ void TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor( wxCommandEvent& event
|
|||
void TREE_PROJECT_FRAME::OnDeleteFile( wxCommandEvent& )
|
||||
{
|
||||
std::vector<TREEPROJECT_ITEM*> tree_data = GetSelectedData();
|
||||
wxString msg, caption;
|
||||
|
||||
for( TREEPROJECT_ITEM* item_data : tree_data )
|
||||
item_data->Delete();
|
||||
if( tree_data.size() == 1 )
|
||||
{
|
||||
bool is_directory = wxDirExists( tree_data[0]->GetFileName() );
|
||||
msg = wxString::Format(
|
||||
_( "Are you sure you want to delete '%s'?" ), tree_data[0]->GetFileName() );
|
||||
caption = is_directory ? _( "Delete Directory" ) : _( "Delete File" );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = wxString::Format(
|
||||
_( "Are you sure you want to delete %lu items?" ), tree_data.size() );
|
||||
caption = _( "Delete Multiple Items" );
|
||||
}
|
||||
|
||||
wxMessageDialog dialog( m_parent, msg, caption, wxYES_NO | wxICON_QUESTION );
|
||||
|
||||
if( dialog.ShowModal() == wxID_YES )
|
||||
{
|
||||
for( TREEPROJECT_ITEM* item_data : tree_data )
|
||||
item_data->Delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -127,23 +127,15 @@ bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
|
|||
void TREEPROJECT_ITEM::Delete()
|
||||
{
|
||||
bool isDirectory = wxDirExists( GetFileName() );
|
||||
bool success;
|
||||
|
||||
wxString msg = wxString::Format( _( "Are you sure you want to delete '%s'?" ), GetFileName() );
|
||||
wxMessageDialog dialog( m_parent, msg, isDirectory ? _( "Delete Directory" ) : _( "Delete File" ),
|
||||
wxYES_NO | wxICON_QUESTION );
|
||||
if( !isDirectory )
|
||||
success = wxRemoveFile( GetFileName() );
|
||||
else
|
||||
success = DeleteDirectory( GetFileName() );
|
||||
|
||||
if( dialog.ShowModal() == wxID_YES )
|
||||
{
|
||||
bool success;
|
||||
|
||||
if( !isDirectory )
|
||||
success = wxRemoveFile( GetFileName() );
|
||||
else
|
||||
success = DeleteDirectory( GetFileName() );
|
||||
|
||||
if( success )
|
||||
m_parent->Delete( GetId() );
|
||||
}
|
||||
if( success )
|
||||
m_parent->Delete( GetId() );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue