Skip to content

Commit

Permalink
Beta version 1.4.4: Correct caption limit.
Browse files Browse the repository at this point in the history
Cherry-picked from upstream: telegramdesktop/tdesktop@ff53404
Closes procxx#188.
  • Loading branch information
john-preston authored and foxcpp committed Oct 17, 2018
1 parent 9c4a0ee commit 3186abd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/boxes/rate_call_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
namespace {

constexpr auto kMaxRating = 5;
constexpr auto kRateCallCommentLengthMax = 200;

} // namespace

Expand Down Expand Up @@ -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());

Expand Down
8 changes: 7 additions & 1 deletion Telegram/SourceFiles/boxes/report_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ui::RadioenumGroup<Reason>>(Reason::Spam))
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/boxes/send_files_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 0 additions & 2 deletions Telegram/SourceFiles/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ enum {
MaxUsernameLength = 32,
UsernameCheckTimeout = 200,

MaxPhotoCaption = 200,

MaxMessageSize = 4096,

WriteMapTimeout = 1000,
Expand Down
6 changes: 6 additions & 0 deletions Telegram/SourceFiles/facades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ struct Data {
qint32 CallConnectTimeoutMs = 30000;
qint32 CallPacketTimeoutMs = 10000;
bool PhoneCallsEnabled = true;
int32 CaptionLengthMax = 1024;
base::Observable<void> PhoneCallsEnabledChanged;

HiddenPinnedMessagesMap HiddenPinnedMessages;
Expand Down Expand Up @@ -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<void>, PhoneCallsEnabledChanged);

DefineVar(Global, HiddenPinnedMessagesMap, HiddenPinnedMessages);
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/facades.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ DeclareVar(qint32, CallRingTimeoutMs);
DeclareVar(qint32, CallConnectTimeoutMs);
DeclareVar(qint32, CallPacketTimeoutMs);
DeclareVar(bool, PhoneCallsEnabled);
DeclareVar(qint32, CaptionLengthMax);
DeclareRefVar(base::Observable<void>, PhoneCallsEnabledChanged);

typedef QMap<PeerId, MsgId> HiddenPinnedMessagesMap;
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/mtproto/mtp_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 3186abd

Please sign in to comment.