From eef3492fc0b514f36d9e024692ffce21a8dbcd9b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 11 Apr 2023 23:51:27 +0100 Subject: [PATCH] Make symbol/footprint trees sensitive to language change. --- common/eda_draw_frame.cpp | 4 ++-- common/lib_tree_model_adapter.cpp | 2 +- common/widgets/lib_tree.cpp | 10 ++++++++++ eeschema/symbol_editor/symbol_edit_frame.cpp | 10 ++++++++++ include/lib_tree_model_adapter.h | 10 +++++----- include/widgets/lib_tree.h | 2 ++ pcbnew/footprint_edit_frame.cpp | 2 ++ pcbnew/widgets/appearance_controls.cpp | 4 +++- 8 files changed, 35 insertions(+), 9 deletions(-) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 1d54d668f1..ff010b20c5 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -605,8 +605,8 @@ void EDA_DRAW_FRAME::DisplayGridMsg() { wxString msg; - msg.Printf( wxS( "grid %s" ), MessageTextFromValue( GetCanvas()->GetGAL()->GetGridSize().x, - false ) ); + msg.Printf( _( "grid %s" ), MessageTextFromValue( GetCanvas()->GetGAL()->GetGridSize().x, + false ) ); SetStatusText( msg, 4 ); } diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index 8bc95a3289..83a268b6d2 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -269,7 +269,7 @@ void LIB_TREE_MODEL_ADAPTER::recreateColumns() for( const wxString& colName : m_shownColumns ) { if( !m_colNameMap.count( colName ) ) - doAddColumn( colName, false ); + doAddColumn( colName, colName == wxT( "Description" ) ); } } diff --git a/common/widgets/lib_tree.cpp b/common/widgets/lib_tree.cpp index 818ddd74f7..290883a6be 100644 --- a/common/widgets/lib_tree.cpp +++ b/common/widgets/lib_tree.cpp @@ -185,6 +185,16 @@ LIB_TREE::~LIB_TREE() } +void LIB_TREE::ShowChangedLanguage() +{ + if( m_query_ctrl ) + m_query_ctrl->SetDescriptiveText( _( "Filter" ) ); + + if( m_adapter ) + m_adapter->ShowChangedLanguage(); +} + + LIB_ID LIB_TREE::GetSelectedLibId( int* aUnit ) const { wxDataViewItem sel = m_tree_ctrl->GetSelection(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 5184e530bb..8d257bb46b 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -1197,6 +1197,16 @@ void SYMBOL_EDIT_FRAME::ShowChangedLanguage() // tooltips in toolbars RecreateToolbars(); + // For some obscure reason, the AUI manager hides the first modified pane. + // So force show panes + wxAuiPaneInfo& tree_pane_info = m_auimgr.GetPane( m_treePane ); + bool tree_shown = tree_pane_info.IsShown(); + tree_pane_info.Caption( _( "Libraries" ) ); + tree_pane_info.Show( tree_shown ); + m_auimgr.Update(); + + m_treePane->GetLibTree()->ShowChangedLanguage(); + // status bar UpdateMsgPanel(); diff --git a/include/lib_tree_model_adapter.h b/include/lib_tree_model_adapter.h index 1b03c0bdc5..486f8ece86 100644 --- a/include/lib_tree_model_adapter.h +++ b/include/lib_tree_model_adapter.h @@ -181,11 +181,6 @@ public: const std::vector& aItemList, bool pinned, bool presorted ); - void AddColumn( const wxString& aHeader ) - { - doAddColumn( aHeader, false ); - } - std::vector GetAvailableColumns() const { return m_availableColumns; } std::vector GetShownColumns() const { return m_shownColumns; } @@ -303,6 +298,11 @@ public: void PinLibrary( LIB_TREE_NODE* aTreeNode ); void UnpinLibrary( LIB_TREE_NODE* aTreeNode ); + void ShowChangedLanguage() + { + recreateColumns(); + } + protected: /** * Convert #SYM_TREE_NODE -> wxDataViewItem. diff --git a/include/widgets/lib_tree.h b/include/widgets/lib_tree.h index 9be994abbe..6282b884b1 100644 --- a/include/widgets/lib_tree.h +++ b/include/widgets/lib_tree.h @@ -144,6 +144,8 @@ public: */ void FocusSearchFieldIfExists(); + void ShowChangedLanguage(); + protected: /** * Expand or collapse a node, switching it to the opposite state. diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 9c3a180e02..e4aed4c6e8 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -890,6 +890,8 @@ void FOOTPRINT_EDIT_FRAME::ShowChangedLanguage() tree_pane_info.Show( tree_shown ); m_auimgr.Update(); + m_treePane->GetLibTree()->ShowChangedLanguage(); + UpdateTitle(); } diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 73fe0dbf32..38e1a679ab 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -1005,7 +1005,9 @@ void APPEARANCE_CONTROLS::OnLanguageChanged() { m_notebook->SetPageText( 0, _( "Layers" ) ); m_notebook->SetPageText( 1, _( "Objects" ) ); - m_notebook->SetPageText( 2, _( "Nets" ) ); + + if( m_notebook->GetPageCount() >= 3 ) + m_notebook->SetPageText( 2, _( "Nets" ) ); Freeze(); rebuildLayers();