mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Sym edit: Also allow the 'edit in library' action to be a hotkey
Allows the user to easily 'upgrade' into a library edit action if they choose the wrong one of Ctrl+E or Ctrl+Shift+E. Increaes consistency with FP editing.
This commit is contained in:
parent
3b2f6d9d03
commit
c55d7d6eb4
@ -49,6 +49,7 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar()
|
||||
fileMenu->Add( ACTIONS::addLibrary );
|
||||
fileMenu->Add( EE_ACTIONS::saveLibraryAs );
|
||||
fileMenu->Add( EE_ACTIONS::newSymbol );
|
||||
fileMenu->Add( EE_ACTIONS::editLibSymbolWithLibEdit );
|
||||
|
||||
fileMenu->AppendSeparator();
|
||||
fileMenu->Add( ACTIONS::save );
|
||||
|
@ -470,13 +470,21 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
|
||||
return getTargetSymbol() != nullptr;
|
||||
};
|
||||
|
||||
mgr->SetConditions( ACTIONS::saveAll, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( ACTIONS::save, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( EE_ACTIONS::saveLibraryAs, ENABLE( libSelectedCondition ) );
|
||||
mgr->SetConditions( EE_ACTIONS::saveSymbolAs, ENABLE( saveSymbolAsCondition ) );
|
||||
mgr->SetConditions( EE_ACTIONS::saveSymbolCopyAs, ENABLE( saveSymbolAsCondition ) );
|
||||
mgr->SetConditions( EE_ACTIONS::newSymbol, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( EE_ACTIONS::importSymbol, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
const auto isSymbolFromSchematicCond =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
return IsSymbolFromSchematic();
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
mgr->SetConditions( ACTIONS::saveAll, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( ACTIONS::save, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( EE_ACTIONS::saveLibraryAs, ENABLE( libSelectedCondition ) );
|
||||
mgr->SetConditions( EE_ACTIONS::saveSymbolAs, ENABLE( saveSymbolAsCondition ) );
|
||||
mgr->SetConditions( EE_ACTIONS::saveSymbolCopyAs, ENABLE( saveSymbolAsCondition ) );
|
||||
mgr->SetConditions( EE_ACTIONS::newSymbol, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( EE_ACTIONS::importSymbol, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
||||
mgr->SetConditions( EE_ACTIONS::editLibSymbolWithLibEdit, ENABLE( isSymbolFromSchematicCond ) );
|
||||
|
||||
mgr->SetConditions( ACTIONS::undo, ENABLE( haveSymbolCond && cond.UndoAvailable() ) );
|
||||
mgr->SetConditions( ACTIONS::redo, ENABLE( haveSymbolCond && cond.RedoAvailable() ) );
|
||||
@ -508,6 +516,7 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
|
||||
|
||||
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
||||
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
||||
// clang-format on
|
||||
|
||||
auto pinTypeCond =
|
||||
[this]( const SELECTION& )
|
||||
@ -891,18 +900,7 @@ void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom )
|
||||
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
|
||||
[this, symbolName, libName]( wxHyperlinkEvent& aEvent )
|
||||
{
|
||||
if( LoadSymbol( m_symbol->GetLibId(), GetUnit(), GetBodyStyle() ) )
|
||||
{
|
||||
if( !IsLibraryTreeShown() )
|
||||
ToggleLibraryTree();
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayError( this, wxString::Format( _( "Failed to load symbol %s from "
|
||||
"library %s." ),
|
||||
symbolName,
|
||||
libName ) );
|
||||
}
|
||||
GetToolManager()->RunAction( EE_ACTIONS::editLibSymbolWithLibEdit );
|
||||
} ) );
|
||||
|
||||
infobar.AddButton( button );
|
||||
|
@ -208,6 +208,38 @@ int SYMBOL_EDITOR_CONTROL::EditSymbol( const TOOL_EVENT& aEvent )
|
||||
}
|
||||
|
||||
|
||||
int SYMBOL_EDITOR_CONTROL::EditLibrarySymbol( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
|
||||
const LIB_SYMBOL* symbol = editFrame->GetCurSymbol();
|
||||
|
||||
if( !symbol || !editFrame->IsSymbolFromSchematic() )
|
||||
{
|
||||
wxBell();
|
||||
return 0;
|
||||
}
|
||||
|
||||
const LIB_ID& libId = symbol->GetLibId();
|
||||
|
||||
if( editFrame->LoadSymbol( libId, editFrame->GetUnit(), editFrame->GetBodyStyle() ) )
|
||||
{
|
||||
if( !editFrame->IsLibraryTreeShown() )
|
||||
editFrame->ToggleLibraryTree();
|
||||
}
|
||||
else
|
||||
{
|
||||
const wxString libName = libId.GetLibNickname();
|
||||
const wxString symbolName = libId.GetLibItemName();
|
||||
|
||||
DisplayError( editFrame,
|
||||
wxString::Format( _( "Failed to load symbol %s from "
|
||||
"library %s." ),
|
||||
UnescapeString( symbolName ), UnescapeString( libName ) ) );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int SYMBOL_EDITOR_CONTROL::AddSymbol( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( !m_isSymbolEditor )
|
||||
@ -813,6 +845,7 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
|
||||
Go( &SYMBOL_EDITOR_CONTROL::AddSymbol, EE_ACTIONS::deriveFromExistingSymbol.MakeEvent() );
|
||||
Go( &SYMBOL_EDITOR_CONTROL::AddSymbol, EE_ACTIONS::importSymbol.MakeEvent() );
|
||||
Go( &SYMBOL_EDITOR_CONTROL::EditSymbol, EE_ACTIONS::editSymbol.MakeEvent() );
|
||||
Go( &SYMBOL_EDITOR_CONTROL::EditLibrarySymbol, EE_ACTIONS::editLibSymbolWithLibEdit.MakeEvent() );
|
||||
|
||||
Go( &SYMBOL_EDITOR_CONTROL::DdAddLibrary, ACTIONS::ddAddLibrary.MakeEvent() );
|
||||
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
int AddLibrary( const TOOL_EVENT& aEvent );
|
||||
int AddSymbol( const TOOL_EVENT& aEvent );
|
||||
int EditSymbol( const TOOL_EVENT& aEvent );
|
||||
int EditLibrarySymbol( const TOOL_EVENT& aEvent );
|
||||
|
||||
int Save( const TOOL_EVENT& aEvt );
|
||||
int Revert( const TOOL_EVENT& aEvent );
|
||||
|
Loading…
x
Reference in New Issue
Block a user