@@ -1116,7 +1116,41 @@ bool Configurator::Load() {
11161116 // TAB_LAYERS_PATHS
11171117 if (json_interface_object.value (GetToken (TAB_LAYERS_PATHS)) != QJsonValue::Undefined) {
11181118 const QJsonObject& json_object = json_interface_object.value (GetToken (TAB_LAYERS_PATHS)).toObject ();
1119- (void )json_object;
1119+ if (json_object.value (" last_driver_dir" ) != QJsonValue::Undefined) {
1120+ this ->layers .last_layers_dir = json_object.value (" last_driver_dir" ).toString ().toStdString ();
1121+ }
1122+ if (json_object.value (" validate_manifests" ) != QJsonValue::Undefined) {
1123+ this ->layers .validate_manifests = json_object.value (" validate_manifests" ).toBool ();
1124+ }
1125+ if (json_object.value (" layers" ) != QJsonValue::Undefined) {
1126+ const QJsonObject& json_object_paths = json_object.value (" paths" ).toObject ();
1127+ QStringList keys = json_object_paths.keys ();
1128+ for (std::size_t i = 0 , n = keys.size (); i < n; ++i) {
1129+ const QJsonArray& json_descriptors = json_object_paths.value (keys[i]).toArray ();
1130+
1131+ std::vector<LayerDisplay> descriptors;
1132+ for (std::size_t j = 0 , o = json_descriptors.size (); j < o; ++j) {
1133+ const QJsonObject& json_descriptor_object = json_descriptors[j].toObject ();
1134+
1135+ LayerDisplay display;
1136+ display.id .key = json_descriptor_object.value (" key" ).toString ().toStdString ();
1137+ display.id .manifest_path = keys[i].toStdString ();
1138+ display.id .api_version = Version::NONE;
1139+ display.descriptor .enabled = json_descriptor_object.value (" enabled" ).toBool ();
1140+ display.descriptor .removed = json_descriptor_object.value (" removed" ).toBool ();
1141+ display.descriptor .validated = json_descriptor_object.value (" validated" ).toBool ();
1142+ descriptors.push_back (display);
1143+ }
1144+
1145+ this ->layers .AppendInit (Path (keys[i].toStdString ()), descriptors);
1146+ }
1147+ }
1148+ if (json_object.value (" paths" ) != QJsonValue::Undefined) {
1149+ const QJsonArray& json_paths = json_object.value (" paths" ).toArray ();
1150+ for (std::size_t i = 0 , n = json_paths.size (); i < n; ++i) {
1151+ this ->layers .gui_added_layers_paths .insert (json_paths[i].toString ().toStdString ());
1152+ }
1153+ }
11201154 }
11211155
11221156 // TAB_DRIVERS
@@ -1199,6 +1233,10 @@ bool Configurator::Load() {
11991233 if (json_interface_object.value (GetToken (TAB_PREFERENCES)) != QJsonValue::Undefined) {
12001234 const QJsonObject& json_object = json_interface_object.value (GetToken (TAB_PREFERENCES)).toObject ();
12011235
1236+ if (json_object.value (" validate_manifests" ) != QJsonValue::Undefined) {
1237+ this ->layers .validate_manifests = json_object.value (" validate_manifests" ).toBool ();
1238+ }
1239+
12021240 if (json_object.value (" use_notify_releases" ) != QJsonValue::Undefined) {
12031241 this ->use_notify_releases = json_object.value (" use_notify_releases" ).toBool ();
12041242 }
@@ -1311,7 +1349,54 @@ bool Configurator::Save() const {
13111349 }
13121350
13131351 // TAB_LAYERS_PATHS
1314- {}
1352+ {
1353+ std::map<Path, std::map<std::string, LayerDisplay>> data = this ->layers .BuildLayerStoreList ();
1354+
1355+ QJsonObject json_layers;
1356+ for (auto it = data.begin (); it != data.end (); ++it) {
1357+ std::map<std::string, LayerDisplay> descriptors = it->second ;
1358+
1359+ QJsonArray json_layer_descriptors;
1360+
1361+ bool is_user_added_path =
1362+ this ->layers .gui_added_layers_paths .find (it->first .AbsoluteDir ()) != this ->layers .gui_added_layers_paths .end ();
1363+
1364+ bool keep = false ; // Only remember paths that don't have all layer removed
1365+
1366+ for (auto jt = it->second .begin (); jt != it->second .end (); ++jt) {
1367+ if (!jt->second .descriptor .removed ) {
1368+ keep = true ;
1369+ }
1370+
1371+ QJsonObject json_descriptor;
1372+ json_descriptor.insert (" key" , jt->first .c_str ());
1373+ json_descriptor.insert (" validated" , jt->second .descriptor .validated );
1374+ json_descriptor.insert (" enabled" , jt->second .descriptor .enabled );
1375+ json_descriptor.insert (" removed" , jt->second .descriptor .removed );
1376+
1377+ json_layer_descriptors.append (json_descriptor);
1378+ }
1379+
1380+ if (is_user_added_path) {
1381+ if (keep) {
1382+ json_layers.insert (it->first .AbsolutePath ().c_str (), json_layer_descriptors);
1383+ }
1384+ } else {
1385+ json_layers.insert (it->first .AbsolutePath ().c_str (), json_layer_descriptors);
1386+ }
1387+ }
1388+
1389+ QJsonArray json_paths;
1390+ for (auto it = this ->layers .gui_added_layers_paths .begin (); it != this ->layers .gui_added_layers_paths .end (); ++it) {
1391+ json_paths.append (it->AbsolutePath ().c_str ());
1392+ }
1393+
1394+ QJsonObject json_object;
1395+ json_object.insert (" paths" , json_paths);
1396+ json_object.insert (" layers" , json_layers);
1397+ json_object.insert (" last_driver_dir" , this ->layers .last_layers_dir .AbsolutePath ().c_str ());
1398+ json_interface_object.insert (::GetToken (TAB_LAYERS_PATHS), json_object);
1399+ }
13151400
13161401 // TAB_DRIVER
13171402 {
@@ -1380,6 +1465,7 @@ bool Configurator::Save() const {
13801465 // TAB_PREFERENCES
13811466 {
13821467 QJsonObject json_object;
1468+ json_object.insert (" validate_manifests" , this ->layers .validate_manifests );
13831469 json_object.insert (" use_system_tray" , this ->use_system_tray );
13841470 json_object.insert (" use_layer_debug_mode" , this ->use_layer_debug_mode );
13851471 json_object.insert (" current_theme_mode" , ::GetToken (this ->current_theme_mode ));
0 commit comments