From 3186abd2198561bdac1151a2ec29a5d09b1a1736 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 17 Oct 2018 14:38:07 +0300 Subject: [PATCH] Beta version 1.4.4: Correct caption limit. Cherry-picked from upstream: https://github.com/telegramdesktop/tdesktop/commit/ff53404d5bd1926d0ceca7f74c5aa47604d939aa Closes #188. --- Telegram/SourceFiles/boxes/rate_call_box.cpp | 3 ++- Telegram/SourceFiles/boxes/report_box.cpp | 8 +++++++- Telegram/SourceFiles/boxes/send_files_box.cpp | 4 ++-- Telegram/SourceFiles/config.h.in | 2 -- Telegram/SourceFiles/facades.cpp | 6 ++++++ Telegram/SourceFiles/facades.h | 1 + Telegram/SourceFiles/mtproto/mtp_instance.cpp | 1 + 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/boxes/rate_call_box.cpp b/Telegram/SourceFiles/boxes/rate_call_box.cpp index 131656766..368c4269d 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.cpp +++ b/Telegram/SourceFiles/boxes/rate_call_box.cpp @@ -33,6 +33,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org namespace { constexpr auto kMaxRating = 5; +constexpr auto kRateCallCommentLengthMax = 200; } // namespace @@ -86,7 +87,7 @@ void RateCallBox::ratingChanged(int value) { _comment.create(this, st::callRatingComment, langFactory(lng_call_rate_comment)); _comment->show(); _comment->setCtrlEnterSubmit(Ui::CtrlEnterSubmit::Both); - _comment->setMaxLength(MaxPhotoCaption); + _comment->setMaxLength(kRateCallCommentLengthMax); _comment->resize(width() - (st::callRatingPadding.left() + st::callRatingPadding.right()), _comment->height()); diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index 3475388dd..dcea3b050 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -30,6 +30,12 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "ui/widgets/checkbox.h" #include "ui/widgets/input_fields.h" +namespace { + +constexpr auto kReportReasonLengthMax = 200; + +} // namespace + ReportBox::ReportBox(QWidget *, PeerData *peer) : _peer(peer) , _reasonGroup(std::make_shared>(Reason::Spam)) @@ -76,7 +82,7 @@ void ReportBox::reasonChanged(Reason reason) { _reasonOtherText.create(this, st::profileReportReasonOther, langFactory(lng_report_reason_description)); _reasonOtherText->show(); _reasonOtherText->setCtrlEnterSubmit(Ui::CtrlEnterSubmit::Both); - _reasonOtherText->setMaxLength(MaxPhotoCaption); + _reasonOtherText->setMaxLength(kReportReasonLengthMax); _reasonOtherText->resize( width() - (st::boxPadding.left() + st::boxOptionListPadding.left() + st::boxPadding.right()), _reasonOtherText->height()); diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 1c7d07e21..7c8ba7f7b 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -253,7 +253,7 @@ void SendFilesBox::prepare() { subscribe(_compressed->checkedChanged, [this](bool checked) { onCompressedChange(); }); } if (_caption) { - _caption->setMaxLength(MaxPhotoCaption); + _caption->setMaxLength(Global::CaptionLengthMax()); _caption->setCtrlEnterSubmit(Ui::CtrlEnterSubmit::Both); connect(_caption, SIGNAL(resized()), this, SLOT(onCaptionResized())); connect(_caption, SIGNAL(submitted(bool)), this, SLOT(onSend(bool))); @@ -596,7 +596,7 @@ EditCaptionBox::EditCaptionBox(QWidget *, HistoryMedia *media, FullMsgId msgId) Assert(_animated || _photo || _doc); _field.create(this, st::confirmCaptionArea, langFactory(lng_photo_caption), caption); - _field->setMaxLength(MaxPhotoCaption); + _field->setMaxLength(Global::CaptionLengthMax()); _field->setCtrlEnterSubmit(Ui::CtrlEnterSubmit::Both); } diff --git a/Telegram/SourceFiles/config.h.in b/Telegram/SourceFiles/config.h.in index 79865ec13..39a62ddea 100644 --- a/Telegram/SourceFiles/config.h.in +++ b/Telegram/SourceFiles/config.h.in @@ -112,8 +112,6 @@ enum { MaxUsernameLength = 32, UsernameCheckTimeout = 200, - MaxPhotoCaption = 200, - MaxMessageSize = 4096, WriteMapTimeout = 1000, diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 8d33e8ea5..624b1e5d3 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -609,6 +609,7 @@ struct Data { qint32 CallConnectTimeoutMs = 30000; qint32 CallPacketTimeoutMs = 10000; bool PhoneCallsEnabled = true; + int32 CaptionLengthMax = 1024; base::Observable PhoneCallsEnabledChanged; HiddenPinnedMessagesMap HiddenPinnedMessages; @@ -731,6 +732,11 @@ DefineVar(Global, qint32, CallRingTimeoutMs); DefineVar(Global, qint32, CallConnectTimeoutMs); DefineVar(Global, qint32, CallPacketTimeoutMs); DefineVar(Global, bool, PhoneCallsEnabled); +<<<<<<< HEAD +======= +DefineVar(Global, bool, BlockedMode); +DefineVar(Global, int32, CaptionLengthMax); +>>>>>>> c5d20a21f... Beta version 1.4.4: Correct caption limit. DefineRefVar(Global, base::Observable, PhoneCallsEnabledChanged); DefineVar(Global, HiddenPinnedMessagesMap, HiddenPinnedMessages); diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 7236cbf29..7bea16e7e 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -340,6 +340,7 @@ DeclareVar(qint32, CallRingTimeoutMs); DeclareVar(qint32, CallConnectTimeoutMs); DeclareVar(qint32, CallPacketTimeoutMs); DeclareVar(bool, PhoneCallsEnabled); +DeclareVar(qint32, CaptionLengthMax); DeclareRefVar(base::Observable, PhoneCallsEnabledChanged); typedef QMap HiddenPinnedMessagesMap; diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp index 0b3f9d984..e59300852 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -620,6 +620,7 @@ void Instance::Private::configLoadDone(const MTPConfig &result) { } Lang::CurrentCloudManager().setSuggestedLanguage(data.has_suggested_lang_code() ? qs(data.vsuggested_lang_code) : QString()); + Global::SetCaptionLengthMax(data.vcaption_length_max.v); Local::writeSettings();