2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Use Images::Read instead of App::readImage.

This commit is contained in:
John Preston
2021-08-11 18:40:17 +03:00
parent b150ab8ef5
commit c79cd0b692
56 changed files with 155 additions and 293 deletions

View File

@@ -31,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h"
#include "mainwindow.h"
#include "main/main_session.h"
#include "app.h"
#include <QtCore/QBuffer>
#include <QtGui/QImageWriter>
@@ -642,25 +641,25 @@ bool FileLoadTask::CheckForImage(
const QString &filepath,
const QByteArray &content,
std::unique_ptr<Ui::PreparedFileInformation> &result) {
auto animated = false;
auto image = [&] {
auto read = [&] {
if (filepath.endsWith(qstr(".tgs"), Qt::CaseInsensitive)) {
auto image = Lottie::ReadThumbnail(
Lottie::ReadContent(content, filepath));
if (!image.isNull()) {
animated = true;
const auto success = !image.isNull();
if (success) {
result->filemime = qstr("application/x-tgsticker");
}
return image;
return Images::ReadResult{
.image = std::move(image),
.animated = success,
};
}
if (!content.isEmpty()) {
return App::readImage(content, nullptr, false, &animated);
} else if (!filepath.isEmpty()) {
return App::readImage(filepath, nullptr, false, &animated);
}
return QImage();
return Images::Read({
.path = filepath,
.content = content,
});
}();
return FillImageInformation(std::move(image), animated, result);
return FillImageInformation(std::move(read.image), read.animated, result);
}
bool FileLoadTask::FillImageInformation(