Allow sending videos with covers.

This commit is contained in:
John Preston
2025-01-29 09:24:01 +04:00
parent 6a415cf232
commit e05bb75b8a
42 changed files with 571 additions and 104 deletions
@@ -362,10 +362,22 @@ void UpdateImageDetails(
bool ApplyModifications(PreparedList &list) {
auto applied = false;
for (auto &file : list.files) {
const auto apply = [&](PreparedFile &file, QSize strictSize = {}) {
const auto image = std::get_if<Image>(&file.information->media);
const auto guard = gsl::finally([&] {
if (!image || strictSize.isEmpty()) {
return;
}
applied = true;
file.path = QString();
file.content = QByteArray();
image->data = image->data.scaled(
strictSize,
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
});
if (!image || !image->modifications) {
continue;
return;
}
applied = true;
file.path = QString();
@@ -373,6 +385,16 @@ bool ApplyModifications(PreparedList &list) {
image->data = Editor::ImageModified(
std::move(image->data),
image->modifications);
};
for (auto &file : list.files) {
apply(file);
if (const auto cover = file.videoCover.get()) {
const auto video = file.information
? std::get_if<Ui::PreparedFileInformation::Video>(
&file.information->media)
: nullptr;
apply(*cover, video ? video->thumbnail.size() : QSize());
}
}
return applied;
}