From c5d20a21f7decd8a9acd928cd7276f70869fc239 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. --- Telegram/SourceFiles/boxes/edit_caption_box.cpp | 2 +- Telegram/SourceFiles/boxes/rate_call_box.cpp | 3 ++- Telegram/SourceFiles/boxes/report_box.cpp | 8 +++++++- Telegram/SourceFiles/boxes/send_files_box.cpp | 2 +- Telegram/SourceFiles/config.h | 2 -- Telegram/SourceFiles/facades.cpp | 2 ++ Telegram/SourceFiles/facades.h | 1 + Telegram/SourceFiles/mtproto/mtp_instance.cpp | 1 + 8 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 430e5682136a42..77c8d18bdd1697 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -209,7 +209,7 @@ EditCaptionBox::EditCaptionBox( Ui::InputField::Mode::MultiLine, langFactory(lng_photo_caption), editData); - _field->setMaxLength(MaxPhotoCaption); + _field->setMaxLength(Global::CaptionLengthMax()); _field->setSubmitSettings(Ui::InputField::SubmitSettings::Both); _field->setInstantReplaces(Ui::InstantReplaces::Default()); _field->setInstantReplacesEnabled(Global::ReplaceEmojiValue()); diff --git a/Telegram/SourceFiles/boxes/rate_call_box.cpp b/Telegram/SourceFiles/boxes/rate_call_box.cpp index e80bdb431676c6..caed8ee91d7a8b 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.cpp +++ b/Telegram/SourceFiles/boxes/rate_call_box.cpp @@ -20,6 +20,7 @@ For license and copyright information please follow this link: namespace { constexpr auto kMaxRating = 5; +constexpr auto kRateCallCommentLengthMax = 200; } // namespace @@ -78,7 +79,7 @@ void RateCallBox::ratingChanged(int value) { langFactory(lng_call_rate_comment)); _comment->show(); _comment->setSubmitSettings(Ui::InputField::SubmitSettings::Both); - _comment->setMaxLength(MaxPhotoCaption); + _comment->setMaxLength(kRateCallCommentLengthMax); _comment->resize(width() - (st::callRatingPadding.left() + st::callRatingPadding.right()), _comment->height()); updateMaxHeight(); diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index 04c8fba2c9a4dd..cd3947418440f8 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -17,6 +17,12 @@ For license and copyright information please follow this link: #include "ui/toast/toast.h" #include "mainwindow.h" +namespace { + +constexpr auto kReportReasonLengthMax = 200; + +} // namespace + ReportBox::ReportBox(QWidget*, not_null peer) : _peer(peer) { } @@ -89,7 +95,7 @@ void ReportBox::reasonChanged(Reason reason) { langFactory(lng_report_reason_description)); _reasonOtherText->show(); _reasonOtherText->setSubmitSettings(Ui::InputField::SubmitSettings::Both); - _reasonOtherText->setMaxLength(MaxPhotoCaption); + _reasonOtherText->setMaxLength(kReportReasonLengthMax); _reasonOtherText->resize(width() - (st::boxPadding.left() + st::boxOptionListPadding.left() + st::boxPadding.right()), _reasonOtherText->height()); updateMaxHeight(); diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 7ffc590bfe4e69..1fecfa1dd359e5 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -1556,7 +1556,7 @@ void SendFilesBox::applyAlbumOrder() { } void SendFilesBox::setupCaption() { - _caption->setMaxLength(MaxPhotoCaption); + _caption->setMaxLength(Global::CaptionLengthMax()); _caption->setSubmitSettings(Ui::InputField::SubmitSettings::Both); connect(_caption, &Ui::InputField::resized, [=] { captionResized(); diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index 863d0280ed12ec..f26f04cae9af01 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -75,8 +75,6 @@ enum { SearchPeopleLimit = 5, UsernameCheckTimeout = 200, - MaxPhotoCaption = 200, - MaxMessageSize = 4096, WriteMapTimeout = 1000, diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index a9de1ea8382a2d..65a7d707f9d8ec 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -622,6 +622,7 @@ struct Data { : qsl("apv2.stel.com"); bool PhoneCallsEnabled = true; bool BlockedMode = false; + int32 CaptionLengthMax = 1024; base::Observable PhoneCallsEnabledChanged; HiddenPinnedMessagesMap HiddenPinnedMessages; @@ -750,6 +751,7 @@ DefineVar(Global, int32, WebFileDcId); DefineVar(Global, QString, TxtDomainString); DefineVar(Global, bool, PhoneCallsEnabled); DefineVar(Global, bool, BlockedMode); +DefineVar(Global, int32, CaptionLengthMax); DefineRefVar(Global, base::Observable, PhoneCallsEnabledChanged); DefineVar(Global, HiddenPinnedMessagesMap, HiddenPinnedMessages); diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index e3eca0d2c231ca..8f58b0bcf0d3e3 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -286,6 +286,7 @@ DeclareVar(int32, WebFileDcId); DeclareVar(QString, TxtDomainString); DeclareVar(bool, PhoneCallsEnabled); DeclareVar(bool, BlockedMode); +DeclareVar(int32, 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 119abbff734f7d..21a56e74b0987f 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -768,6 +768,7 @@ void Instance::Private::configLoadDone(const MTPConfig &result) { Global::RefPhoneCallsEnabledChanged().notify(); } Global::SetBlockedMode(data.is_blocked_mode()); + Global::SetCaptionLengthMax(data.vcaption_length_max.v); const auto lang = data.has_suggested_lang_code() ? qs(data.vsuggested_lang_code)