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" ) )
122 aJson = nlohmann::json::array();
125 aJson.push_back( item );
136 if( aJson.is_array() )
138 for(
const nlohmann::json& item : aJson )
148 [&]() -> nlohmann::json
151 nlohmann::json js = nlohmann::json::array();
155 js.push_back( nlohmann::json( { {
"name", magic_enum::enum_name( loc ) },
156 {
"contents", tb } } ) );
161 [&](
const nlohmann::json& aObj )
166 if( !aObj.is_array() )
169 for(
const auto& entry : aObj )
171 if( entry.empty() || !entry.is_object() )
174 auto loc = magic_enum::enum_cast<TOOLBAR_LOC>( entry[
"name"].get<std::string>(),
175 magic_enum::case_insensitive );
177 if( loc.has_value() )
180 std::make_pair( loc.value(),
185 nlohmann::json::array() ) );
194 if( !defaultConfig.has_value() )
235 return m_parent.AppendAction( aActionName );
241 return m_parent.AppendAction( aAction );
253 return m_parent.AppendSpacer( aSize );
259 return m_parent.AppendGroup( aGroup );
265 return m_parent.AppendControl( aControlName );
271 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/)