2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Generate previews for cloud theme links.

This commit is contained in:
John Preston
2019-09-09 14:56:05 +03:00
parent 6d29dc3b36
commit ee5423762a
20 changed files with 193 additions and 80 deletions

View File

@@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "storage/file_download.h"
#include "storage/storage_media_prepare.h"
#include "window/themes/window_theme_preview.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "main/main_session.h"
@@ -78,13 +79,6 @@ PreparedFileThumbnail PrepareFileThumbnail(QImage &&original) {
return result;
}
PreparedFileThumbnail PrepareAnimatedStickerThumbnail(
const QString &file,
const QByteArray &bytes) {
return PrepareFileThumbnail(
Lottie::ReadThumbnail(Lottie::ReadContent(bytes, file)));
}
bool FileThumbnailUploadRequired(const QString &filemime, int32 filesize) {
constexpr auto kThumbnailUploadBySize = 5 * 1024 * 1024;
const auto kThumbnailKnownMimes = {
@@ -818,6 +812,15 @@ void FileLoadTask::process() {
}
thumbnail = PrepareFileThumbnail(std::move(video->thumbnail));
} else if (filemime == qstr("application/x-tdesktop-theme")
|| filemime == qstr("application/x-tgtheme-tdesktop")) {
goodThumbnail = Window::Theme::GeneratePreview(_content, _filepath);
if (!goodThumbnail.isNull()) {
QBuffer buffer(&goodThumbnailBytes);
goodThumbnail.save(&buffer, "JPG", kThumbnailQuality);
thumbnail = PrepareFileThumbnail(base::duplicate(goodThumbnail));
}
}
}