1
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-03-21 02:41:34 +00:00

Limit video messages size.

This commit is contained in:
John Preston 2018-10-25 17:22:44 +04:00
parent 885e7f0471
commit 91a6af71a0
6 changed files with 31 additions and 22 deletions

View File

@ -243,12 +243,6 @@ dragPadding: margins(20px, 10px, 20px, 10px);
dragHeight: 72px;
minPhotoSize: 100px;
maxMediaSize: 430px;
maxStickerSize: 256px;
maxGifSize: 320px;
maxSignatureSize: 144px;
radialSize: size(50px, 50px);
radialLine: 3px;
radialDuration: 350;

View File

@ -9,6 +9,13 @@ using "basic.style";
using "dialogs/dialogs.style";
using "ui/widgets/widgets.style";
minPhotoSize: 100px;
maxMediaSize: 430px;
maxStickerSize: 256px;
maxGifSize: 320px;
maxVideoMessageSize: 240px;
maxSignatureSize: 144px;
historyMinimalWidth: 380px;
historyScroll: ScrollArea(defaultScrollArea) {

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_cursor_state.h"
#include "storage/storage_shared_media.h"
#include "ui/text_options.h"
#include "styles/style_history.h"
namespace {

View File

@ -2030,13 +2030,16 @@ QSize HistoryGif::countOptimalSize() {
th = ConvertScale(_data->thumb->height());
}
}
if (tw > st::maxGifSize) {
th = (st::maxGifSize * th) / tw;
tw = st::maxGifSize;
const auto maxSize = _data->isVideoMessage()
? st::maxVideoMessageSize
: st::maxGifSize;
if (tw > maxSize) {
th = (maxSize * th) / tw;
tw = maxSize;
}
if (th > st::maxGifSize) {
tw = (st::maxGifSize * tw) / th;
th = st::maxGifSize;
if (th > maxSize) {
tw = (maxSize * tw) / th;
th = maxSize;
}
if (!tw || !th) {
tw = th = 1;
@ -2085,13 +2088,16 @@ QSize HistoryGif::countCurrentSize(int newWidth) {
th = ConvertScale(_data->thumb->height());
}
}
if (tw > st::maxGifSize) {
th = (st::maxGifSize * th) / tw;
tw = st::maxGifSize;
const auto maxSize = _data->isVideoMessage()
? st::maxVideoMessageSize
: st::maxGifSize;
if (tw > maxSize) {
th = (maxSize * th) / tw;
tw = maxSize;
}
if (th > st::maxGifSize) {
tw = (st::maxGifSize * tw) / th;
th = st::maxGifSize;
if (th > maxSize) {
tw = (maxSize * tw) / th;
th = maxSize;
}
if (!tw || !th) {
tw = th = 1;

View File

@ -386,7 +386,7 @@ Video::Video(
}
void Video::initDimensions() {
_maxw = 2 * st::minPhotoSize;
_maxw = 2 * st::overviewPhotoMinSize;
_minh = _maxw;
}

View File

@ -16,9 +16,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h"
#include "mainwidget.h"
#include "core/file_utilities.h"
#include "styles/style_boxes.h"
#include "styles/style_widgets.h"
#include "styles/style_chat_helpers.h"
#include "ui/widgets/shadow.h"
#include "ui/image/image.h"
#include "ui/emoji_config.h"
@ -26,6 +23,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "auth_session.h"
#include "chat_helpers/stickers.h"
#include "window/window_controller.h"
#include "styles/style_boxes.h"
#include "styles/style_widgets.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_history.h"
namespace {