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

Method setattributes

Telegram/SourceFiles/data/data_document.cpp:334–535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334void DocumentData::setattributes(
335 const QVector<MTPDocumentAttribute> &attributes) {
336 _duration = -1;
337 _flags &= ~(Flag::ImageType
338 | Flag::HasAttachedStickers
339 | Flag::UseTextColor
340 | Flag::SilentVideo
341 | kStreamingSupportedMask);
342 _flags |= kStreamingSupportedUnknown;
343
344 validateLottieSticker();
345
346 auto wasVideoData = isVideoFile() ? std::move(_additional) : nullptr;
347
348 _videoPreloadPrefix = 0;
349 for (const auto &attribute : attributes) {
350 attribute.match([&](const MTPDdocumentAttributeImageSize &data) {
351 dimensions = QSize(data.vw().v, data.vh().v);
352 }, [&](const MTPDdocumentAttributeAnimated &data) {
353 if (type == FileDocument
354 || type == VideoDocument
355 || (sticker() && sticker()->type != StickerType::Webm)) {
356 type = AnimatedDocument;
357 _additional = nullptr;
358 }
359 }, [&](const MTPDdocumentAttributeSticker &data) {
360 const auto was = type;
361 if (type == FileDocument || type == VideoDocument) {
362 type = StickerDocument;
363 _additional = std::make_unique<StickerData>();
364 }
365 if (const auto info = sticker()) {
366 info->setType = data.is_mask()
367 ? Data::StickersType::Masks
368 : Data::StickersType::Stickers;
369 if (was == VideoDocument) {
370 info->type = StickerType::Webm;
371 }
372 info->alt = qs(data.valt());
373 UpdateStickerSetIdentifier(info->set, data.vstickerset());
374 }
375 }, [&](const MTPDdocumentAttributeCustomEmoji &data) {
376 const auto was = type;
377 if (type == FileDocument || type == VideoDocument) {
378 type = StickerDocument;
379 _additional = std::make_unique<StickerData>();
380 }
381 if (const auto info = sticker()) {
382 info->setType = Data::StickersType::Emoji;
383 if (was == VideoDocument) {
384 info->type = StickerType::Webm;
385 }
386 info->alt = qs(data.valt());
387 if (data.is_free()) {
388 _flags &= ~Flag::PremiumSticker;
389 } else {
390 _flags |= Flag::PremiumSticker;
391 }

Callers 1

documentApplyFieldsMethod · 0.80

Calls 12

qsFunction · 0.85
documentWaveformDecodeFunction · 0.85
GoodStickerDimensionsFunction · 0.85
NameTypeAllowsThumbnailFunction · 0.85
scaledMethod · 0.80
isLottieMethod · 0.80
emptyMethod · 0.45
isEmptyMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected