mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Upload saved theme to the cloud.
This commit is contained in:
@@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "storage/file_upload.h"
|
||||
#include "base/parse_helper.h"
|
||||
#include "base/zlib_help.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "data/data_session.h"
|
||||
#include "main/main_account.h" // Account::sessionValue.
|
||||
#include "ui/image/image.h"
|
||||
@@ -395,6 +396,68 @@ void ClearApplying() {
|
||||
GlobalApplying = Applying();
|
||||
}
|
||||
|
||||
SendMediaReady PrepareWallPaper(const QImage &image) {
|
||||
PreparedPhotoThumbs thumbnails;
|
||||
QVector<MTPPhotoSize> sizes;
|
||||
|
||||
QByteArray jpeg;
|
||||
QBuffer jpegBuffer(&jpeg);
|
||||
image.save(&jpegBuffer, "JPG", 87);
|
||||
|
||||
const auto scaled = [&](int size) {
|
||||
return image.scaled(
|
||||
size,
|
||||
size,
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
};
|
||||
const auto push = [&](const char *type, QImage &&image) {
|
||||
sizes.push_back(MTP_photoSize(
|
||||
MTP_string(type),
|
||||
MTP_fileLocationToBeDeprecated(MTP_long(0), MTP_int(0)),
|
||||
MTP_int(image.width()),
|
||||
MTP_int(image.height()), MTP_int(0)));
|
||||
thumbnails.emplace(type[0], std::move(image));
|
||||
};
|
||||
push("s", scaled(320));
|
||||
|
||||
const auto filename = qsl("wallpaper.jpg");
|
||||
auto attributes = QVector<MTPDocumentAttribute>(
|
||||
1,
|
||||
MTP_documentAttributeFilename(MTP_string(filename)));
|
||||
attributes.push_back(MTP_documentAttributeImageSize(
|
||||
MTP_int(image.width()),
|
||||
MTP_int(image.height())));
|
||||
const auto id = rand_value<DocumentId>();
|
||||
const auto document = MTP_document(
|
||||
MTP_flags(0),
|
||||
MTP_long(id),
|
||||
MTP_long(0),
|
||||
MTP_bytes(),
|
||||
MTP_int(base::unixtime::now()),
|
||||
MTP_string("image/jpeg"),
|
||||
MTP_int(jpeg.size()),
|
||||
MTP_vector<MTPPhotoSize>(sizes),
|
||||
MTP_int(MTP::maindc()),
|
||||
MTP_vector<MTPDocumentAttribute>(attributes));
|
||||
|
||||
return SendMediaReady(
|
||||
SendMediaType::ThemeFile,
|
||||
QString(), // filepath
|
||||
filename,
|
||||
jpeg.size(),
|
||||
jpeg,
|
||||
id,
|
||||
0,
|
||||
QString(),
|
||||
PeerId(),
|
||||
MTP_photoEmpty(MTP_long(0)),
|
||||
thumbnails,
|
||||
document,
|
||||
QByteArray(),
|
||||
0);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ChatBackground::AdjustableColor::AdjustableColor(style::color data)
|
||||
|
Reference in New Issue
Block a user