diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 6d32d0eac9..41ed83c394 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -57,6 +57,7 @@ #include <tool/common_control.h> #include <tool/tool_manager.h> #include <tool/tool_dispatcher.h> +#include <tool/ui/toolbar_configuration.h> #include <trace_helpers.h> #include <widgets/paged_dialog.h> #include <widgets/wx_busy_indicator.h> @@ -517,11 +518,37 @@ ACTION_TOOLBAR_CONTROL_FACTORY* EDA_BASE_FRAME::GetCustomToolbarControlFactory( void EDA_BASE_FRAME::configureToolbars() { - // Get the default toolbar config for the frame - m_tbConfigLeft = DefaultLeftToolbarConfig(); - m_tbConfigRight = DefaultRightToolbarConfig(); - m_tbConfigTopAux = DefaultTopAuxToolbarConfig(); - m_tbConfigTopMain = DefaultTopMainToolbarConfig(); + APP_SETTINGS_BASE* cfg = config(); + + if( cfg && cfg->m_CustomToolbars ) + { + // Get the custom toolbar config + TOOLBAR_SETTINGS tb( cfg->GetFilename() + "-toolbars" ); + + tb.LoadFromFile( SETTINGS_MANAGER::GetToolbarSettingsPath() ); + + for( auto t : tb.m_Toolbars ) + { + if( t.first == "left" ) + m_tbConfigLeft = t.second; + else if( t.first == "right" ) + m_tbConfigRight = t.second; + else if( t.first == "top_aux" ) + m_tbConfigTopAux = t.second; + else if( t.first == "top_main" ) + m_tbConfigTopMain = t.second; + else + wxASSERT_MSG( false, wxString::Format( "Unknown toolbar: '%s'", t.first ) ); + } + } + else + { + // Get the default toolbar config for the frame + m_tbConfigLeft = DefaultLeftToolbarConfig(); + m_tbConfigRight = DefaultRightToolbarConfig(); + m_tbConfigTopAux = DefaultTopAuxToolbarConfig(); + m_tbConfigTopMain = DefaultTopMainToolbarConfig(); + } } diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index 23a3b793f1..649e7abd5b 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -43,6 +43,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV m_System(), m_Plugins(), m_Window(), + m_CustomToolbars( false ), m_appSettingsSchemaVersion( aSchemaVersion ) { // Make Coverity happy: @@ -205,6 +206,9 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV m_params.emplace_back( new PARAM<wxString>( "appearance.color_theme", &m_ColorTheme, COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT ) ); + m_params.emplace_back( new PARAM<bool>( "appearance.custom_toolbars", + &m_CustomToolbars, false ) ); + addParamsForWindow( &m_Window, "window" ); m_params.emplace_back( new PARAM<bool>( "cross_probing.on_selection", diff --git a/include/settings/app_settings.h b/include/settings/app_settings.h index 15a6c27fcd..390072f590 100644 --- a/include/settings/app_settings.h +++ b/include/settings/app_settings.h @@ -198,6 +198,9 @@ public: /// Active color theme name. wxString m_ColorTheme; + /// Use custom toolbars + bool m_CustomToolbars; + ///! Local schema version for common app settings. int m_appSettingsSchemaVersion; diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 72e87e6ca3..12f56cb1f3 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -454,6 +454,7 @@ void PCB_EDIT_FRAME::configureToolbars() _( "Region to hold the IPC/Scripting action buttons" ), pluginControlFactory ); +/* TOOLBAR_SETTINGS tb( "pcbnew-toolbars" ); if( m_tbConfigLeft.has_value() ) @@ -469,6 +470,7 @@ void PCB_EDIT_FRAME::configureToolbars() tb.m_Toolbars.emplace( "top_main", m_tbConfigTopMain.value() ); tb.SaveToFile( SETTINGS_MANAGER::GetToolbarSettingsPath(), true ); + */ }