Move LibEdit Save operations to ACTIONS.
This commit is contained in:
parent
2502bce987
commit
927d2a645c
|
@ -90,9 +90,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
// Actions
|
||||
EVT_TOOL( ID_LIBEDIT_NEW_LIBRARY, LIB_EDIT_FRAME::OnCreateNewLibrary )
|
||||
EVT_TOOL( ID_LIBEDIT_ADD_LIBRARY, LIB_EDIT_FRAME::OnAddLibrary )
|
||||
EVT_TOOL( ID_LIBEDIT_SAVE, LIB_EDIT_FRAME::OnSave )
|
||||
EVT_MENU( ID_LIBEDIT_SAVE_AS, LIB_EDIT_FRAME::OnSaveAs )
|
||||
EVT_MENU( ID_LIBEDIT_SAVE_ALL, LIB_EDIT_FRAME::OnSaveAll )
|
||||
EVT_TOOL( ID_LIBEDIT_REVERT, LIB_EDIT_FRAME::OnRevert )
|
||||
EVT_TOOL( ID_LIBEDIT_NEW_PART, LIB_EDIT_FRAME::OnCreateNewPart )
|
||||
EVT_TOOL( ID_LIBEDIT_EDIT_PART, LIB_EDIT_FRAME::OnEditPart )
|
||||
|
@ -133,8 +130,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
|
||||
// Update user interface elements.
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateHavePart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE, LIB_EDIT_FRAME::OnUpdateSave )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_ALL, LIB_EDIT_FRAME::OnUpdateSave )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_AS, LIB_EDIT_FRAME::OnUpdateHavePart )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_REVERT, LIB_EDIT_FRAME::OnUpdateRevert )
|
||||
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
|
||||
|
@ -397,20 +392,6 @@ void LIB_EDIT_FRAME::ClearSearchTreeSelection()
|
|||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
LIB_ID libId = getTargetLibId();
|
||||
const wxString& libName = libId.GetLibNickname();
|
||||
const wxString& partName = libId.GetLibItemName();
|
||||
bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName );
|
||||
|
||||
if( partName.IsEmpty() )
|
||||
aEvent.Enable( !readOnly && m_libMgr->IsLibraryModified( libName ) );
|
||||
else
|
||||
aEvent.Enable( !readOnly && m_libMgr->IsPartModified( partName, libName ) );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnUpdateRevert( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
LIB_ID libId = getTargetLibId();
|
||||
|
|
|
@ -252,17 +252,17 @@ public:
|
|||
/**
|
||||
* Saves the selected part or library.
|
||||
*/
|
||||
void OnSave( wxCommandEvent& aEvent );
|
||||
void OnSave();
|
||||
|
||||
/**
|
||||
* Saves the selected part or library to a new name and/or location.
|
||||
*/
|
||||
void OnSaveAs( wxCommandEvent& aEvent );
|
||||
void OnSaveAs();
|
||||
|
||||
/**
|
||||
* Saves all modified parts and libraries.
|
||||
*/
|
||||
void OnSaveAll( wxCommandEvent& aEvent );
|
||||
void OnSaveAll();
|
||||
|
||||
/**
|
||||
* Reverts unsaved changes in a part, restoring to the last saved state.
|
||||
|
@ -292,7 +292,6 @@ public:
|
|||
|
||||
void OnUpdateEditingPart( wxUpdateUIEvent& event );
|
||||
void OnUpdateHavePart( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateSave( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateRevert( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateSyncPinEdit( wxUpdateUIEvent& event );
|
||||
void OnUpdatePartNumber( wxUpdateUIEvent& event );
|
||||
|
|
|
@ -289,7 +289,7 @@ void LIB_EDIT_FRAME::RedrawComponent( wxDC* aDC, wxPoint aOffset )
|
|||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnSaveAll( wxCommandEvent& event )
|
||||
void LIB_EDIT_FRAME::OnSaveAll()
|
||||
{
|
||||
saveAllLibraries( false );
|
||||
m_treePane->Refresh();
|
||||
|
@ -383,7 +383,7 @@ void LIB_EDIT_FRAME::OnEditPart( wxCommandEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnSave( wxCommandEvent& aEvent )
|
||||
void LIB_EDIT_FRAME::OnSave()
|
||||
{
|
||||
LIB_ID libId = getTargetLibId();
|
||||
const wxString& libName = libId.GetLibNickname();
|
||||
|
@ -405,7 +405,7 @@ void LIB_EDIT_FRAME::OnSave( wxCommandEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnSaveAs( wxCommandEvent& aEvent )
|
||||
void LIB_EDIT_FRAME::OnSaveAs()
|
||||
{
|
||||
LIB_ID libId = getTargetLibId();
|
||||
const wxString& libName = libId.GetLibNickname();
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <tool/tool_manager.h>
|
||||
#include <tools/ee_actions.h>
|
||||
#include <tools/ee_selection_tool.h>
|
||||
|
||||
#include <lib_manager.h>
|
||||
#include "eeschema_id.h"
|
||||
#include "general.h"
|
||||
#include "help_common_strings.h"
|
||||
|
@ -46,98 +46,72 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
wxMenuBar* menuBar = new wxMenuBar();
|
||||
wxString text;
|
||||
|
||||
// Recreate all menus:
|
||||
auto modifiedDocumentCondition = [ this ] ( const SELECTION& sel ) {
|
||||
LIB_ID libId = getTargetLibId();
|
||||
const wxString& libName = libId.GetLibNickname();
|
||||
const wxString& partName = libId.GetLibItemName();
|
||||
bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName );
|
||||
|
||||
if( partName.IsEmpty() )
|
||||
return ( !readOnly && m_libMgr->IsLibraryModified( libName ) );
|
||||
else
|
||||
return ( !readOnly && m_libMgr->IsPartModified( partName, libName ) );
|
||||
};
|
||||
|
||||
//
|
||||
// Menu File:
|
||||
wxMenu* fileMenu = new wxMenu;
|
||||
//
|
||||
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
|
||||
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_NEW_LIBRARY,
|
||||
_( "New Library..." ),
|
||||
_( "Creates an empty library" ),
|
||||
KiBitmap( new_library_xpm ) );
|
||||
fileMenu->AddItem( ID_LIBEDIT_NEW_LIBRARY,
|
||||
_( "New Library..." ),
|
||||
_( "Creates an empty library" ),
|
||||
new_library_xpm, EE_CONDITIONS::ShowAlways );
|
||||
fileMenu->AddItem( ID_LIBEDIT_ADD_LIBRARY,
|
||||
_( "Add Library..." ),
|
||||
_( "Adds a previously created library" ),
|
||||
add_library_xpm, EE_CONDITIONS::ShowAlways );
|
||||
fileMenu->AddItem( ID_LIBEDIT_NEW_PART,
|
||||
AddHotkeyName( _( "New Symbol..." ), m_hotkeysDescrList, HK_NEW ),
|
||||
_( "Create a new symbol" ),
|
||||
new_component_xpm, EE_CONDITIONS::ShowAlways );
|
||||
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_ADD_LIBRARY,
|
||||
_( "Add Library..." ),
|
||||
_( "Adds a previously created library" ),
|
||||
KiBitmap( add_library_xpm ) );
|
||||
fileMenu->AddSeparator();
|
||||
fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition );
|
||||
fileMenu->AddItem( ACTIONS::saveAs, EE_CONDITIONS::ShowAlways );
|
||||
fileMenu->AddItem( ACTIONS::saveAll, EE_CONDITIONS::ShowAlways );
|
||||
fileMenu->AddItem( ID_LIBEDIT_REVERT,
|
||||
_( "Revert" ),
|
||||
_( "Throw away changes" ),
|
||||
undo_xpm, EE_CONDITIONS::ShowAlways );
|
||||
|
||||
text = AddHotkeyName( _( "&New Symbol..." ), m_hotkeysDescrList, HK_NEW );
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_NEW_PART,
|
||||
text,
|
||||
_( "Create a new symbol" ),
|
||||
KiBitmap( new_component_xpm ) );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
text = AddHotkeyName( _( "&Save" ), g_Libedit_Hotkeys_Descr, HK_SAVE );
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_SAVE,
|
||||
text,
|
||||
_( "Save changes" ),
|
||||
KiBitmap( save_xpm ) );
|
||||
|
||||
text = AddHotkeyName( _( "Save &As..." ), g_Libedit_Hotkeys_Descr, HK_SAVEAS );
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_SAVE_AS,
|
||||
text,
|
||||
_( "Save a copy to a new name and/or location" ),
|
||||
KiBitmap( save_as_xpm ) );
|
||||
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_SAVE_ALL,
|
||||
_( "Save All" ),
|
||||
_( "Save all library and symbol changes" ),
|
||||
KiBitmap( save_xpm ) );
|
||||
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_REVERT,
|
||||
_( "&Revert" ),
|
||||
_( "Throw away changes" ),
|
||||
KiBitmap( undo_xpm ) );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_IMPORT_PART,
|
||||
_( "&Import Symbol..." ),
|
||||
_( "Import a symbol to the current library" ),
|
||||
KiBitmap( import_part_xpm ) );
|
||||
fileMenu->AddSeparator();
|
||||
fileMenu->AddItem( ID_LIBEDIT_IMPORT_PART,
|
||||
_( "Import Symbol..." ),
|
||||
_( "Import a symbol to the current library" ),
|
||||
import_part_xpm, EE_CONDITIONS::ShowAlways );
|
||||
|
||||
// Export submenu
|
||||
wxMenu* submenuExport = new wxMenu();
|
||||
ACTION_MENU* submenuExport = new ACTION_MENU();
|
||||
submenuExport->SetTool( selTool );
|
||||
submenuExport->SetTitle( _( "Export" ) );
|
||||
submenuExport->SetIcon( export_xpm );
|
||||
|
||||
AddMenuItem( submenuExport,
|
||||
ID_LIBEDIT_EXPORT_PART,
|
||||
_( "S&ymbol..." ),
|
||||
_( "Create a library file containing only the current symbol" ),
|
||||
KiBitmap( export_part_xpm ) );
|
||||
submenuExport->Add( _( "Symbol..." ),
|
||||
_( "Create a new library file containing the current symbol" ),
|
||||
ID_LIBEDIT_EXPORT_PART, export_part_xpm );
|
||||
submenuExport->Add( _( "View as PNG..." ),
|
||||
_( "Create a PNG file from the current view" ),
|
||||
ID_LIBEDIT_GEN_PNG_FILE, plot_xpm );
|
||||
submenuExport->Add( _( "Symbol as SVG..." ),
|
||||
_( "Create a SVG file from the current symbol" ),
|
||||
ID_LIBEDIT_GEN_SVG_FILE, plot_svg_xpm );
|
||||
|
||||
AddMenuItem( submenuExport,
|
||||
ID_LIBEDIT_GEN_PNG_FILE,
|
||||
_( "View as &PNG..." ),
|
||||
_( "Create a PNG file from the current view" ),
|
||||
KiBitmap( plot_xpm ) );
|
||||
fileMenu->AddMenu( submenuExport, EE_CONDITIONS::ShowAlways );
|
||||
|
||||
AddMenuItem( submenuExport,
|
||||
ID_LIBEDIT_GEN_SVG_FILE,
|
||||
_( "Symbol as S&VG..." ),
|
||||
_( "Create a SVG file from the current symbol" ),
|
||||
KiBitmap( plot_svg_xpm ) );
|
||||
|
||||
AddMenuItem( fileMenu, submenuExport, ID_GEN_EXPORT_FILE, _( "E&xport" ),
|
||||
_( "Export files" ),
|
||||
KiBitmap( export_xpm ) );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
|
||||
AddMenuItem( fileMenu,
|
||||
wxID_EXIT,
|
||||
_( "&Quit" ),
|
||||
_( "Quit Library Editor" ),
|
||||
KiBitmap( exit_xpm ) );
|
||||
fileMenu->AddSeparator();
|
||||
// Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT
|
||||
fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, EE_CONDITIONS::ShowAlways );
|
||||
|
||||
//
|
||||
// Edit menu
|
||||
|
@ -225,7 +199,6 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
//
|
||||
wxMenu* inspectMenu = new wxMenu;
|
||||
|
||||
|
||||
text = AddHotkeyName( _( "Show Datasheet" ), g_Libedit_Hotkeys_Descr, HK_LIBEDIT_VIEW_DOC );
|
||||
AddMenuItem( inspectMenu,
|
||||
ID_LIBEDIT_VIEW_DOC,
|
||||
|
|
|
@ -91,9 +91,7 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
|
|||
KiScaledBitmap( new_component_xpm, this ),
|
||||
_( "Create new symbol" ) );
|
||||
|
||||
m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_ALL, wxEmptyString,
|
||||
KiScaledBitmap( save_xpm, this ),
|
||||
_( "Save all changes" ) );
|
||||
m_mainToolBar->Add( ACTIONS::saveAll );
|
||||
|
||||
m_mainToolBar->AddSeparator();
|
||||
m_mainToolBar->Add( ACTIONS::undo );
|
||||
|
|
|
@ -41,6 +41,27 @@ TOOL_ACTION EE_ACTIONS::showComponentTree( "eeschema.SymbolLibraryControl.showCo
|
|||
search_tree_xpm );
|
||||
|
||||
|
||||
int LIB_CONTROL::Save( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->OnSave();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int LIB_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->OnSaveAs( true );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int LIB_CONTROL::SaveAll( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->OnSaveAll();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int LIB_CONTROL::ShowLibraryBrowser( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
wxCommandEvent dummy;
|
||||
|
@ -79,6 +100,10 @@ int LIB_CONTROL::ShowElectricalTypes( const TOOL_EVENT& aEvent )
|
|||
|
||||
void LIB_CONTROL::setTransitions()
|
||||
{
|
||||
Go( &LIB_CONTROL::Save, ACTIONS::save.MakeEvent() );
|
||||
Go( &LIB_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
|
||||
Go( &LIB_CONTROL::SaveAll, ACTIONS::saveAll.MakeEvent() );
|
||||
|
||||
Go( &LIB_CONTROL::ShowLibraryBrowser, EE_ACTIONS::showLibraryBrowser.MakeEvent() );
|
||||
Go( &LIB_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() );
|
||||
Go( &LIB_CONTROL::ShowComponentTree, EE_ACTIONS::showComponentTree.MakeEvent() );
|
||||
|
|
|
@ -35,15 +35,19 @@ class LIB_EDIT_FRAME;
|
|||
*
|
||||
* Handles actions for the various symbol editor and viewers.
|
||||
*/
|
||||
class LIB_CONTROL : public wxEvtHandler, public EE_TOOL_BASE<SCH_BASE_FRAME>
|
||||
class LIB_CONTROL : public wxEvtHandler, public EE_TOOL_BASE<LIB_EDIT_FRAME>
|
||||
{
|
||||
public:
|
||||
LIB_CONTROL() :
|
||||
EE_TOOL_BASE<SCH_BASE_FRAME>( "eeschema.SymbolLibraryControl" )
|
||||
EE_TOOL_BASE<LIB_EDIT_FRAME>( "eeschema.SymbolLibraryControl" )
|
||||
{ }
|
||||
|
||||
virtual ~LIB_CONTROL() { }
|
||||
|
||||
int Save( const TOOL_EVENT& aEvent );
|
||||
int SaveAs( const TOOL_EVENT& aEvent );
|
||||
int SaveAll( const TOOL_EVENT& aEvent );
|
||||
|
||||
int ShowLibraryBrowser( const TOOL_EVENT& aEvent );
|
||||
int ShowElectricalTypes( const TOOL_EVENT& aEvent );
|
||||
int ShowComponentTree( const TOOL_EVENT& aEvent );
|
||||
|
|
|
@ -1109,6 +1109,7 @@ 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::SaveAll, ACTIONS::saveAll.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::PageSetup, ACTIONS::pageSettings.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
|
||||
|
|
Loading…
Reference in New Issue