MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / Parse

Method Parse

Telegram/SourceFiles/data/data_cloud_themes.cpp:36–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34} // namespace
35
36CloudTheme CloudTheme::Parse(
37 not_null<Main::Session*> session,
38 const MTPDtheme &data,
39 bool parseSettings) {
40 const auto document = data.vdocument();
41 const auto paper = [&](const MTPThemeSettings &settings) {
42 const auto &data = settings.data();
43 return data.vwallpaper()
44 ? WallPaper::Create(session, *data.vwallpaper())
45 : std::nullopt;
46 };
47 const auto outgoingMessagesColors = [&](
48 const MTPThemeSettings &settings) {
49 auto result = std::vector<QColor>();
50 const auto &data = settings.data();
51 if (const auto colors = data.vmessage_colors()) {
52 for (const auto &color : colors->v) {
53 result.push_back(Ui::ColorFromSerialized(color));
54 }
55 }
56 return result;
57 };
58 const auto accentColor = [&](const MTPThemeSettings &settings) {
59 const auto &data = settings.data();
60 return Ui::ColorFromSerialized(data.vaccent_color());
61 };
62 const auto outgoingAccentColor = [&](const MTPThemeSettings &settings) {
63 const auto &data = settings.data();
64 return Ui::MaybeColorFromSerialized(data.voutbox_accent_color());
65 };
66 const auto basedOnDark = [&](const MTPThemeSettings &settings) {
67 const auto &data = settings.data();
68 return data.vbase_theme().match([](const MTPDbaseThemeNight &) {
69 return true;
70 }, [](const MTPDbaseThemeTinted &) {
71 return true;
72 }, [](const auto &) {
73 return false;
74 });
75 };
76 const auto settings = [&] {
77 auto result = base::flat_map<Type, Settings>();
78 const auto settings = data.vsettings();
79 if (!settings) {
80 return result;
81 }
82 for (const auto &fields : settings->v) {
83 const auto type = basedOnDark(fields) ? Type::Dark : Type::Light;
84 result.emplace(type, Settings{
85 .paper = paper(fields),
86 .accentColor = accentColor(fields),
87 .outgoingAccentColor = outgoingAccentColor(fields),
88 .outgoingMessagesColors = outgoingMessagesColors(fields),
89 });
90 }
91 return result;
92 };
93 return {

Callers

nothing calls this directly

Calls 11

qsFunction · 0.85
emplaceMethod · 0.80
processDocumentMethod · 0.80
ColorFromSerializedFunction · 0.70
MaybeColorFromSerializedFunction · 0.70
UserIdClass · 0.70
FromTLFunction · 0.70
ParseFunction · 0.70
CreateFunction · 0.50
dataMethod · 0.45
userIdMethod · 0.45

Tested by

no test coverage detected