mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Allow sending videos with covers.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user