Move some language changes to a event on the frame

This commit is contained in:
Marek Roszko 2024-03-03 10:57:26 -05:00
parent 0bde79bd6c
commit 0c8e08ed58
20 changed files with 71 additions and 45 deletions

View File

@ -1190,16 +1190,12 @@ void EDA_DRAW_FRAME::ShowChangedLanguage()
{
wxAuiPaneInfo& search_pane_info = m_auimgr.GetPane( m_searchPane );
search_pane_info.Caption( _( "Search" ) );
m_searchPane->OnLanguageChange();
}
if( m_propertiesPanel )
{
wxAuiPaneInfo& properties_pane_info = m_auimgr.GetPane( m_propertiesPanel );
properties_pane_info.Caption( _( "Properties" ) );
m_propertiesPanel->OnLanguageChanged();
}
}

View File

@ -617,8 +617,12 @@ void KIWAY::SetLanguage( int aLanguage )
// so a static_cast is used.
EDA_BASE_FRAME* top = static_cast<EDA_BASE_FRAME*>( m_top );
if( top )
if ( top )
{
top->ShowChangedLanguage();
wxCommandEvent e( EDA_LANG_CHANGED );
top->GetEventHandler()->ProcessEvent( e );
}
}
#endif
@ -629,6 +633,8 @@ void KIWAY::SetLanguage( int aLanguage )
if( frame )
{
frame->ShowChangedLanguage();
wxCommandEvent e( EDA_LANG_CHANGED );
frame->GetEventHandler()->ProcessEvent( e );
}
}
}

View File

@ -24,3 +24,4 @@
#include <ui_events.h>
wxDEFINE_EVENT( EDA_EVT_UNITS_CHANGED, wxCommandEvent );
wxDEFINE_EVENT( EDA_LANG_CHANGED, wxCommandEvent );

View File

@ -141,10 +141,18 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame )
} );
aEvent.Skip();
} );
m_frame->Bind( EDA_LANG_CHANGED, &PROPERTIES_PANEL::OnLanguageChanged, this );
}
void PROPERTIES_PANEL::OnLanguageChanged()
PROPERTIES_PANEL::~PROPERTIES_PANEL()
{
m_frame->Unbind( EDA_LANG_CHANGED, &PROPERTIES_PANEL::OnLanguageChanged, this );
}
void PROPERTIES_PANEL::OnLanguageChanged( wxCommandEvent& aEvent )
{
if( m_grid->IsEditorFocused() )
m_grid->CommitChangesFromEditor();
@ -153,6 +161,8 @@ void PROPERTIES_PANEL::OnLanguageChanged()
m_displayed.clear();
UpdateData();
aEvent.Skip();
}

View File

