@@ -67,101 +67,119 @@ static var convertFromLegacyFormat(ValueTree s)
6767 auto * root = new DynamicObject ();
6868 var result (root);
6969
70- auto copy = [&](char const * xmlName, char const * jsonName) {
70+ auto copyInt = [&](char const * xmlName, char const * jsonName) {
7171 if (s.hasProperty (xmlName))
72- root->setProperty (jsonName, s[xmlName]);
72+ root->setProperty (jsonName, static_cast < int >( s[xmlName]) );
7373 };
74-
7574 auto copyBool = [&](char const * xmlName, char const * jsonName) {
7675 if (s.hasProperty (xmlName))
7776 root->setProperty (jsonName, static_cast <bool >(static_cast <int >(s[xmlName])));
7877 };
78+ auto copyFloat = [&](char const * xmlName, char const * jsonName) {
79+ if (s.hasProperty (xmlName))
80+ root->setProperty (jsonName, static_cast <float >(s[xmlName]));
81+ };
82+ auto copyString = [&](char const * xmlName, char const * jsonName) {
83+ if (s.hasProperty (xmlName))
84+ root->setProperty (jsonName, s[xmlName].toString ());
85+ };
7986
80- copy (" browser_path" , " browser_path" );
81- copy (" theme" , " theme" );
82- copy (" oversampling" , " oversampling" );
83- copy (" limiter_threshold" , " limiter_threshold" );
84- copy (" protected" , " protected" );
85- copy (" debug_connections" , " debug_connections" );
86- copy (" internal_synth" , " internal_synth" );
87- copy (" grid_enabled" , " grid_enabled" );
88- copy (" grid_type" , " grid_type" );
89- copy (" grid_size" , " grid_size" );
90- copy (" default_font" , " default_font" );
91- copy (" global_scale" , " global_scale" );
92- copy (" default_zoom" , " default_zoom" );
93- copy (" cpu_meter_mapping_mode" , " cpu_meter_mapping_mode" );
94- copy (" autosave_interval" , " autosave_interval" );
95- copy (" autosave_enabled" , " autosave_enabled" );
96- copy (" show_minimap" , " show_minimap" );
97- copy (" hvcc_mode" , " hvcc_mode" );
98- copy (" last_welcome_panel" , " last_welcome_panel" );
99- copyBool (" native_window" , " native_window" );
100- copyBool (" autoconnect" , " autoconnect" );
101- copyBool (" show_palettes" , " show_palettes" );
102- copyBool (" centre_resized_canvas" , " centre_resized_canvas" );
103- copyBool (" centre_sidepanel_buttons" , " centre_sidepanel_buttons" );
104- copyBool (" show_all_audio_device_rates" , " show_all_audio_device_rates" );
105- copyBool (" add_object_menu_pinned" , " add_object_menu_pinned" );
106- copyBool (" patch_downwards_only" , " patch_downwards_only" );
107- copyBool (" search_order" , " search_order" );
108- copyBool (" search_xy_show" , " search_xy_show" );
109- copyBool (" search_index_show" , " search_index_show" );
110- copyBool (" open_patches_in_window" , " open_patches_in_window" );
111- copyBool (" cmd_click_switches_mode" , " cmd_click_switches_mode" );
112- copyBool (" touch_mode" , " touch_mode" );
113-
87+ copyString (" browser_path" , " browser_path" );
88+ copyString (" theme" , " theme" );
89+ copyString (" default_font" , " default_font" );
90+
91+ copyInt (" oversampling" , " oversampling" );
92+ copyInt (" limiter_threshold" , " limiter_threshold" );
93+ copyInt (" internal_synth" , " internal_synth" );
94+ copyInt (" grid_type" , " grid_type" );
95+ copyInt (" grid_size" , " grid_size" );
96+ copyInt (" cpu_meter_mapping_mode" , " cpu_meter_mapping_mode" );
97+ copyInt (" autosave_interval" , " autosave_interval" );
98+ copyInt (" show_minimap" , " show_minimap" );
99+ copyInt (" hvcc_mode" , " hvcc_mode" );
100+ copyInt (" last_welcome_panel" , " last_welcome_panel" );
101+
102+ copyFloat (" global_scale" , " global_scale" );
103+ copyFloat (" default_zoom" , " default_zoom" );
104+
105+ copyBool (" protected" , " protected" );
106+ copyBool (" debug_connections" , " debug_connections" );
107+ copyBool (" grid_enabled" , " grid_enabled" );
108+ copyBool (" native_window" , " native_window" );
109+ copyBool (" native_file_dialog" , " native_file_dialog" );
110+ copyBool (" autoconnect" , " autoconnect" );
111+ copyBool (" show_palettes" , " show_palettes" );
112+ copyBool (" centre_resized_canvas" , " centre_resized_canvas" );
113+ copyBool (" centre_sidepanel_buttons" , " centre_sidepanel_buttons" );
114+ copyBool (" show_all_audio_device_rates" ," show_all_audio_device_rates" );
115+ copyBool (" add_object_menu_pinned" , " add_object_menu_pinned" );
116+ copyBool (" autosave_enabled" , " autosave_enabled" );
117+ copyBool (" patch_downwards_only" , " patch_downwards_only" );
118+ copyBool (" search_order" , " search_order" );
119+ copyBool (" search_xy_show" , " search_xy_show" );
120+ copyBool (" search_index_show" , " search_index_show" );
121+ copyBool (" open_patches_in_window" , " open_patches_in_window" );
122+ copyBool (" cmd_click_switches_mode" , " cmd_click_switches_mode" );
123+ copyBool (" touch_mode" , " touch_mode" );
124+
125+ // Paths
114126 Array<var> paths;
115127 if (auto pathsTree = s.getChildWithName (" Paths" ); pathsTree.isValid ())
116128 for (auto path : pathsTree)
117129 paths.add (path[" Path" ].toString ());
118130 root->setProperty (" paths" , paths);
119131
132+ // Keymap
120133 if (auto keymapTree = s.getChildWithName (" KeyMap" ); keymapTree.isValid ()) {
121134 auto keyxml = keymapTree[" keyxml" ].toString ();
122135 auto encoded = Base64::toBase64 (keyxml.toRawUTF8 (), keyxml.getNumBytesAsUTF8 ());
123136 root->setProperty (" keymap" , encoded);
124137 }
125138
139+ // Themes
126140 Array<var> themes;
127- if (auto colourThemes = s.getChildWithName (" ColourThemes" ); colourThemes.isValid ()) {
128- for (auto themeTree : colourThemes) {
141+ if (auto colourThemes = s.getChildWithName (" ColourThemes" ); colourThemes.isValid ())
142+ for (auto themeTree : colourThemes)
129143 themes.add (var (SettingsFile::xmlThemeToJson (themeTree).get ()));
130- }
131- }
132144 root->setProperty (" themes" , themes);
133145
146+ // Active themes
134147 if (auto sel = s.getChildWithName (" SelectedThemes" ); sel.isValid ()) {
135148 Array<var> active;
136149 active.add (sel[" first" ].toString ());
137150 active.add (sel[" second" ].toString ());
138151 root->setProperty (" active_themes" , active);
139152 }
153+
154+ // Recently opened
140155 Array<var> recent;
141156 if (auto recentTree = s.getChildWithName (" RecentlyOpened" ); recentTree.isValid ()) {
142157 for (auto item : recentTree) {
143158 auto * entry = new DynamicObject ();
144159 entry->setProperty (" path" , item[" Path" ].toString ());
145- entry->setProperty (" time" , item[" Time" ]);
160+ entry->setProperty (" time" , static_cast <int64>( item[" Time" ]) );
146161 recent.add (var (entry));
147162 }
148163 }
149164 root->setProperty (" recently_opened" , recent);
150165
166+ // Libraries
151167 Array<var> libraries;
152168 if (auto libTree = s.getChildWithName (" Libraries" ); libTree.isValid ())
153169 for (auto lib : libTree)
154170 libraries.add (lib[" Path" ].toString ());
155171 root->setProperty (" libraries" , libraries);
156172
173+ // Overlays
157174 if (auto overlaysTree = s.getChildWithName (" Overlays" ); overlaysTree.isValid ()) {
158175 auto * overlays = new DynamicObject ();
159- overlays->setProperty (" edit" , overlaysTree[" edit" ]);
160- overlays->setProperty (" lock" , overlaysTree[" lock" ]);
161- overlays->setProperty (" run" , overlaysTree[" run" ]);
162- overlays->setProperty (" alt" , overlaysTree[" alt" ]);
176+ overlays->setProperty (" edit" , static_cast < int >( overlaysTree[" edit" ]) );
177+ overlays->setProperty (" lock" , static_cast < int >( overlaysTree[" lock" ]) );
178+ overlays->setProperty (" run" , static_cast < int >( overlaysTree[" run" ]) );
179+ overlays->setProperty (" alt" , static_cast < int >( overlaysTree[" alt" ]) );
163180 root->setProperty (" overlays" , var (overlays));
164181 }
182+
165183 return result;
166184}
167185
0 commit comments