PCM: auto reload global libs after dialog is run
This adds Reset() method to KIFACE to reload global libs stored in global static vars. Also refactors some lib reload code in various frames to have common MAIL_RELOAD_LIB handler. Fixes https://gitlab.com/kicad/code/kicad/-/issues/12500
This commit is contained in:
parent
5a56b18b0e
commit
2975f53647
|
@ -596,6 +596,7 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable )
|
|||
}
|
||||
}
|
||||
|
||||
aTable.Clear();
|
||||
aTable.Load( fn.GetFullPath() );
|
||||
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
|
|
|
@ -947,6 +947,10 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
m_toolManager->RunAction( ACTIONS::updateSchematicFromPcb, true );
|
||||
break;
|
||||
|
||||
case MAIL_RELOAD_LIB:
|
||||
SyncView();
|
||||
break;
|
||||
|
||||
default:;
|
||||
|
||||
}
|
||||
|
|
|
@ -1014,9 +1014,7 @@ size_t PANEL_SYM_LIB_TABLE::m_pageNdx = 0;
|
|||
|
||||
void InvokeSchEditSymbolLibTable( KIWAY* aKiway, wxWindow *aParent )
|
||||
{
|
||||
auto* schEditor = (SCH_EDIT_FRAME*) aKiway->Player( FRAME_SCH, false );
|
||||
auto* symbolEditor = (SYMBOL_EDIT_FRAME*) aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
|
||||
auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) aKiway->Player( FRAME_SCH_VIEWER, false );
|
||||
|
||||
SYMBOL_LIB_TABLE* globalTable = &SYMBOL_LIB_TABLE::GetGlobalLibTable();
|
||||
wxString globalTablePath = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
|
||||
|
@ -1093,23 +1091,13 @@ void InvokeSchEditSymbolLibTable( KIWAY* aKiway, wxWindow *aParent )
|
|||
}
|
||||
}
|
||||
|
||||
if( schEditor )
|
||||
schEditor->SyncView();
|
||||
|
||||
if( symbolEditor )
|
||||
{
|
||||
// Check if the currently selected symbol library been removed or disabled.
|
||||
if( !currentLib.empty() && projectTable && !projectTable->HasLibrary( currentLib, true ) )
|
||||
{
|
||||
symbolEditor->SetCurLib( wxEmptyString );
|
||||
symbolEditor->emptyScreen();
|
||||
}
|
||||
|
||||
symbolEditor->SyncLibraries( true );
|
||||
symbolEditor->ThawLibraryTree();
|
||||
symbolEditor->RefreshLibraryTree();
|
||||
}
|
||||
|
||||
if( symbolViewer )
|
||||
symbolViewer->ReCreateLibList();
|
||||
std::string payload = "";
|
||||
aKiway->ExpressMail( FRAME_SCH, MAIL_RELOAD_LIB, payload );
|
||||
aKiway->ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_RELOAD_LIB, payload );
|
||||
aKiway->ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload );
|
||||
}
|
||||
|
|
|
@ -135,6 +135,8 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
|
|||
|
||||
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
|
||||
|
||||
void Reset() override;
|
||||
|
||||
void OnKifaceEnd() override;
|
||||
|
||||
wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
|
||||
|
@ -286,6 +288,8 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
|
|||
int HandleJob( JOB* aJob ) override;
|
||||
|
||||
private:
|
||||
bool loadGlobalLibTable();
|
||||
|
||||
std::unique_ptr<EESCHEMA_JOBS_HANDLER> m_jobHandler;
|
||||
|
||||
} kiface( "eeschema", KIWAY::FACE_SCH );
|
||||
|
@ -332,11 +336,28 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
|
|||
|
||||
start_common( aCtlBits );
|
||||
|
||||
if( !loadGlobalLibTable() )
|
||||
return false;
|
||||
|
||||
m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void IFACE::Reset()
|
||||
{
|
||||
loadGlobalLibTable();
|
||||
}
|
||||
|
||||
|
||||
bool IFACE::loadGlobalLibTable()
|
||||
{
|
||||
wxFileName fn = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
|
||||
|
||||
if( !fn.FileExists() )
|
||||
{
|
||||
if( !( aCtlBits & KFCTL_CLI ) )
|
||||
if( !( m_start_flags & KFCTL_CLI ) )
|
||||
{
|
||||
DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG fpDialog( nullptr );
|
||||
|
||||
|
@ -366,8 +387,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
|
|||
}
|
||||
}
|
||||
|
||||
m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1332,6 +1332,27 @@ void SYMBOL_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
|
||||
break;
|
||||
|
||||
case MAIL_RELOAD_LIB:
|
||||
{
|
||||
wxString currentLib = GetCurLib();
|
||||
SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable();
|
||||
|
||||
FreezeLibraryTree();
|
||||
|
||||
// Check if the currently selected symbol library been removed or disabled.
|
||||
if( !currentLib.empty() && libTable && !libTable->HasLibrary( currentLib, true ) )
|
||||
{
|
||||
SetCurLib( wxEmptyString );
|
||||
emptyScreen();
|
||||
}
|
||||
|
||||
SyncLibraries( true );
|
||||
ThawLibraryTree();
|
||||
RefreshLibraryTree();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
|
|
@ -635,6 +635,7 @@ bool SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE& aTable )
|
|||
}
|
||||
}
|
||||
|
||||
aTable.Clear();
|
||||
aTable.Load( fn.GetFullPath() );
|
||||
|
||||
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <eeschema_settings.h>
|
||||
#include <kiface_base.h>
|
||||
#include <kiway.h>
|
||||
#include <kiway_express.h>
|
||||
#include <locale_io.h>
|
||||
#include <symbol_viewer_frame.h>
|
||||
#include <widgets/msgpanel.h>
|
||||
|
@ -1306,3 +1307,17 @@ SELECTION& SYMBOL_VIEWER_FRAME::GetCurrentSelection()
|
|||
{
|
||||
return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
|
||||
}
|
||||
|
||||
|
||||
void SYMBOL_VIEWER_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
||||
{
|
||||
switch( mail.Command() )
|
||||
{
|
||||
case MAIL_RELOAD_LIB:
|
||||
{
|
||||
ReCreateLibList();
|
||||
break;
|
||||
}
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,8 @@ public:
|
|||
|
||||
SELECTION& GetCurrentSelection() override;
|
||||
|
||||
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
|
||||
|
||||
protected:
|
||||
void setupUIConditions() override;
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
virtual wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKIWAY,
|
||||
int aCtlBits = 0 ) override = 0;
|
||||
|
||||
virtual void Reset() override{};
|
||||
|
||||
virtual void* IfaceOrAddress( int aDataId ) override = 0;
|
||||
|
||||
/**
|
||||
|
@ -63,9 +65,9 @@ public:
|
|||
* #FACE_PL_EDITOR, #FACE_PCB_CALCULATOR, #FACE_BMP2CMP)
|
||||
*/
|
||||
KIFACE_BASE( const char* aKifaceName, KIWAY::FACE_T aId ) :
|
||||
m_start_flags( 0 ),
|
||||
m_id( aId ),
|
||||
m_bm( aKifaceName ),
|
||||
m_start_flags( 0 )
|
||||
m_bm( aKifaceName )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -119,12 +121,12 @@ public:
|
|||
aActions.push_back( action );
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_start_flags; ///< flags provided in OnKifaceStart()
|
||||
|
||||
private:
|
||||
KIWAY::FACE_T m_id;
|
||||
|
||||
BIN_MOD m_bm;
|
||||
|
||||
int m_start_flags; ///< flags provided in OnKifaceStart()
|
||||
KIWAY::FACE_T m_id;
|
||||
BIN_MOD m_bm;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -184,6 +184,11 @@ struct KIFACE
|
|||
*/
|
||||
virtual void OnKifaceEnd() = 0;
|
||||
|
||||
/**
|
||||
* Reloads global state.
|
||||
*/
|
||||
virtual void Reset() = 0;
|
||||
|
||||
/**
|
||||
* Create a wxWindow for the current project.
|
||||
*
|
||||
|
|
|
@ -52,7 +52,8 @@ enum MAIL_T
|
|||
MAIL_SCH_REFRESH, // Tell the schematic editor to refresh the display.
|
||||
MAIL_LIB_EDIT,
|
||||
MAIL_FP_EDIT,
|
||||
MAIL_RELOAD_LIB //Reload Library List if one was added
|
||||
MAIL_RELOAD_LIB, // Reload Library List if one was added
|
||||
MAIL_RELOAD_PLUGINS // Reload python plugins
|
||||
};
|
||||
|
||||
#endif // MAIL_TYPE_H_
|
||||
|
|
|
@ -290,13 +290,12 @@ void DIALOG_PCM::OnInstallFromFileClicked( wxCommandEvent& event )
|
|||
PCM_TASK_MANAGER task_manager( m_pcm );
|
||||
task_manager.InstallFromFile( this, open_file_dialog.GetPath() );
|
||||
|
||||
m_changed_package_types.merge( task_manager.GetChangedPackageTypes() );
|
||||
|
||||
setInstalledPackages();
|
||||
|
||||
if( !m_selectedRepositoryId.IsEmpty() )
|
||||
setRepositoryData( m_selectedRepositoryId );
|
||||
|
||||
if( task_manager.ColorSettingsChanged() )
|
||||
Pgm().GetSettingsManager().ReloadColorSettings();
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,6 +461,8 @@ void DIALOG_PCM::OnApplyChangesClicked( wxCommandEvent& event )
|
|||
|
||||
task_manager.RunQueue( this );
|
||||
|
||||
m_changed_package_types.merge( task_manager.GetChangedPackageTypes() );
|
||||
|
||||
m_sdbSizer1OK->Enable();
|
||||
m_sdbSizer1Apply->Enable();
|
||||
m_sdbSizer1Cancel->Enable();
|
||||
|
@ -472,9 +473,6 @@ void DIALOG_PCM::OnApplyChangesClicked( wxCommandEvent& event )
|
|||
|
||||
if( !m_selectedRepositoryId.IsEmpty() )
|
||||
setRepositoryData( m_selectedRepositoryId );
|
||||
|
||||
if( task_manager.ColorSettingsChanged() )
|
||||
Pgm().GetSettingsManager().ReloadColorSettings();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,6 +73,12 @@ public:
|
|||
///< Handles modification of the buttons' status
|
||||
void OnUpdateEventButtons( wxUpdateUIEvent& event );
|
||||
|
||||
///< Returns types of packages that were installed/uninstalled
|
||||
const std::unordered_set<PCM_PACKAGE_TYPE>& GetChangedPackageTypes() const
|
||||
{
|
||||
return m_changed_package_types;
|
||||
};
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Gets package data from PCM and displays it on repository tab
|
||||
|
@ -105,6 +111,7 @@ private:
|
|||
std::unordered_map<wxString, wxBitmap> m_packageBitmaps;
|
||||
std::unordered_map<wxString, wxBitmap> m_installedBitmaps;
|
||||
wxBitmap m_defaultBitmap;
|
||||
std::unordered_set<PCM_PACKAGE_TYPE> m_changed_package_types;
|
||||
|
||||
struct PENDING_ACTION
|
||||
{
|
||||
|
|
|
@ -35,8 +35,6 @@ PANEL_PCM_SETTINGS::PANEL_PCM_SETTINGS( wxWindow* parent ) : PANEL_PCM_SETTINGS_
|
|||
int minWidth = m_libPrefix->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
|
||||
|
||||
m_libPrefix->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
|
||||
|
||||
m_libHelp->SetFont( KIUI::GetInfoFont( this ).Italic() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -71,10 +71,6 @@ PANEL_PCM_SETTINGS_BASE::PANEL_PCM_SETTINGS_BASE( wxWindow* parent, wxWindowID i
|
|||
|
||||
bSizer3->Add( bSizer2, 0, wxEXPAND, 5 );
|
||||
|
||||
m_libHelp = new wxStaticText( this, wxID_ANY, _("After packages are (un)installed KiCad may need to be restarted to reflect changes in the global library table."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_libHelp->Wrap( -1 );
|
||||
bSizer3->Add( m_libHelp, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( bSizer3, 1, wxEXPAND|wxTOP|wxLEFT, 5 );
|
||||
|
||||
|
|
|
@ -673,67 +673,6 @@
|
|||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">After packages are (un)installed KiCad may need to be restarted to reflect changes in the global library table.</property>
|
||||
<property name="markup">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_libHelp</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
|
||||
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -42,7 +42,6 @@ class PANEL_PCM_SETTINGS_BASE : public wxPanel
|
|||
wxCheckBox* m_libAutoRemove;
|
||||
wxStaticText* m_staticText1;
|
||||
wxTextCtrl* m_libPrefix;
|
||||
wxStaticText* m_libHelp;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -212,17 +212,16 @@ void PCM_TASK_MANAGER::installDownloadedPackage( const PCM_PACKAGE& aPackage,
|
|||
if( extract( aFilePath.GetFullPath(), aPackage.identifier, true ) )
|
||||
{
|
||||
m_pcm->MarkInstalled( aPackage, pkgver->version, aRepositoryId );
|
||||
// TODO register libraries.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cleanup possibly partially extracted package
|
||||
deletePackageDirectories( aPackage.identifier );
|
||||
}
|
||||
}
|
||||
|
||||
if( aPackage.type == PCM_PACKAGE_TYPE::PT_COLORTHEME )
|
||||
m_color_themes_changed.store( true );
|
||||
std::unique_lock lock( m_changed_package_types_guard );
|
||||
m_changed_package_types.insert( aPackage.type );
|
||||
}
|
||||
|
||||
m_reporter->PCMReport(
|
||||
wxString::Format( _( "Removing downloaded archive '%s'." ), aFilePath.GetFullName() ),
|
||||
|
@ -431,7 +430,8 @@ void PCM_TASK_MANAGER::InstallFromFile( wxWindow* aParent, const wxString& aFile
|
|||
|
||||
aParent->Raise();
|
||||
|
||||
m_color_themes_changed.store( package.type == PCM_PACKAGE_TYPE::PT_COLORTHEME );
|
||||
std::unique_lock lock( m_changed_package_types_guard );
|
||||
m_changed_package_types.insert( package.type );
|
||||
}
|
||||
|
||||
|
||||
|
@ -560,8 +560,8 @@ void PCM_TASK_MANAGER::Uninstall( const PCM_PACKAGE& aPackage )
|
|||
|
||||
m_pcm->MarkUninstalled( aPackage );
|
||||
|
||||
if( aPackage.type == PCM_PACKAGE_TYPE::PT_COLORTHEME )
|
||||
m_color_themes_changed.store( true );
|
||||
std::unique_lock lock( m_changed_package_types_guard );
|
||||
m_changed_package_types.insert( aPackage.type );
|
||||
|
||||
m_reporter->PCMReport(
|
||||
wxString::Format( _( "Package %s uninstalled" ), aPackage.identifier ),
|
||||
|
@ -589,8 +589,6 @@ void PCM_TASK_MANAGER::RunQueue( wxWindow* aParent )
|
|||
std::condition_variable condvar;
|
||||
bool download_complete = false;
|
||||
|
||||
m_color_themes_changed.store( false );
|
||||
|
||||
std::thread download_thread(
|
||||
[&]()
|
||||
{
|
||||
|
@ -650,9 +648,3 @@ void PCM_TASK_MANAGER::RunQueue( wxWindow* aParent )
|
|||
download_thread.join();
|
||||
install_thread.join();
|
||||
}
|
||||
|
||||
|
||||
bool PCM_TASK_MANAGER::ColorSettingsChanged() const
|
||||
{
|
||||
return m_color_themes_changed.load();
|
||||
}
|
|
@ -105,9 +105,12 @@ public:
|
|||
void InstallFromFile( wxWindow* aParent, const wxString& aFilePath );
|
||||
|
||||
/**
|
||||
* @return true if color settings were installed or uninstalled by the most recent action
|
||||
* @return types of packages that were installed/uninstalled by the task manager
|
||||
*/
|
||||
bool ColorSettingsChanged() const;
|
||||
std::unordered_set<PCM_PACKAGE_TYPE>& GetChangedPackageTypes()
|
||||
{
|
||||
return m_changed_package_types;
|
||||
};
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -155,7 +158,8 @@ private:
|
|||
SYNC_QUEUE<PCM_TASK> m_download_queue;
|
||||
SYNC_QUEUE<PCM_TASK> m_install_queue;
|
||||
std::shared_ptr<PLUGIN_CONTENT_MANAGER> m_pcm;
|
||||
std::atomic_bool m_color_themes_changed;
|
||||
std::mutex m_changed_package_types_guard;
|
||||
std::unordered_set<PCM_PACKAGE_TYPE> m_changed_package_types;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <project/project_file.h>
|
||||
#include <project/project_local_settings.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <settings/kicad_settings.h>
|
||||
#include <tool/selection.h>
|
||||
#include <tool/tool_event.h>
|
||||
#include <tools/kicad_manager_actions.h>
|
||||
|
@ -900,6 +901,47 @@ int KICAD_MANAGER_CONTROL::ShowPluginManager( const TOOL_EVENT& aEvent )
|
|||
DIALOG_PCM pcm( m_frame, m_frame->GetPcm() );
|
||||
pcm.ShowModal();
|
||||
|
||||
const std::unordered_set<PCM_PACKAGE_TYPE>& changed = pcm.GetChangedPackageTypes();
|
||||
|
||||
if( changed.count( PCM_PACKAGE_TYPE::PT_PLUGIN ) )
|
||||
{
|
||||
std::string payload = "";
|
||||
m_frame->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_RELOAD_PLUGINS, payload );
|
||||
}
|
||||
|
||||
KICAD_SETTINGS* settings = Pgm().GetSettingsManager().GetAppSettings<KICAD_SETTINGS>();
|
||||
|
||||
if( changed.count( PCM_PACKAGE_TYPE::PT_LIBRARY )
|
||||
&& ( settings->m_PcmLibAutoAdd || settings->m_PcmLibAutoRemove ) )
|
||||
{
|
||||
// Reset project tables
|
||||
Prj().SetElem( PROJECT::ELEM_SYMBOL_LIB_TABLE, nullptr );
|
||||
Prj().SetElem( PROJECT::ELEM_FPTBL, nullptr );
|
||||
|
||||
KIWAY& kiway = m_frame->Kiway();
|
||||
|
||||
// Reset state containing global lib tables
|
||||
KIFACE* kiface;
|
||||
|
||||
if( kiface = kiway.KiFACE( KIWAY::FACE_SCH, false ) )
|
||||
kiface->Reset();
|
||||
|
||||
if( kiface = kiway.KiFACE( KIWAY::FACE_PCB, false ) )
|
||||
kiface->Reset();
|
||||
|
||||
// Reload lib tables
|
||||
std::string payload = "";
|
||||
|
||||
kiway.ExpressMail( FRAME_FOOTPRINT_EDITOR, MAIL_RELOAD_LIB, payload );
|
||||
kiway.ExpressMail( FRAME_FOOTPRINT_VIEWER, MAIL_RELOAD_LIB, payload );
|
||||
kiway.ExpressMail( FRAME_CVPCB, MAIL_RELOAD_LIB, payload );
|
||||
kiway.ExpressMail( FRAME_SCH_SYMBOL_EDITOR, MAIL_RELOAD_LIB, payload );
|
||||
kiway.ExpressMail( FRAME_SCH_VIEWER, MAIL_RELOAD_LIB, payload );
|
||||
}
|
||||
|
||||
if( changed.count( PCM_PACKAGE_TYPE::PT_COLORTHEME ) )
|
||||
Pgm().GetSettingsManager().ReloadColorSettings();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -663,6 +663,10 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
break;
|
||||
}
|
||||
|
||||
case MAIL_RELOAD_PLUGINS:
|
||||
GetToolManager()->RunAction( PCB_ACTIONS::pluginsReload, true );
|
||||
break;
|
||||
|
||||
// many many others.
|
||||
default:
|
||||
;
|
||||
|
|
|
@ -1130,19 +1130,8 @@ void InvokePcbLibTableEditor( KIWAY* aKiway, wxWindow* aCaller )
|
|||
}
|
||||
}
|
||||
|
||||
auto editor = (FOOTPRINT_EDIT_FRAME*) aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
|
||||
|
||||
if( editor )
|
||||
{
|
||||
editor->SyncLibraryTree( true );
|
||||
editor->RefreshLibraryTree();
|
||||
}
|
||||
|
||||
auto viewer = (FOOTPRINT_VIEWER_FRAME*) aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
|
||||
|
||||
if( viewer )
|
||||
viewer->ReCreateLibraryList();
|
||||
|
||||
std::string payload = "";
|
||||
aKiway->ExpressMail( FRAME_FOOTPRINT_EDITOR, MAIL_RELOAD_LIB, payload );
|
||||
aKiway->ExpressMail( FRAME_FOOTPRINT_VIEWER, MAIL_RELOAD_LIB, payload );
|
||||
aKiway->ExpressMail( FRAME_CVPCB, MAIL_RELOAD_LIB, payload );
|
||||
}
|
||||
|
|
|
@ -990,7 +990,7 @@ void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress )
|
|||
}
|
||||
|
||||
// Sync the LIB_TREE to the FOOTPRINT_INFO list
|
||||
adapter->Sync();
|
||||
adapter->Sync( fpTable );
|
||||
|
||||
m_treePane->GetLibTree()->Unselect();
|
||||
m_treePane->GetLibTree()->Regenerate( true );
|
||||
|
|
|
@ -359,6 +359,11 @@ void FOOTPRINT_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
|
||||
break;
|
||||
|
||||
case MAIL_RELOAD_LIB:
|
||||
SyncLibraryTree( true );
|
||||
RefreshLibraryTree();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1086,6 +1086,11 @@ void FOOTPRINT_VIEWER_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
|
||||
break;
|
||||
}
|
||||
case MAIL_RELOAD_LIB:
|
||||
{
|
||||
ReCreateLibraryList();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
;
|
||||
|
|
|
@ -68,8 +68,10 @@ bool FP_TREE_SYNCHRONIZING_ADAPTER::IsContainer( const wxDataViewItem& aItem ) c
|
|||
|
||||
#define PROGRESS_INTERVAL_MILLIS 33 // 30 FPS refresh rate
|
||||
|
||||
void FP_TREE_SYNCHRONIZING_ADAPTER::Sync()
|
||||
void FP_TREE_SYNCHRONIZING_ADAPTER::Sync( FP_LIB_TABLE* aLibs )
|
||||
{
|
||||
m_libs = aLibs;
|
||||
|
||||
// Process already stored libraries
|
||||
for( auto it = m_tree.m_Children.begin(); it != m_tree.m_Children.end(); )
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
bool IsContainer( const wxDataViewItem& aItem ) const override;
|
||||
|
||||
void Sync();
|
||||
void Sync( FP_LIB_TABLE* aLibs );
|
||||
|
||||
int GetLibrariesCount() const override;
|
||||
|
||||
|
|
|
@ -81,6 +81,8 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
|
|||
|
||||
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
|
||||
|
||||
void Reset() override;
|
||||
|
||||
void OnKifaceEnd() override;
|
||||
|
||||
wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
|
||||
|
@ -286,6 +288,8 @@ static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
|
|||
int HandleJob( JOB* aJob ) override;
|
||||
|
||||
private:
|
||||
bool loadGlobalLibTable();
|
||||
|
||||
std::unique_ptr<PCBNEW_JOBS_HANDLER> m_jobHandler;
|
||||
|
||||
} kiface( "pcbnew", KIWAY::FACE_PCB );
|
||||
|
@ -347,11 +351,28 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
|
|||
|
||||
start_common( aCtlBits );
|
||||
|
||||
if( !loadGlobalLibTable() )
|
||||
return false;
|
||||
|
||||
m_jobHandler = std::make_unique<PCBNEW_JOBS_HANDLER>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void IFACE::Reset()
|
||||
{
|
||||
loadGlobalLibTable();
|
||||
}
|
||||
|
||||
|
||||
bool IFACE::loadGlobalLibTable()
|
||||
{
|
||||
wxFileName fn = FP_LIB_TABLE::GetGlobalTableFileName();
|
||||
|
||||
if( !fn.FileExists() )
|
||||
{
|
||||
if( !( aCtlBits & KFCTL_CLI ) )
|
||||
if( !( m_start_flags & KFCTL_CLI ) )
|
||||
{
|
||||
DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG fpDialog( nullptr );
|
||||
|
||||
|
@ -382,8 +403,6 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
|
|||
}
|
||||
}
|
||||
|
||||
m_jobHandler = std::make_unique<PCBNEW_JOBS_HANDLER>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue