mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Allow sending videos as files.
This commit is contained in:
@@ -887,22 +887,24 @@ void FileLoadTask::process(Args &&args) {
|
||||
isVideo = true;
|
||||
auto coverWidth = video->thumbnail.width();
|
||||
auto coverHeight = video->thumbnail.height();
|
||||
if (video->isGifv && !_album) {
|
||||
attributes.push_back(MTP_documentAttributeAnimated());
|
||||
if (!_forceFile) {
|
||||
if (video->isGifv && !_album) {
|
||||
attributes.push_back(MTP_documentAttributeAnimated());
|
||||
}
|
||||
auto flags = MTPDdocumentAttributeVideo::Flags(0);
|
||||
if (video->supportsStreaming) {
|
||||
flags |= MTPDdocumentAttributeVideo::Flag::f_supports_streaming;
|
||||
}
|
||||
const auto realSeconds = video->duration / 1000.;
|
||||
attributes.push_back(MTP_documentAttributeVideo(
|
||||
MTP_flags(flags),
|
||||
MTP_double(realSeconds),
|
||||
MTP_int(coverWidth),
|
||||
MTP_int(coverHeight),
|
||||
MTPint(),
|
||||
MTPdouble(),
|
||||
MTPstring()));
|
||||
}
|
||||
auto flags = MTPDdocumentAttributeVideo::Flags(0);
|
||||
if (video->supportsStreaming) {
|
||||
flags |= MTPDdocumentAttributeVideo::Flag::f_supports_streaming;
|
||||
}
|
||||
const auto realSeconds = video->duration / 1000.;
|
||||
attributes.push_back(MTP_documentAttributeVideo(
|
||||
MTP_flags(flags),
|
||||
MTP_double(realSeconds),
|
||||
MTP_int(coverWidth),
|
||||
MTP_int(coverHeight),
|
||||
MTPint(), // preload_prefix_size
|
||||
MTPdouble(), // video_start_ts
|
||||
MTPstring())); // video_codec
|
||||
|
||||
if (args.generateGoodThumbnail) {
|
||||
goodThumbnail = video->thumbnail;
|
||||
|
||||
@@ -133,6 +133,7 @@ MimeDataState ComputeMimeDataState(const QMimeData *data) {
|
||||
}
|
||||
|
||||
auto allAreSmallImages = true;
|
||||
auto allAreMedia = true;
|
||||
for (const auto &url : urls) {
|
||||
if (!url.isLocalFile()) {
|
||||
return MimeDataState::None;
|
||||
@@ -162,9 +163,17 @@ MimeDataState ComputeMimeDataState(const QMimeData *data) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (allAreMedia) {
|
||||
const auto type = DetectNameType(file);
|
||||
if (type != NameType::Image && type != NameType::Video) {
|
||||
allAreMedia = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return allAreSmallImages
|
||||
? MimeDataState::PhotoFiles
|
||||
: allAreMedia
|
||||
? MimeDataState::MediaFiles
|
||||
: MimeDataState::Files;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ enum class MimeDataState {
|
||||
None,
|
||||
Files,
|
||||
PhotoFiles,
|
||||
MediaFiles,
|
||||
//PremiumFile,
|
||||
Image,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user