EEschema: change Save Copy As... to Save Current Sheet Copy As...

Save Copy As did not work with hierarchies (was not able to manage subsheets)
Fixes #9245
https://gitlab.com/kicad/code/kicad/issues/9245
This commit is contained in:
jean-pierre charras 2021-09-27 18:22:46 +02:00
parent e32bd7c4c4
commit d362cbc530
5 changed files with 39 additions and 2 deletions

View File

@ -85,7 +85,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
if( Kiface().IsSingle() )
fileMenu->Add( ACTIONS::saveAs );
else
fileMenu->Add( ACTIONS::saveCopyAs );
fileMenu->Add( EE_ACTIONS::saveCurrSheetCopyAs );
fileMenu->AppendSeparator();

View File

@ -753,3 +753,10 @@ TOOL_ACTION EE_ACTIONS::symbolMoveActivate( "eeschema.SymbolMoveTool",
TOOL_ACTION EE_ACTIONS::alignToGrid( "eeschema.AlignToGrid",
AS_GLOBAL, 0, "",
_( "Align Elements to Grid" ), "", BITMAPS::move, AF_ACTIVATE );
// Schematic editor save copy curr sheet command
TOOL_ACTION EE_ACTIONS::saveCurrSheetCopyAs( "eeschema.EditorControl.saveCurrSheetCopyAs",
AS_GLOBAL,
0, "",
_( "Save Current Sheet Copy As..." ), _( "Save a copy of the current sheet to another location or name" ),
BITMAPS::save_as );

View File

@ -38,6 +38,9 @@ class TOOL_MANAGER;
class EE_ACTIONS : public ACTIONS
{
public:
// Menu bar save curr sheet as command
static TOOL_ACTION saveCurrSheetCopyAs;
// Selection Tool
/// Activation of the selection tool
static TOOL_ACTION selectionActivate;

View File

@ -61,6 +61,10 @@
#include <dialog_update_from_pcb.h>
#include <eda_list_dialog.h>
#include <wildcards_and_files_ext.h>
#include <sch_sheet_path.h>
#include <wx/filedlg.h>
int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
{
@ -90,6 +94,25 @@ int SCH_EDITOR_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
}
int SCH_EDITOR_CONTROL::SaveCurrSheetCopyAs( const TOOL_EVENT& aEvent )
{
SCH_SHEET* curr_sheet = m_frame->GetCurrentSheet().Last();
wxFileName curr_fn = curr_sheet->GetFileName();
wxFileDialog dlg( m_frame, _( "Schematic Files" ), curr_fn.GetPath(),
curr_fn.GetFullName(), KiCadSchematicFileWildcard(),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )
return false;
wxFileName newFileName = dlg.GetPath();
newFileName.SetExt( KiCadSchematicFileExtension );
m_frame->saveSchematicFile( curr_sheet, newFileName.GetFullPath() );
return 0;
}
int SCH_EDITOR_CONTROL::ShowSchematicSetup( const TOOL_EVENT& aEvent )
{
m_frame->ShowSchematicSetupDialog();
@ -2056,7 +2079,8 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveCopyAs.MakeEvent() );
//Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveCopyAs.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::SaveCurrSheetCopyAs, EE_ACTIONS::saveCurrSheetCopyAs.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ShowSchematicSetup, EE_ACTIONS::schematicSetup.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PageSetup, ACTIONS::pageSettings.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );

View File

@ -50,6 +50,9 @@ public:
int Open( const TOOL_EVENT& aEvent );
int Save( const TOOL_EVENT& aEvent );
int SaveAs( const TOOL_EVENT& aEvent );
/// Saves the currently-open schematic sheet to an other name
int SaveCurrSheetCopyAs( const TOOL_EVENT& aEvent );
int ShowSchematicSetup( const TOOL_EVENT& aEvent );
int PageSetup( const TOOL_EVENT& aEvent );
int Print( const TOOL_EVENT& aEvent );