mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 18:33:45 +00:00
Fix design block panel trampling symbol chooser settings
Fixes https://gitlab.com/kicad/code/kicad/-/issues/19190
This commit is contained in:
parent
e487f19260
commit
8903a82c50
@ -127,10 +127,10 @@ LIB_TREE_NODE* LIB_TREE_MODEL_ADAPTER::ToNode( wxDataViewItem aItem )
|
||||
|
||||
LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent,
|
||||
const wxString& aPinnedKey,
|
||||
APP_SETTINGS_BASE* aCfg ) :
|
||||
APP_SETTINGS_BASE::LIB_TREE& aSettingsStruct ) :
|
||||
m_widget( nullptr ),
|
||||
m_parent( aParent ),
|
||||
m_cfg( aCfg ),
|
||||
m_cfg( aSettingsStruct ),
|
||||
m_sort_mode( BEST_MATCH ),
|
||||
m_show_units( true ),
|
||||
m_preselect_unit( 0 ),
|
||||
@ -143,10 +143,10 @@ LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent,
|
||||
|
||||
m_availableColumns = { _HKI( "Item" ), _HKI( "Description" ) };
|
||||
|
||||
for( const std::pair<const wxString, int>& pair : m_cfg->m_LibTree.column_widths )
|
||||
for( const std::pair<const wxString, int>& pair : m_cfg.column_widths )
|
||||
m_colWidths[pair.first] = pair.second;
|
||||
|
||||
m_shownColumns = m_cfg->m_LibTree.columns;
|
||||
m_shownColumns = m_cfg.columns;
|
||||
|
||||
if( m_shownColumns.empty() )
|
||||
m_shownColumns = { _HKI( "Item" ), _HKI( "Description" ) };
|
||||
@ -196,13 +196,13 @@ void LIB_TREE_MODEL_ADAPTER::SaveSettings()
|
||||
{
|
||||
if( m_widget )
|
||||
{
|
||||
m_cfg->m_LibTree.columns = GetShownColumns();
|
||||
m_cfg->m_LibTree.column_widths.clear();
|
||||
m_cfg.columns = GetShownColumns();
|
||||
m_cfg.column_widths.clear();
|
||||
|
||||
for( const std::pair<const wxString, wxDataViewColumn*>& pair : m_colNameMap )
|
||||
m_cfg->m_LibTree.column_widths[pair.first] = pair.second->GetWidth();
|
||||
m_cfg.column_widths[pair.first] = pair.second->GetWidth();
|
||||
|
||||
m_cfg->m_LibTree.open_libs = GetOpenLibs();
|
||||
m_cfg.open_libs = GetOpenLibs();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,18 +34,18 @@
|
||||
#include <tools/sch_design_block_control.h>
|
||||
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
|
||||
DESIGN_BLOCK_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs )
|
||||
DESIGN_BLOCK_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs,
|
||||
APP_SETTINGS_BASE::LIB_TREE& aSettings )
|
||||
{
|
||||
auto* adapter = new DESIGN_BLOCK_TREE_MODEL_ADAPTER( aParent, aLibs );
|
||||
auto* adapter = new DESIGN_BLOCK_TREE_MODEL_ADAPTER( aParent, aLibs, aSettings );
|
||||
adapter->m_frame = aParent;
|
||||
return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
|
||||
}
|
||||
|
||||
|
||||
DESIGN_BLOCK_TREE_MODEL_ADAPTER::DESIGN_BLOCK_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent,
|
||||
LIB_TABLE* aLibs ) :
|
||||
LIB_TREE_MODEL_ADAPTER( aParent, wxT( "pinned_design_block_libs" ),
|
||||
Kiface().KifaceSettings() ),
|
||||
DESIGN_BLOCK_TREE_MODEL_ADAPTER::DESIGN_BLOCK_TREE_MODEL_ADAPTER(
|
||||
EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs, APP_SETTINGS_BASE::LIB_TREE& aSettings ) :
|
||||
LIB_TREE_MODEL_ADAPTER( aParent, wxT( "pinned_design_block_libs" ), aSettings ),
|
||||
m_libs( (DESIGN_BLOCK_LIB_TABLE*) aLibs ),
|
||||
m_frame( aParent )
|
||||
{
|
||||
|
@ -34,7 +34,8 @@ public:
|
||||
* @param aLibs library set from which parts will be loaded
|
||||
*/
|
||||
static wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Create( EDA_BASE_FRAME* aParent,
|
||||
LIB_TABLE* aLibs );
|
||||
LIB_TABLE* aLibs,
|
||||
APP_SETTINGS_BASE::LIB_TREE& aSettings );
|
||||
|
||||
void AddLibraries( EDA_BASE_FRAME* aParent );
|
||||
void ClearLibraries();
|
||||
@ -47,7 +48,8 @@ protected:
|
||||
/**
|
||||
* Constructor; takes a set of libraries to be included in the search.
|
||||
*/
|
||||
DESIGN_BLOCK_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs );
|
||||
DESIGN_BLOCK_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs,
|
||||
APP_SETTINGS_BASE::LIB_TREE& aSettings );
|
||||
|
||||
std::vector<LIB_TREE_ITEM*> getDesignBlocks( EDA_BASE_FRAME* aParent,
|
||||
const wxString& aLibName );
|
||||
|
@ -677,6 +677,35 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
|
||||
m_params.emplace_back( new PARAM<bool>( "design_block_chooser.keep_annotations",
|
||||
&m_DesignBlockChooserPanel.keep_annotations, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>(
|
||||
"design_block_chooser.lib_tree.column_widths",
|
||||
[&]() -> nlohmann::json
|
||||
{
|
||||
nlohmann::json ret = {};
|
||||
|
||||
for( const auto& [name, width] : m_DesignBlockChooserPanel.tree.column_widths )
|
||||
ret[std::string( name.ToUTF8() )] = width;
|
||||
|
||||
return ret;
|
||||
},
|
||||
[&]( const nlohmann::json& aJson )
|
||||
{
|
||||
if( !aJson.is_object() )
|
||||
return;
|
||||
|
||||
m_DesignBlockChooserPanel.tree.column_widths.clear();
|
||||
|
||||
for( const auto& entry : aJson.items() )
|
||||
{
|
||||
if( !entry.value().is_number_integer() )
|
||||
continue;
|
||||
|
||||
m_DesignBlockChooserPanel.tree.column_widths[ entry.key() ] =
|
||||
entry.value().get<int>();
|
||||
}
|
||||
},
|
||||
{} ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( "import_graphics.interactive_placement",
|
||||
&m_ImportGraphics.interactive_placement, true ) );
|
||||
|
||||
|
@ -286,6 +286,9 @@ public:
|
||||
bool repeated_placement;
|
||||
bool place_as_sheet;
|
||||
bool keep_annotations;
|
||||
|
||||
// For saving tree columns and widths
|
||||
LIB_TREE tree;
|
||||
};
|
||||
|
||||
struct DIALOG_IMPORT_GRAPHICS
|
||||
|
@ -50,7 +50,8 @@ SYMBOL_TREE_MODEL_ADAPTER::Create( SCH_BASE_FRAME* aParent, LIB_TABLE* aLibs )
|
||||
|
||||
|
||||
SYMBOL_TREE_MODEL_ADAPTER::SYMBOL_TREE_MODEL_ADAPTER( SCH_BASE_FRAME* aParent, LIB_TABLE* aLibs ) :
|
||||
LIB_TREE_MODEL_ADAPTER( aParent, "pinned_symbol_libs", aParent->GetViewerSettingsBase() ),
|
||||
LIB_TREE_MODEL_ADAPTER( aParent, "pinned_symbol_libs",
|
||||
aParent->GetViewerSettingsBase()->m_LibTree ),
|
||||
m_libs( (SYMBOL_LIB_TABLE*) aLibs )
|
||||
{
|
||||
// Symbols may have different value from name
|
||||
|
@ -46,7 +46,8 @@ SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( SYMBOL_EDIT_FRAME* aParent,
|
||||
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER::SYMBOL_TREE_SYNCHRONIZING_ADAPTER( SYMBOL_EDIT_FRAME* aParent,
|
||||
SYMBOL_LIBRARY_MANAGER* aLibMgr ) :
|
||||
LIB_TREE_MODEL_ADAPTER( aParent, "pinned_symbol_libs", aParent->GetViewerSettingsBase() ),
|
||||
LIB_TREE_MODEL_ADAPTER( aParent, "pinned_symbol_libs",
|
||||
aParent->GetViewerSettingsBase()->m_LibTree ),
|
||||
m_frame( aParent ),
|
||||
m_libMgr( aLibMgr ),
|
||||
m_lastSyncHash( -1 )
|
||||
|
@ -81,7 +81,8 @@ PANEL_DESIGN_BLOCK_CHOOSER::PANEL_DESIGN_BLOCK_CHOOSER( SCH_EDIT_FRAME* aFrame,
|
||||
if( DESIGN_BLOCK_LIB_TABLE::GetGlobalList().GetErrorCount() )
|
||||
displayErrors( aFrame );
|
||||
|
||||
m_adapter = DESIGN_BLOCK_TREE_MODEL_ADAPTER::Create( m_frame, libs );
|
||||
m_adapter = DESIGN_BLOCK_TREE_MODEL_ADAPTER::Create( m_frame, libs,
|
||||
m_frame->eeconfig()->m_DesignBlockChooserPanel.tree );
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Construct the actual panel
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <eda_base_frame.h>
|
||||
#include <lib_id.h>
|
||||
#include <lib_tree_model.h>
|
||||
#include <settings/app_settings.h>
|
||||
#include <wx/hashmap.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/headerctrl.h>
|
||||
@ -94,7 +95,7 @@
|
||||
|
||||
#include <project.h>
|
||||
|
||||
class APP_SETTINGS_BASE;
|
||||
;
|
||||
class TOOL_INTERACTIVE;
|
||||
class EDA_BASE_FRAME;
|
||||
|
||||
@ -338,10 +339,10 @@ protected:
|
||||
*
|
||||
* @param aParent is the parent frame
|
||||
* @param aPinnedKey is the key to load the pinned libraries list from the project file
|
||||
* @param aCfg app settings for the specific editor
|
||||
* @param aSettingsStruct is the settings structure to load column visibility settings from
|
||||
*/
|
||||
LIB_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, const wxString& aPinnedKey,
|
||||
APP_SETTINGS_BASE* aCfg );
|
||||
APP_SETTINGS_BASE::LIB_TREE& aSettingsStruct );
|
||||
|
||||
LIB_TREE_NODE_LIBRARY& DoAddLibraryNode( const wxString& aNodeName, const wxString& aDesc,
|
||||
bool pinned );
|
||||
@ -426,7 +427,7 @@ protected:
|
||||
|
||||
private:
|
||||
EDA_BASE_FRAME* m_parent;
|
||||
APP_SETTINGS_BASE* m_cfg;
|
||||
APP_SETTINGS_BASE::LIB_TREE& m_cfg;
|
||||
|
||||
SORT_MODE m_sort_mode;
|
||||
bool m_show_units;
|
||||
|
@ -42,7 +42,7 @@ FP_TREE_MODEL_ADAPTER::Create( PCB_BASE_FRAME* aParent, LIB_TABLE* aLibs )
|
||||
|
||||
FP_TREE_MODEL_ADAPTER::FP_TREE_MODEL_ADAPTER( PCB_BASE_FRAME* aParent, LIB_TABLE* aLibs ) :
|
||||
LIB_TREE_MODEL_ADAPTER( aParent, wxT( "pinned_footprint_libs" ),
|
||||
aParent->GetViewerSettingsBase() ),
|
||||
aParent->GetViewerSettingsBase()->m_LibTree ),
|
||||
m_libs( (FP_LIB_TABLE*) aLibs )
|
||||
{}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user