7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Remember open jobsets.

This commit is contained in:
Jeff Young 2025-01-02 23:43:58 +00:00
parent 49b949cec7
commit 757a16b4bf
4 changed files with 38 additions and 14 deletions

View File

@ -222,6 +222,8 @@ PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxStrin
m_params.emplace_back( new PARAM_LIST<wxString>( "net_inspector_panel.expanded_rows",
&m_NetInspectorPanel.expanded_rows, {} ) );
m_params.emplace_back( new PARAM_LIST<wxString>( "open_jobsets", &m_OpenJobSets, {} ) );
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "project.files",
[&]() -> nlohmann::json
{

View File

@ -92,6 +92,8 @@ public:
/// File based state
std::vector<PROJECT_FILE_STATE> m_files;
std::vector<wxString> m_OpenJobSets;
/**
* Board settings
*/

View File

@ -329,6 +329,12 @@ void KICAD_MANAGER_FRAME::onNotebookPageCloseRequest( wxAuiNotebookEvent& evt )
{
evt.Veto();
}
CallAfter(
[this]()
{
SaveOpenJobSetsToLocalSettings();
} );
}
else
{
@ -600,8 +606,7 @@ bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
{
wxWindow* page = m_notebook->GetPage( i );
PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page );
if( panel )
if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
{
if( !panel->GetCanClose() )
return false;
@ -649,11 +654,8 @@ void KICAD_MANAGER_FRAME::doCloseWindow()
{
wxWindow* page = m_notebook->GetPage( i );
PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page );
if( panel )
{
if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
m_notebook->DeletePage( i );
}
}
m_leftWin->Show( false );
@ -667,6 +669,22 @@ void KICAD_MANAGER_FRAME::doCloseWindow()
}
void KICAD_MANAGER_FRAME::SaveOpenJobSetsToLocalSettings()
{
PROJECT_LOCAL_SETTINGS& cfg = Prj().GetLocalSettings();
cfg.m_OpenJobSets.clear();
for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
{
if( PANEL_JOBS* jobset = dynamic_cast<PANEL_JOBS*>( m_notebook->GetPage( i ) ) )
cfg.m_OpenJobSets.emplace_back( jobset->GetFilePath() );
}
cfg.SaveToFile( Prj().GetProjectPath() );
}
void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
{
Close( true );
@ -698,8 +716,7 @@ bool KICAD_MANAGER_FRAME::CloseProject( bool aSave )
{
wxWindow* page = m_notebook->GetPage( i );
PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page );
if( panel )
if( PANEL_NOTEBOOK_BASE* panel = dynamic_cast<PANEL_NOTEBOOK_BASE*>( page ) )
{
if( panel->GetProjectTied() )
{
@ -723,10 +740,7 @@ void KICAD_MANAGER_FRAME::OpenJobsFile( const wxFileName& aFileName, bool aCreat
for( size_t i = 0; i < m_notebook->GetPageCount(); i++ )
{
wxWindow* page = m_notebook->GetPage( i );
PANEL_JOBS* panel = dynamic_cast<PANEL_JOBS*>( page );
if( panel )
if( PANEL_JOBS* panel = dynamic_cast<PANEL_JOBS*>( m_notebook->GetPage( i ) ) )
{
if( aFileName.GetFullPath() == panel->GetFilePath() )
{
@ -746,8 +760,9 @@ void KICAD_MANAGER_FRAME::OpenJobsFile( const wxFileName& aFileName, bool aCreat
PANEL_JOBS* jobPanel = new PANEL_JOBS( m_notebook, this, std::move( jobsFile ) );
jobPanel->SetProjectTied( true );
jobPanel->SetClosable( true );
m_notebook->AddPage( jobPanel, aFileName.GetFullName(),
true );
m_notebook->AddPage( jobPanel, aFileName.GetFullName(), true );
SaveOpenJobSetsToLocalSettings();
}
catch( ... )
{
@ -784,6 +799,9 @@ void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
m_leftWin->ReCreateTreePrj();
for( const wxString& jobset : Prj().GetLocalSettings().m_OpenJobSets )
OpenJobsFile( jobset );
// Rebuild the list of watched paths.
// however this is possible only when the main loop event handler is running,
// so we use it to run the rebuild function.

View File

@ -170,6 +170,8 @@ public:
void ReCreateTreePrj();
void SaveOpenJobSetsToLocalSettings();
wxWindow* GetToolCanvas() const override;
std::shared_ptr<PLUGIN_CONTENT_MANAGER> GetPcm() { return m_pcm; };