void qt_gui_settings::unserialize(core::coll_helper _collection) { core::iarray* values_array = _collection.get_value_as_array("values"); if (!values_array) { assert(false); return; } for (int i = 0; i < values_array->size(); ++i) { const core::ivalue* val = values_array->get_at(i); gui_coll_helper coll_val(val->get_as_collection(), false); core::istream* idata = coll_val.get_value_as_stream("value"); int len = idata->size(); set_value_simple_data(coll_val.get_value_as_string("name"), (const char*) idata->read(len), len, false); } emit received(); setIsLoaded(true); }
void qt_theme_settings::unserialize(core::coll_helper _collection) { core::iarray* values_array = _collection.get_value_as_array("values"); if (!values_array) { assert(false); return; } QString tint_color; QByteArray imageDataArray; QByteArray thumbDataArray; QString contactsThemes; int theme_id = -1; bool tile = false; for (int i = 0; i < values_array->size(); ++i) { const core::ivalue* val = values_array->get_at(i); gui_coll_helper coll_val(val->get_as_collection(), false); std::string name = coll_val.get_value_as_string("name"); core::istream* idata = coll_val.get_value_as_stream("value"); int len = idata->size(); const char* data = (char *)idata->read(len); if (name == "id") { if (len == 4) { theme_id = *(data) | *(data+1) << 8 | *(data+2) << 16 | *(data+3) << 24; } } else if (name == "image") { imageDataArray = QByteArray(data, len); } else if (name == "thumb") { thumbDataArray = QByteArray(data, len); } else if (name == "tint_color") { tint_color = QString(std::string(data, len).c_str()); } else if (name == "contacts_themes") { contactsThemes = QString(std::string(data, len).c_str()); } else if (name == "tile") { if (len == 1) { tile = *(data) & 0xFF; } } } if (theme_id != -1) { __INFO("themes", "unserialized default theme " << theme_id << "(tint_color " << tint_color << ")"); default_theme_ = std::make_shared<themes::theme>(theme_id, tint_color, imageDataArray, thumbDataArray, tile); } if (contactsThemes.length() > 1) { __INFO("themes", "contactsThemes " << contactsThemes); QStringList list = contactsThemes.split(","); for (int i = 0; i < list.count(); ++i) { QString item = list[i]; QStringList contactTheme = item.split(":"); if (contactTheme.count() == 2) { QString aimId = contactTheme[0]; int themeId = contactTheme[1].toInt(); if (themeId >= 0) { contactsThemes_[aimId] = themeId; themesIdToLoad_.push_back(themeId); } } } } }