@ -41,19 +41,12 @@ class PROPERTIES_PANEL : public wxPanel
public:
PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame );
virtual ~PROPERTIES_PANEL()
{
}
virtual ~PROPERTIES_PANEL();
virtual void UpdateData() = 0;
virtual void AfterCommit() {}
/**
* Parents will call this when the user changes the UI language
*/
virtual void LanguageChanged() {}
wxPropertyGrid* GetPropertyGrid()
{
return m_grid;
@ -74,8 +67,6 @@ public:
void SetSplitterProportion( float aProportion );
float SplitterProportion() const { return m_splitter_key_proportion; }
void OnLanguageChanged();
protected:
/**
* Generates the property grid for a given selection of items.
@ -92,6 +83,8 @@ protected:
void onCharHook( wxKeyEvent& aEvent );
void onShow( wxShowEvent& aEvent );
virtual void OnLanguageChanged( wxCommandEvent& aEvent );
/**
* Utility to fetch a property value and convert to wxVariant
* Precondition: aItem is known to have property aProperty

View File

@ -24,17 +24,20 @@
SEARCH_PANE::SEARCH_PANE( EDA_DRAW_FRAME* aFrame ) :
SEARCH_PANE_BASE( aFrame )
SEARCH_PANE_BASE( aFrame ),
m_frame( aFrame )
{
m_frame->Bind( EDA_LANG_CHANGED, &SEARCH_PANE::OnLanguageChange, this );
}
SEARCH_PANE::~SEARCH_PANE()
{
m_frame->Unbind( EDA_LANG_CHANGED, &SEARCH_PANE::OnLanguageChange, this );
}
void SEARCH_PANE::OnLanguageChange()
void SEARCH_PANE::OnLanguageChange( wxCommandEvent& aEvent )
{
m_searchCtrl1->SetDescriptiveText( _( "Search" ) );
@ -48,6 +51,8 @@ void SEARCH_PANE::OnLanguageChange()
tab->RefreshColumnNames();
m_notebook->SetPageText( i, wxGetTranslation( tab->GetSearchHandler()->GetName() ) );
}
aEvent.Skip();
}

View File

@ -1969,9 +1969,6 @@ void SCH_EDIT_FRAME::ShowChangedLanguage()
m_auimgr.Update();
m_hierarchy->UpdateHierarchyTree();
m_propertiesPanel->LanguageChanged();
m_selectionFilterPanel->OnLanguageChanged();
// status bar
UpdateMsgPanel();

View File

@ -1294,8 +1294,6 @@ void SYMBOL_EDIT_FRAME::ShowChangedLanguage()
m_treePane->GetLibTree()->ShowChangedLanguage();
m_propertiesPanel->LanguageChanged();
// status bar
UpdateMsgPanel();

View File

@ -78,6 +78,14 @@ PANEL_SCH_SELECTION_FILTER::PANEL_SCH_SELECTION_FILTER( wxWindow* aParent ) :
m_gridSizer->SetItemPosition( m_cbOtherItems, wxGBPosition( 2, 1 ) );
Thaw();
}
m_frame->Bind( EDA_LANG_CHANGED, &PANEL_SCH_SELECTION_FILTER::OnLanguageChanged, this );
}
PANEL_SCH_SELECTION_FILTER::~PANEL_SCH_SELECTION_FILTER()
{
m_frame->Unbind( EDA_LANG_CHANGED, &PANEL_SCH_SELECTION_FILTER::OnLanguageChanged, this );
}
@ -186,7 +194,7 @@ void PANEL_SCH_SELECTION_FILTER::onPopupSelection( wxCommandEvent& aEvent )
}
void PANEL_SCH_SELECTION_FILTER::OnLanguageChanged()
void PANEL_SCH_SELECTION_FILTER::OnLanguageChanged( wxCommandEvent& aEvent )
{
m_cbAllItems->SetLabel( _( "All items" ) );
m_cbLockedItems->SetLabel( _( "Locked items" ) );
@ -201,4 +209,6 @@ void PANEL_SCH_SELECTION_FILTER::OnLanguageChanged()
m_cbOtherItems->SetLabel( _( "Other items" ) );
m_cbAllItems->GetParent()->Layout();
aEvent.Skip();
}

View File

@ -33,14 +33,13 @@ class PANEL_SCH_SELECTION_FILTER : public PANEL_SCH_SELECTION_FILTER_BASE
public:
PANEL_SCH_SELECTION_FILTER( wxWindow* aParent );
~PANEL_SCH_SELECTION_FILTER() = default;
~PANEL_SCH_SELECTION_FILTER();
void SetCheckboxesFromFilter( SCH_SELECTION_FILTER_OPTIONS& aOptions );
void OnLanguageChanged();
protected:
void OnFilterChanged( wxCommandEvent& aEvent ) override;
void OnLanguageChanged( wxCommandEvent& aEvent );
private:
bool setFilterFromCheckboxes( SCH_SELECTION_FILTER_OPTIONS& aOptions );

View File

@ -207,8 +207,9 @@ void SCH_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
}
void SCH_PROPERTIES_PANEL::LanguageChanged()
void SCH_PROPERTIES_PANEL::OnLanguageChanged( wxCommandEvent& aEvent )
{
PROPERTIES_PANEL::OnLanguageChanged( aEvent );
updateFontList();
}

View File

@ -43,8 +43,6 @@ public:
void AfterCommit() override;
void LanguageChanged() override;
protected:
wxPGProperty* createPGProperty( const PROPERTY_BASE* aProperty ) const override;
@ -53,6 +51,8 @@ protected:
void valueChanging( wxPropertyGridEvent& aEvent ) override;
void valueChanged( wxPropertyGridEvent& aEvent ) override;
void OnLanguageChanged( wxCommandEvent& aEvent ) override;
///< Regenerates caches of font list property
void updateFontList();

View File

@ -28,5 +28,6 @@
#include <wx/event.h>
wxDECLARE_EXPORTED_EVENT( KICOMMON_API, EDA_EVT_UNITS_CHANGED, wxCommandEvent );
wxDECLARE_EXPORTED_EVENT( KICOMMON_API, EDA_LANG_CHANGED, wxCommandEvent );
#endif

View File

@ -64,17 +64,18 @@ public:
void OnNotebookPageChanged( wxBookCtrlEvent& aEvent ) override;
void RefreshSearch();
void OnLanguageChange();
void FocusSearch();
void ClearAllResults();
protected:
void OnLanguageChange( wxCommandEvent& aEvent );
SEARCH_PANE_TAB* GetCurrentTab() const;
private:
std::vector<SEARCH_HANDLER*> m_handlers;
std::vector<SEARCH_PANE_TAB*> m_tabs;
wxString m_lastQuery;
EDA_DRAW_FRAME* m_frame;
};
#endif

View File

@ -911,8 +911,6 @@ void FOOTPRINT_EDIT_FRAME::ShowChangedLanguage()
sf_pane_info.Caption( _( "Selection Filter" ) );
// update the layer manager
m_appearancePanel->OnLanguageChanged();
m_selectionFilterPanel->OnLanguageChanged();
UpdateUserInterface();
// Now restore the visibility:

View File

@ -1582,10 +1582,6 @@ void PCB_EDIT_FRAME::ShowChangedLanguage()
m_auimgr.GetPane( m_propertiesPanel ).Caption( _( "Properties" ) );
m_auimgr.Update();
m_appearancePanel->OnLanguageChanged();
m_selectionFilterPanel->OnLanguageChanged();
m_propertiesPanel->OnLanguageChanged();
UpdateTitle();
}

View File

@ -591,11 +591,15 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
Bind( wxEVT_COMMAND_MENU_SELECTED, &APPEARANCE_CONTROLS::OnLayerContextMenu, this,
ID_CHANGE_COLOR, ID_LAST_VALUE );
m_frame->Bind( EDA_LANG_CHANGED, &APPEARANCE_CONTROLS::OnLanguageChanged, this );
}
APPEARANCE_CONTROLS::~APPEARANCE_CONTROLS()
{
m_frame->Unbind( EDA_LANG_CHANGED, &APPEARANCE_CONTROLS::OnLanguageChanged, this );
delete m_iconProvider;
}
@ -1018,7 +1022,7 @@ void APPEARANCE_CONTROLS::OnNetGridMouseEvent( wxMouseEvent& aEvent )
}
void APPEARANCE_CONTROLS::OnLanguageChanged()
void APPEARANCE_CONTROLS::OnLanguageChanged( wxCommandEvent& aEvent )
{
m_notebook->SetPageText( 0, _( "Layers" ) );
m_notebook->SetPageText( 1, _( "Objects" ) );
@ -1042,6 +1046,8 @@ void APPEARANCE_CONTROLS::OnLanguageChanged()
Thaw();
Refresh();
aEvent.Skip();
}

View File

@ -200,8 +200,6 @@ public:
wxSize GetBestSize() const;
void OnLanguageChanged();
///< Update the panel contents from the application and board models.
void OnBoardChanged();
@ -290,6 +288,7 @@ protected:
void OnNetGridDoubleClick( wxGridEvent& event ) override;
void OnNetGridRightClick( wxGridEvent& event ) override;
void OnNetGridMouseEvent( wxMouseEvent& aEvent );
void OnLanguageChanged( wxCommandEvent& aEvent );
private:
void createControls();

View File

@ -62,6 +62,14 @@ PANEL_SELECTION_FILTER::PANEL_SELECTION_FILTER( wxWindow* aParent ) :
m_cbKeepouts->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this );
m_cbDimensions->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this );
m_cbOtherItems->Bind( wxEVT_RIGHT_DOWN, &PANEL_SELECTION_FILTER::onRightClick, this );
m_frame->Bind( EDA_LANG_CHANGED, &PANEL_SELECTION_FILTER::OnLanguageChanged, this );
}
PANEL_SELECTION_FILTER::~PANEL_SELECTION_FILTER()
{
m_frame->Unbind( EDA_LANG_CHANGED, &PANEL_SELECTION_FILTER::OnLanguageChanged, this );
}
@ -178,7 +186,7 @@ void PANEL_SELECTION_FILTER::onPopupSelection( wxCommandEvent& aEvent )
}
void PANEL_SELECTION_FILTER::OnLanguageChanged()
void PANEL_SELECTION_FILTER::OnLanguageChanged( wxCommandEvent& aEvent )
{
m_cbAllItems->SetLabel( _( "All items" ) );
m_cbLockedItems->SetLabel( _( "Locked items" ) );
@ -195,4 +203,6 @@ void PANEL_SELECTION_FILTER::OnLanguageChanged()
m_cbOtherItems->SetLabel( _( "Other items" ) );
m_cbAllItems->GetParent()->Layout();
aEvent.Skip();
}

View File

@ -33,14 +33,13 @@ class PANEL_SELECTION_FILTER : public PANEL_SELECTION_FILTER_BASE
public:
PANEL_SELECTION_FILTER( wxWindow* aParent );
~PANEL_SELECTION_FILTER() = default;
~PANEL_SELECTION_FILTER();
void SetCheckboxesFromFilter( PCB_SELECTION_FILTER_OPTIONS& aOptions );
void OnLanguageChanged();
protected:
void OnFilterChanged( wxCommandEvent& aEvent ) override;
void OnLanguageChanged( wxCommandEvent& aEvent );
private:
bool setFilterFromCheckboxes( PCB_SELECTION_FILTER_OPTIONS& aOptions );