mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-02 00:26:45 +00:00
design blocks: move table manager to common dialogs
Also add to schematic editor preferences.
This commit is contained in:
parent
0a5de3510d
commit
b2dda11fae
@ -358,6 +358,8 @@ set( COMMON_DLG_SRCS
|
||||
dialogs/panel_color_settings.cpp
|
||||
dialogs/panel_common_settings.cpp
|
||||
dialogs/panel_common_settings_base.cpp
|
||||
dialogs/panel_design_block_lib_table_base.cpp
|
||||
dialogs/panel_design_block_lib_table.cpp
|
||||
dialogs/panel_embedded_files.cpp
|
||||
dialogs/panel_embedded_files_base.cpp
|
||||
dialogs/panel_gal_display_options.cpp
|
||||
|
@ -1153,3 +1153,57 @@ void PANEL_DESIGN_BLOCK_LIB_TABLE::populateEnvironReadOnlyTable()
|
||||
|
||||
|
||||
size_t PANEL_DESIGN_BLOCK_LIB_TABLE::m_pageNdx = 0;
|
||||
|
||||
|
||||
void InvokeEditDesignBlockLibTable( KIWAY* aKiway, wxWindow *aParent )
|
||||
{
|
||||
DESIGN_BLOCK_LIB_TABLE* globalTable = &GDesignBlockTable;
|
||||
wxString globalTablePath = DESIGN_BLOCK_LIB_TABLE::GetGlobalTableFileName();
|
||||
DESIGN_BLOCK_LIB_TABLE* projectTable = aKiway->Prj().DesignBlockLibs();
|
||||
wxString projectTablePath = aKiway->Prj().DesignBlockLibTblName();
|
||||
wxString msg;
|
||||
|
||||
DIALOG_EDIT_LIBRARY_TABLES dlg( aParent, _( "Design Block Libraries" ) );
|
||||
|
||||
if( aKiway->Prj().IsNullProject() )
|
||||
projectTable = nullptr;
|
||||
|
||||
dlg.InstallPanel( new PANEL_DESIGN_BLOCK_LIB_TABLE( &dlg, &aKiway->Prj(), globalTable, globalTablePath,
|
||||
projectTable, projectTablePath,
|
||||
aKiway->Prj().GetProjectPath() ) );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
|
||||
if( dlg.m_GlobalTableChanged )
|
||||
{
|
||||
try
|
||||
{
|
||||
globalTable->Save( globalTablePath );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
|
||||
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
if( projectTable && dlg.m_ProjectTableChanged )
|
||||
{
|
||||
try
|
||||
{
|
||||
projectTable->Save( projectTablePath );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
|
||||
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
std::string payload = "";
|
||||
aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload );
|
||||
aKiway->ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload );
|
||||
|
||||
return;
|
||||
}
|
@ -103,4 +103,7 @@ private:
|
||||
m_supportedDesignBlockFiles;
|
||||
};
|
||||
|
||||
|
||||
void InvokeEditDesignBlockLibTable( KIWAY* aKiway, wxWindow *aParent );
|
||||
|
||||
#endif // PANEL_DESIGN_BLOCK_LIB_TABLE_H
|
@ -123,7 +123,6 @@ int COMMON_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent )
|
||||
}
|
||||
else if( aEvent.IsAction( &ACTIONS::showFootprintLibTable ) )
|
||||
{
|
||||
|
||||
try // Pcb frame was not available, try to start it
|
||||
{
|
||||
KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
|
||||
@ -138,6 +137,22 @@ int COMMON_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent )
|
||||
// A error message is displayed after trying to load _pcbnew.kiface.
|
||||
}
|
||||
}
|
||||
else if( aEvent.IsAction( &ACTIONS::showDesignBlockLibTable ) )
|
||||
{
|
||||
try // Kicad frame was not available, try to start it
|
||||
{
|
||||
KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH );
|
||||
|
||||
if( kiface )
|
||||
kiface->CreateKiWindow( m_frame, DIALOG_DESIGN_BLOCK_LIBRARY_TABLE, &m_frame->Kiway() );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
// _eeschema.kiface is not available: it contains the library table dialog.
|
||||
// Do nothing here.
|
||||
// A error message is displayed after trying to load _eeschema.kiface.
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -342,6 +357,7 @@ void COMMON_CONTROL::setTransitions()
|
||||
Go( &COMMON_CONTROL::ConfigurePaths, ACTIONS::configurePaths.MakeEvent() );
|
||||
Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showSymbolLibTable.MakeEvent() );
|
||||
Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showFootprintLibTable.MakeEvent() );
|
||||
Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showDesignBlockLibTable.MakeEvent() );
|
||||
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showSymbolBrowser.MakeEvent() );
|
||||
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showSymbolEditor.MakeEvent() );
|
||||
Go( &COMMON_CONTROL::ShowPlayer, ACTIONS::showFootprintBrowser.MakeEvent() );
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <dialogs/dialog_global_sym_lib_table_config.h>
|
||||
#include <dialogs/panel_grid_settings.h>
|
||||
#include <dialogs/panel_simulator_preferences.h>
|
||||
#include <dialogs/panel_design_block_lib_table.h>
|
||||
#include <dialogs/panel_sym_lib_table.h>
|
||||
#include <kiway.h>
|
||||
#include <settings/settings_manager.h>
|
||||
@ -197,6 +198,11 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
|
||||
// Dialog has completed; nothing to return.
|
||||
return nullptr;
|
||||
|
||||
case DIALOG_DESIGN_BLOCK_LIBRARY_TABLE:
|
||||
InvokeEditDesignBlockLibTable( aKiway, aParent );
|
||||
// Dialog has completed; nothing to return.
|
||||
return nullptr;
|
||||
|
||||
case PANEL_SYM_DISP_OPTIONS:
|
||||
{
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
|
@ -337,6 +337,8 @@ void SCH_EDIT_FRAME::doReCreateMenuBar()
|
||||
|
||||
prefsMenu->Add( ACTIONS::configurePaths );
|
||||
prefsMenu->Add( ACTIONS::showSymbolLibTable );
|
||||
if( ADVANCED_CFG::GetCfg().m_EnableDesignBlocks )
|
||||
prefsMenu->Add( ACTIONS::showDesignBlockLibTable );
|
||||
prefsMenu->Add( ACTIONS::openPreferences );
|
||||
|
||||
prefsMenu->AppendSeparator();
|
||||
|
@ -25,8 +25,6 @@ set( KICAD_SRCS
|
||||
dialogs/dialog_template_selector.cpp
|
||||
dialogs/panel_kicad_launcher_base.cpp
|
||||
dialogs/panel_kicad_launcher.cpp
|
||||
dialogs/panel_design_block_lib_table_base.cpp
|
||||
dialogs/panel_design_block_lib_table.cpp
|
||||
files-io.cpp
|
||||
import_proj.cpp
|
||||
import_project.cpp
|
||||
|
@ -890,65 +890,6 @@ int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent )
|
||||
}
|
||||
|
||||
|
||||
int KICAD_MANAGER_CONTROL::ShowDesignBlockLibTable( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
// For some reason, after a click or a double click the bitmap button calling
|
||||
// PCM keeps the focus althougt the focus was not set to this button.
|
||||
// This hack force removing the focus from this button
|
||||
m_frame->SetFocus();
|
||||
wxSafeYield();
|
||||
|
||||
DESIGN_BLOCK_LIB_TABLE* globalTable = &GDesignBlockTable;
|
||||
wxString globalTablePath = DESIGN_BLOCK_LIB_TABLE::GetGlobalTableFileName();
|
||||
DESIGN_BLOCK_LIB_TABLE* projectTable = Prj().DesignBlockLibs();
|
||||
wxString projectTablePath = Prj().DesignBlockLibTblName();
|
||||
wxString msg;
|
||||
|
||||
DIALOG_EDIT_LIBRARY_TABLES dlg( m_frame, _( "Design Block Libraries" ) );
|
||||
|
||||
if( Prj().IsNullProject() )
|
||||
projectTable = nullptr;
|
||||
|
||||
dlg.InstallPanel( new PANEL_DESIGN_BLOCK_LIB_TABLE( &dlg, &Prj(), globalTable, globalTablePath,
|
||||
projectTable, projectTablePath,
|
||||
Prj().GetProjectPath() ) );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return 0;
|
||||
|
||||
if( dlg.m_GlobalTableChanged )
|
||||
{
|
||||
try
|
||||
{
|
||||
globalTable->Save( globalTablePath );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
|
||||
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
if( projectTable && dlg.m_ProjectTableChanged )
|
||||
{
|
||||
try
|
||||
{
|
||||
projectTable->Save( projectTablePath );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
|
||||
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
std::string payload = "";
|
||||
Kiway.ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload );
|
||||
Kiway.ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int KICAD_MANAGER_CONTROL::ShowPluginManager( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( KIPLATFORM::POLICY::GetPolicyBool( POLICY_KEY_PCM )
|
||||
@ -1042,7 +983,5 @@ void KICAD_MANAGER_CONTROL::setTransitions()
|
||||
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::editOtherSch.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::Execute, KICAD_MANAGER_ACTIONS::editOtherPCB.MakeEvent() );
|
||||
|
||||
Go( &KICAD_MANAGER_CONTROL::ShowDesignBlockLibTable,
|
||||
ACTIONS::showDesignBlockLibTable.MakeEvent() );
|
||||
Go( &KICAD_MANAGER_CONTROL::ShowPluginManager, KICAD_MANAGER_ACTIONS::showPluginManager.MakeEvent() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user