void PeerData::clearUserpic() { const auto photoId = PhotoId(0); const auto loc = StorageImageLocation(); const auto photo = [&] { if (id == peerFromUser(ServiceUserId)) { auto image = Messenger::Instance().logoNoMargin().scaledToWidth( kUserpicSize, Qt::SmoothTransformation); auto pixmap = App::pixmapFromImageInPlace(std::move(image)); return _userpic ? _userpic : ImagePtr(std::move(pixmap), "PNG"); } return ImagePtr(); }(); setUserpicChecked(photoId, loc, photo); }
DelayedStorageSource::DelayedStorageSource(int w, int h) : StorageSource(StorageImageLocation(w, h, 0, 0, 0, 0, {}), 0) { }
DelayedStorageSource::DelayedStorageSource() : StorageSource(StorageImageLocation(), 0) { }
void Result::createDocument() { if (_document) return; if (!_thumb_url.isEmpty()) { _thumb = ImagePtr(_thumb_url, QSize(90, 90)); } QString mime = _content_type; QVector<MTPDocumentAttribute> attributes; QSize dimensions(_width, _height); if (_type == Type::Gif) { const char *filename = (mime == qstr("video/mp4") ? "animation.gif.mp4" : "animation.gif"); attributes.push_back(MTP_documentAttributeFilename(MTP_string(filename))); attributes.push_back(MTP_documentAttributeAnimated()); attributes.push_back(MTP_documentAttributeVideo(MTP_int(_duration), MTP_int(_width), MTP_int(_height))); } else if (_type == Type::Video) { attributes.push_back(MTP_documentAttributeVideo(MTP_int(_duration), MTP_int(_width), MTP_int(_height))); } else if (_type == Type::Audio) { MTPDdocumentAttributeAudio::Flags flags = 0; if (mime == qstr("audio/ogg")) { flags |= MTPDdocumentAttributeAudio::Flag::f_voice; } else { QStringList p = mimeTypeForName(mime).globPatterns(); QString pattern = p.isEmpty() ? QString() : p.front(); QString extension = pattern.isEmpty() ? qsl(".unknown") : pattern.replace('*', QString()); QString filename = filedialogDefaultName(qsl("inline"), extension, QString(), true); attributes.push_back(MTP_documentAttributeFilename(MTP_string(filename))); } attributes.push_back(MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(_duration), MTPstring(), MTPstring(), MTPbytes())); } auto documentId = rand_value<DocumentId>(); _document = App::documentSet(documentId, nullptr, 0, 0, unixtime(), attributes, mime, _thumb, MTP::maindc(), 0, StorageImageLocation()); _document->setContentUrl(_content_url); }
StorageImageLocation readStorageImageLocation(QDataStream &stream) { qint32 width, height, dc, local; quint64 volume, secret; stream >> width >> height >> dc >> volume >> local >> secret; return StorageImageLocation(width, height, dc, volume, local, secret); }
DelayedStorageSource::DelayedStorageSource(int w, int h) : StorageSource(StorageImageLocation(StorageFileLocation(), w, h), 0) { }