21#include <magic_enum.hpp>
33 aJson = { {
"type", magic_enum::enum_name( aItem.
m_Type ) } };
42 aJson[
"size"] = aItem.
m_Size;
56 nlohmann::json grpItems = nlohmann::json::array();
59 grpItems.push_back( it );
61 aJson[
"group_items"] = grpItems;
73 if( aJson.contains(
"type" ) )
75 auto type = magic_enum::enum_cast<TOOLBAR_ITEM_TYPE>( aJson[
"type"].get<std::string>(),
76 magic_enum::case_insensitive );
78 if( type.has_value() )
79 aItem.
m_Type = type.value();
89 if( aJson.contains(
"size" ) )
90 aItem.
m_Size = aJson[
"size"].get<
int>();
95 if( aJson.contains(
"name" ) )
101 if( aJson.contains(
"name" ) )
107 if( aJson.contains(
"group_name" ) )
108 aItem.
m_GroupName = aJson[
"group_name"].get<wxString>();
110 if( aJson.contains(
"group_items" ) )
112 for(
const nlohmann::json& it : aJson.at(
"group_items" ) )
123 aJson = nlohmann::json::array();
126 aJson.push_back( item );
137 if( aJson.is_array() )
139 for(
const nlohmann::json& item : aJson )
149 [&]() -> nlohmann::json
152 nlohmann::json js = nlohmann::json::array();
156 js.push_back( nlohmann::json( { {
"name", magic_enum::enum_name( loc ) },
157 {
"contents", tb } } ) );
162 [&](
const nlohmann::json& aObj )
167 if( !aObj.is_array() )
170 for(
const auto& entry : aObj )
172 if( entry.empty() || !entry.is_object() )
175 auto loc = magic_enum::enum_cast<TOOLBAR_LOC>( entry[
"name"].get<std::string>(),
176 magic_enum::case_insensitive );
178 if( loc.has_value() )
180 m_toolbars.emplace( std::make_pair( loc.value(),
185 nlohmann::json::array() ) );
194 if( !defaultConfig.has_value() )
234 return m_parent.AppendAction( aActionName );
240 return m_parent.AppendAction( aAction );
252 return m_parent.AppendSpacer( aSize );
258 return m_parent.AppendGroup( aGroup );
264 return m_parent.AppendControl( aControlName );
270 return m_parent.AppendControl( aControl );
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
JSON_SETTINGS(const wxString &aFilename, SETTINGS_LOC aLocation, int aSchemaVersion)
Like a normal param, but with custom getter and setter functions.
@ TOOLBARS
The toolbar directory (e.g. ~/.config/kicad/toolbars/)