Use the parent frame GetSettings helper rather than including for Pgm()

This commit is contained in:
Marek Roszko 2021-06-06 18:36:31 -04:00
parent 6789dac20b
commit 33bbf85a3e
12 changed files with 39 additions and 45 deletions

View File

@ -31,7 +31,6 @@
#include <symbol_editor_settings.h>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/wx_grid.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <kicad_string.h>
@ -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>();
SYMBOL_EDITOR_SETTINGS* cfg = m_editFrame->GetSettings();
if( last->GetOrientation() == PIN_LEFT || last->GetOrientation() == PIN_RIGHT )
pos.y -= Mils2iu(cfg->m_Repeat.pin_step);

View File

@ -99,7 +99,7 @@ bool DIALOG_LIB_EDIT_TEXT::TransferDataToWindow()
}
else
{
auto* cfg = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
SYMBOL_EDITOR_SETTINGS* cfg = m_parent->GetSettings();
auto* tools = m_parent->GetToolManager()->GetTool<SYMBOL_EDITOR_DRAWING_TOOLS>();
m_textSize.SetValue( Mils2iu( cfg->m_Defaults.text_size ) );

View File

@ -28,7 +28,6 @@
#include <symbol_edit_frame.h>
#include <symbol_library_manager.h>
#include <math/util.h> // for KiROUND
#include <pgm_base.h>
#include <sch_symbol.h>
#include <widgets/grid_text_button_helpers.h>
#include <widgets/wx_grid.h>
@ -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>();
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>();
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>();
SYMBOL_EDITOR_SETTINGS* settings = m_Parent->GetSettings();
int fieldID = m_fields->size();
LIB_FIELD newField( m_libEntry, fieldID );

View File

@ -31,7 +31,6 @@
#include <eeschema_settings.h>
#include <kiface_i.h>
#include <locale_io.h>
#include <pgm_base.h>
#include <plotters_specific.h>
#include <reporter.h>
#include <trace_helpers.h>
@ -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<void*>( 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<COLOR_SETTINGS*>( m_colorTheme->GetClientData( selection ) );
}

View File

@ -24,7 +24,6 @@
#include <eeschema_settings.h>
#include <symbol_edit_frame.h>
#include <symbol_editor_settings.h>
#include <pgm_base.h>
#include <sch_painter.h>
#include <settings/settings_manager.h>
#include <view/view.h>
@ -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>();
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<void*>( 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<COLOR_SETTINGS*>(
m_themeSelection->GetClientData( m_themeSelection->GetSelection() ) );
SYMBOL_EDITOR_SETTINGS* cfg = mgr.GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
SYMBOL_EDITOR_SETTINGS* cfg = mgr->GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
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<EESCHEMA_SETTINGS>();
selected = mgr.GetColorSettings( eecfg->m_ColorTheme );
EESCHEMA_SETTINGS* eecfg = mgr->GetAppSettings<EESCHEMA_SETTINGS>();
selected = mgr->GetColorSettings( eecfg->m_ColorTheme );
}
auto settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings();

View File

@ -24,7 +24,6 @@
#include <symbol_edit_frame.h>
#include <sch_painter.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <symbol_editor/symbol_editor_settings.h>
@ -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>();
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>();
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() );

View File

@ -26,6 +26,7 @@
#include <bitmaps.h>
#include <menus_helpers.h>
#include <gerbview.h>
#include "gerbview_draw_panel_gal.h"
#include <gerbview_frame.h>
#include <gerber_file_image_list.h>
#include <core/arraydim.h>
@ -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 );

View File

@ -33,7 +33,6 @@
#include <confirm.h>
#include <dialogs/panel_kicad_launcher.h>
#include <kiway.h>
#include <pgm_kicad.h>
#include <project/project_archiver.h>
#include <reporter.h>
#include <settings/settings_manager.h>
@ -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();
}

View File

@ -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<PCBNEW_SETTINGS>();
if( cfg->m_lastFootprint3dDir.IsEmpty() )
{
wxGetEnv( KICAD6_3DMODEL_DIR, &cfg->m_lastFootprint3dDir );

View File

@ -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<void*>( settings ) );

View File

@ -26,7 +26,6 @@
#include <gal/gal_display_options.h>
#include <layers_id_colors_and_visibility.h>
#include <panel_fp_editor_color_settings.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
@ -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<FOOTPRINT_EDITOR_SETTINGS>();
COLOR_SETTINGS* current = mgr.GetColorSettings( settings->m_ColorTheme );
FOOTPRINT_EDITOR_SETTINGS* settings = mgr->GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
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<FOOTPRINT_EDITOR_SETTINGS>();
SETTINGS_MANAGER* settingsMgr = m_frame->GetSettingsManager();
FOOTPRINT_EDITOR_SETTINGS* settings = settingsMgr->GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
settings->m_ColorTheme = m_currentSettings->GetFilename();
return true;

View File

@ -26,7 +26,6 @@
#include <panel_pcbnew_color_settings.h>
#include <pcbnew_settings.h>
#include <pcb_edit_frame.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <footprint_preview_panel.h>
#include <widgets/appearance_controls.h>
@ -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<PCBNEW_SETTINGS>();
COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme );
SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager();
PCBNEW_SETTINGS* app_settings = mgr->GetAppSettings<PCBNEW_SETTINGS>();
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<PCBNEW_SETTINGS>();
SETTINGS_MANAGER* settingsMgr = m_frame->GetSettingsManager();
PCBNEW_SETTINGS* app_settings = settingsMgr->GetAppSettings<PCBNEW_SETTINGS>();
app_settings->m_ColorTheme = m_currentSettings->GetFilename();
return true;