From 33bbf85a3e54b918442dc7d02ed359d8d3f35508 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sun, 6 Jun 2021 18:36:31 -0400 Subject: [PATCH] Use the parent frame GetSettings helper rather than including for Pgm() --- eeschema/dialogs/dialog_lib_edit_pin_table.cpp | 3 +-- eeschema/dialogs/dialog_lib_edit_text.cpp | 2 +- eeschema/dialogs/dialog_lib_symbol_properties.cpp | 7 +++---- eeschema/dialogs/dialog_plot_schematic.cpp | 5 ++--- eeschema/dialogs/panel_sym_color_settings.cpp | 15 +++++++-------- eeschema/dialogs/panel_sym_editing_options.cpp | 5 ++--- gerbview/widgets/gerbview_layer_widget.cpp | 7 ++++--- kicad/files-io.cpp | 7 +++---- pcbnew/dialogs/dialog_footprint_properties.cpp | 5 +++-- pcbnew/dialogs/dialog_print_pcbnew.cpp | 2 +- pcbnew/dialogs/panel_fp_editor_color_settings.cpp | 15 +++++++-------- pcbnew/dialogs/panel_pcbnew_color_settings.cpp | 11 +++++------ 12 files changed, 39 insertions(+), 45 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 600587b100..127fe07a86 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -605,7 +604,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow( wxCommandEvent& event ) wxPoint pos = last->GetPosition(); - auto* cfg = Pgm().GetSettingsManager().GetAppSettings(); + SYMBOL_EDITOR_SETTINGS* cfg = m_editFrame->GetSettings(); if( last->GetOrientation() == PIN_LEFT || last->GetOrientation() == PIN_RIGHT ) pos.y -= Mils2iu(cfg->m_Repeat.pin_step); diff --git a/eeschema/dialogs/dialog_lib_edit_text.cpp b/eeschema/dialogs/dialog_lib_edit_text.cpp index 0b4e569e6e..8091f7d0b5 100644 --- a/eeschema/dialogs/dialog_lib_edit_text.cpp +++ b/eeschema/dialogs/dialog_lib_edit_text.cpp @@ -99,7 +99,7 @@ bool DIALOG_LIB_EDIT_TEXT::TransferDataToWindow() } else { - auto* cfg = Pgm().GetSettingsManager().GetAppSettings(); + SYMBOL_EDITOR_SETTINGS* cfg = m_parent->GetSettings(); auto* tools = m_parent->GetToolManager()->GetTool(); m_textSize.SetValue( Mils2iu( cfg->m_Defaults.text_size ) ); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index 3fd62cc974..bf4bd07dc4 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -28,7 +28,6 @@ #include #include #include // for KiROUND -#include #include #include #include @@ -67,7 +66,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES( SYMBOL_EDIT_FRAME* a m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) ); // Show/hide columns according to the user's preference - auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + SYMBOL_EDITOR_SETTINGS* cfg = m_Parent->GetSettings(); m_grid->ShowHideColumns( cfg->m_EditComponentVisibleColumns ); wxGridCellAttr* attr = new wxGridCellAttr; @@ -129,7 +128,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES::~DIALOG_LIB_SYMBOL_PROPERTIES() { m_lastOpenedPage = m_NoteBook->GetSelection( ); - auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + SYMBOL_EDITOR_SETTINGS* cfg = m_Parent->GetSettings(); cfg->m_EditComponentVisibleColumns = m_grid->GetShownColumns(); // Prevents crash bug in wxGrid's d'tor @@ -465,7 +464,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event ) if( !m_grid->CommitPendingChanges() ) return; - auto* settings = Pgm().GetSettingsManager().GetAppSettings(); + SYMBOL_EDITOR_SETTINGS* settings = m_Parent->GetSettings(); int fieldID = m_fields->size(); LIB_FIELD newField( m_libEntry, fieldID ); diff --git a/eeschema/dialogs/dialog_plot_schematic.cpp b/eeschema/dialogs/dialog_plot_schematic.cpp index 4efa236b25..c190804771 100644 --- a/eeschema/dialogs/dialog_plot_schematic.cpp +++ b/eeschema/dialogs/dialog_plot_schematic.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -127,7 +126,7 @@ void DIALOG_PLOT_SCHEMATIC::initDlg() if( cfg ) { - for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() ) + for( COLOR_SETTINGS* settings : m_parent->GetSettingsManager()->GetColorSettingsList() ) { int idx = m_colorTheme->Append( settings->GetName(), static_cast( settings ) ); @@ -374,7 +373,7 @@ COLOR_SETTINGS* DIALOG_PLOT_SCHEMATIC::getColorSettings() int selection = m_colorTheme->GetSelection(); if( selection < 0 ) - return Pgm().GetSettingsManager().GetColorSettings( "_builtin_default" ); + return m_parent->GetSettingsManager()->GetColorSettings( "_builtin_default" ); return static_cast( m_colorTheme->GetClientData( selection ) ); } diff --git a/eeschema/dialogs/panel_sym_color_settings.cpp b/eeschema/dialogs/panel_sym_color_settings.cpp index e27e6c7866..db102b9ded 100644 --- a/eeschema/dialogs/panel_sym_color_settings.cpp +++ b/eeschema/dialogs/panel_sym_color_settings.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -41,11 +40,11 @@ PANEL_SYM_COLOR_SETTINGS::PANEL_SYM_COLOR_SETTINGS( SYMBOL_EDIT_FRAME* aFrame, bool PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow() { - auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + SYMBOL_EDITOR_SETTINGS* cfg = m_frame->GetSettings(); m_useEeschemaTheme->SetValue( cfg->m_UseEeschemaColorSettings ); - COLOR_SETTINGS* current = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme ); + COLOR_SETTINGS* current = m_frame->GetSettingsManager()->GetColorSettings( cfg->m_ColorTheme ); int width = 0; int height = 0; @@ -53,7 +52,7 @@ bool PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow() m_themeSelection->Clear(); - for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() ) + for( COLOR_SETTINGS* settings : m_frame->GetSettingsManager()->GetColorSettingsList() ) { int pos = m_themeSelection->Append( settings->GetName(), static_cast( settings ) ); @@ -77,12 +76,12 @@ bool PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow() bool PANEL_SYM_COLOR_SETTINGS::TransferDataFromWindow() { - SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager(); auto selected = static_cast( m_themeSelection->GetClientData( m_themeSelection->GetSelection() ) ); - SYMBOL_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); + SYMBOL_EDITOR_SETTINGS* cfg = mgr->GetAppSettings(); cfg->m_UseEeschemaColorSettings = m_useEeschemaTheme->GetValue(); @@ -91,8 +90,8 @@ bool PANEL_SYM_COLOR_SETTINGS::TransferDataFromWindow() if( cfg->m_UseEeschemaColorSettings ) { - EESCHEMA_SETTINGS* eecfg = mgr.GetAppSettings(); - selected = mgr.GetColorSettings( eecfg->m_ColorTheme ); + EESCHEMA_SETTINGS* eecfg = mgr->GetAppSettings(); + selected = mgr->GetColorSettings( eecfg->m_ColorTheme ); } auto settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings(); diff --git a/eeschema/dialogs/panel_sym_editing_options.cpp b/eeschema/dialogs/panel_sym_editing_options.cpp index 5a2b71b054..5f69e7e95d 100644 --- a/eeschema/dialogs/panel_sym_editing_options.cpp +++ b/eeschema/dialogs/panel_sym_editing_options.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -47,7 +46,7 @@ PANEL_SYM_EDITING_OPTIONS::PANEL_SYM_EDITING_OPTIONS( SYMBOL_EDIT_FRAME* aFrame, bool PANEL_SYM_EDITING_OPTIONS::TransferDataToWindow() { - auto* settings = Pgm().GetSettingsManager().GetAppSettings(); + SYMBOL_EDITOR_SETTINGS* settings = m_frame->GetSettings(); m_lineWidth.SetValue( Mils2iu( settings->m_Defaults.line_width ) ); m_textSize.SetValue( Mils2iu( settings->m_Defaults.text_size ) ); @@ -67,7 +66,7 @@ bool PANEL_SYM_EDITING_OPTIONS::TransferDataToWindow() bool PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow() { - auto* settings = Pgm().GetSettingsManager().GetAppSettings(); + SYMBOL_EDITOR_SETTINGS* settings = m_frame->GetSettings(); settings->m_Defaults.line_width = Iu2Mils( (int) m_lineWidth.GetValue() ); settings->m_Defaults.text_size = Iu2Mils( (int) m_textSize.GetValue() ); diff --git a/gerbview/widgets/gerbview_layer_widget.cpp b/gerbview/widgets/gerbview_layer_widget.cpp index 1632286cb1..0058f33873 100644 --- a/gerbview/widgets/gerbview_layer_widget.cpp +++ b/gerbview/widgets/gerbview_layer_widget.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "gerbview_draw_panel_gal.h" #include #include #include @@ -255,7 +256,7 @@ void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor ) myframe->m_SelLayerBox->ResyncBitmapOnly(); KIGFX::VIEW* view = myframe->GetCanvas()->GetView(); - auto settings = Pgm().GetSettingsManager().GetColorSettings(); + auto settings = myframe->GetSettingsManager()->GetColorSettings(); view->GetPainter()->GetSettings()->LoadColors( settings ); view->UpdateLayerColor( GERBER_DRAW_LAYER( aLayer ) ); @@ -301,13 +302,13 @@ void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFin myframe->GetCanvas()->Refresh(); } -#include "gerbview_draw_panel_gal.h" + void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor ) { myframe->SetVisibleElementColor( aId, aColor ); auto view = myframe->GetCanvas()->GetView(); - COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings(); + COLOR_SETTINGS* settings = myframe->GetSettingsManager()->GetColorSettings(); view->GetPainter()->GetSettings()->LoadColors( settings ); view->UpdateLayerColor( aId ); diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp index 82974555d0..5eee868a0f 100644 --- a/kicad/files-io.cpp +++ b/kicad/files-io.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -99,10 +98,10 @@ void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event ) { wxString prjPath = Prj().GetProjectFullName(); - SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + SETTINGS_MANAGER* mgr = GetSettingsManager(); - mgr.UnloadProject( &Prj(), false ); - mgr.LoadProject( prjPath ); + mgr->UnloadProject( &Prj(), false ); + mgr->LoadProject( prjPath ); RefreshProjectTree(); } diff --git a/pcbnew/dialogs/dialog_footprint_properties.cpp b/pcbnew/dialogs/dialog_footprint_properties.cpp index 08fed7ebc4..bb1e9499e5 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties.cpp @@ -93,12 +93,13 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) ); m_modelsGrid->PushEventHandler( new GRID_TRICKS( m_modelsGrid ) ); + PCBNEW_SETTINGS* cfg = m_frame->GetPcbNewSettings(); + // Show/hide text item columns according to the user's preference - m_itemsGrid->ShowHideColumns( m_frame->GetPcbNewSettings()->m_FootprintTextShownColumns ); + m_itemsGrid->ShowHideColumns( cfg->m_FootprintTextShownColumns ); // Set up the 3D models grid // Path selector - PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); if( cfg->m_lastFootprint3dDir.IsEmpty() ) { wxGetEnv( KICAD6_3DMODEL_DIR, &cfg->m_lastFootprint3dDir ); diff --git a/pcbnew/dialogs/dialog_print_pcbnew.cpp b/pcbnew/dialogs/dialog_print_pcbnew.cpp index 8d4a6dc82e..864f08a6f7 100644 --- a/pcbnew/dialogs/dialog_print_pcbnew.cpp +++ b/pcbnew/dialogs/dialog_print_pcbnew.cpp @@ -165,7 +165,7 @@ bool DIALOG_PRINT_PCBNEW::TransferDataToWindow() wxString target = cfg->m_Printing.use_theme ? cfg->m_Printing.color_theme : cfg->m_ColorTheme; - for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() ) + for( COLOR_SETTINGS* settings : m_parent->GetSettingsManager()->GetColorSettingsList() ) { int pos = m_colorTheme->Append( settings->GetName(), static_cast( settings ) ); diff --git a/pcbnew/dialogs/panel_fp_editor_color_settings.cpp b/pcbnew/dialogs/panel_fp_editor_color_settings.cpp index 3fcfd353fe..8ece7e9472 100644 --- a/pcbnew/dialogs/panel_fp_editor_color_settings.cpp +++ b/pcbnew/dialogs/panel_fp_editor_color_settings.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include @@ -42,20 +41,20 @@ PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS( FOOTPRINT_EDIT_F m_colorNamespace = "board"; - SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager(); - FOOTPRINT_EDITOR_SETTINGS* settings = mgr.GetAppSettings(); - COLOR_SETTINGS* current = mgr.GetColorSettings( settings->m_ColorTheme ); + FOOTPRINT_EDITOR_SETTINGS* settings = mgr->GetAppSettings(); + COLOR_SETTINGS* current = mgr->GetColorSettings( settings->m_ColorTheme ); // Store the current settings before reloading below current->Store(); - mgr.SaveColorSettings( current, "board" ); + mgr->SaveColorSettings( current, "board" ); m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() ); m_currentSettings = new COLOR_SETTINGS( *current ); - mgr.ReloadColorSettings(); + mgr->ReloadColorSettings(); createThemeList( settings->m_ColorTheme ); m_validLayers.push_back( F_Cu ); @@ -94,8 +93,8 @@ PANEL_FP_EDITOR_COLOR_SETTINGS::~PANEL_FP_EDITOR_COLOR_SETTINGS() bool PANEL_FP_EDITOR_COLOR_SETTINGS::TransferDataFromWindow() { - SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager(); - FOOTPRINT_EDITOR_SETTINGS* settings = settingsMgr.GetAppSettings(); + SETTINGS_MANAGER* settingsMgr = m_frame->GetSettingsManager(); + FOOTPRINT_EDITOR_SETTINGS* settings = settingsMgr->GetAppSettings(); settings->m_ColorTheme = m_currentSettings->GetFilename(); return true; diff --git a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp index b0c42cf576..57a2f3bd72 100644 --- a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -381,9 +380,9 @@ PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS( PCB_EDIT_FRAME* aFrame { m_colorNamespace = "board"; - SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - PCBNEW_SETTINGS* app_settings = mgr.GetAppSettings(); - COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme ); + SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager(); + PCBNEW_SETTINGS* app_settings = mgr->GetAppSettings(); + COLOR_SETTINGS* current = mgr->GetColorSettings( app_settings->m_ColorTheme ); // Saved theme doesn't exist? Reset to default if( current->GetFilename() != app_settings->m_ColorTheme ) @@ -435,8 +434,8 @@ PANEL_PCBNEW_COLOR_SETTINGS::~PANEL_PCBNEW_COLOR_SETTINGS() bool PANEL_PCBNEW_COLOR_SETTINGS::TransferDataFromWindow() { - SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager(); - PCBNEW_SETTINGS* app_settings = settingsMgr.GetAppSettings(); + SETTINGS_MANAGER* settingsMgr = m_frame->GetSettingsManager(); + PCBNEW_SETTINGS* app_settings = settingsMgr->GetAppSettings(); app_settings->m_ColorTheme = m_currentSettings->GetFilename(); return true;