Send high quality as first-class option.

This commit is contained in:
John Preston
2026-03-17 14:27:30 +04:00
parent 98a6af1ca9
commit 87ebd2720f
28 changed files with 413 additions and 73 deletions
@@ -12,9 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "core/file_utilities.h"
#include "core/mime_type.h"
#include "base/options.h"
#include "base/unixtime.h"
#include "base/random.h"
#include "editor/scene/scene_item_sticker.h"
@@ -51,13 +52,6 @@ constexpr auto kRecompressAfterBpp = 4;
using Ui::ValidateThumbDimensions;
base::options::toggle SendLargePhotos({
.id = kOptionSendLargePhotos,
.name = "Send large photos",
.description = "Increase the side limit on compressed images to 2560px.",
});
std::atomic<bool> SendLargePhotosAtomic/* = false*/;
struct PreparedFileThumbnail {
uint64 id = 0;
QString name;
@@ -206,20 +200,15 @@ struct PreparedFileThumbnail {
return result;
}
[[nodiscard]] int PhotoSideLimit(bool large) {
} // namespace
int PhotoSideLimit(bool large) {
return large ? 2560 : 1280;
}
[[nodiscard]] int PhotoSideLimitAtomic() {
return PhotoSideLimit(SendLargePhotosAtomic.load());
}
} // namespace
const char kOptionSendLargePhotos[] = "send-large-photos";
int PhotoSideLimit() {
return PhotoSideLimit(SendLargePhotos.value());
return PhotoSideLimit(
Core::App().settings().sendFilesWay().sendLargePhotos());
}
TaskQueue::TaskQueue(crl::time stopTimeoutMs) {
@@ -480,13 +469,12 @@ FileLoadTask::FileLoadTask(Args &&args)
, _type(args.type)
, _caption(std::move(args.caption))
, _spoiler(args.spoiler)
, _forceFile(args.forceFile) {
, _forceFile(args.forceFile)
, _sendLargePhotos(args.sendLargePhotos) {
Expects(_to.options.scheduled
|| _to.options.shortcutId
|| !_to.replaceMediaOf
|| IsServerMsgId(_to.replaceMediaOf));
SendLargePhotosAtomic = SendLargePhotos.value();
}
FileLoadTask::FileLoadTask(VoiceArgs &&args)
@@ -944,7 +932,7 @@ void FileLoadTask::process(ProcessArgs &&args) {
}
auto medium = (w > 320 || h > 320) ? fullimage.scaled(320, 320, Qt::KeepAspectRatio, Qt::SmoothTransformation) : fullimage;
const auto limit = PhotoSideLimitAtomic();
const auto limit = PhotoSideLimit(_sendLargePhotos);
const auto downscaled = (w > limit || h > limit);
auto full = downscaled ? fullimage.scaled(limit, limit, Qt::KeepAspectRatio, Qt::SmoothTransformation) : fullimage;
if (downscaled) {
@@ -24,8 +24,7 @@ constexpr auto kFileSizeLimit = 2'000 * int64(1024 * 1024);
// Load files up to 4'000 MB.
constexpr auto kFileSizePremiumLimit = 4'000 * int64(1024 * 1024);
extern const char kOptionSendLargePhotos[];
[[nodiscard]] int PhotoSideLimit(bool large);
[[nodiscard]] int PhotoSideLimit();
enum class SendMediaType {
@@ -232,6 +231,7 @@ public:
bool spoiler = false;
std::shared_ptr<SendingAlbum> album;
bool forceFile = false;
bool sendLargePhotos = false;
uint64 idOverride = 0;
QString displayName;
};
@@ -303,6 +303,7 @@ private:
TextWithTags _caption;
bool _spoiler = false;
bool _forceFile = false;
bool _sendLargePhotos = false;
std::shared_ptr<FilePrepareResult> _result;