From ae56c5266fcbefe45bc5d7f4c30b4227679c6d1a Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 24 Jun 2017 20:21:01 +0300 Subject: [PATCH] Fix rich text entities in log entry original. --- .../history/history_admin_log_item.cpp | 5 +++-- .../SourceFiles/history/history_media_types.cpp | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history/history_admin_log_item.cpp b/Telegram/SourceFiles/history/history_admin_log_item.cpp index 689ac0282..bf2c4d0be 100644 --- a/Telegram/SourceFiles/history/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/history_admin_log_item.cpp @@ -349,9 +349,10 @@ void GenerateItems(gsl::not_null history, LocalIdManager &idManager, c auto applyServiceAction = false; auto detachExistingItem = false; auto body = history->createItem(PrepareLogMessage(action.vnew_message, idManager.next(), date.v), applyServiceAction, detachExistingItem); - if (!oldValue.text.isEmpty()) { - body->addLogEntryOriginal(id, lang(canHaveCaption ? lng_admin_log_previous_caption : lng_admin_log_previous_message), oldValue); + if (oldValue.text.isEmpty()) { + oldValue = PrepareText(QString(), lang(lng_admin_log_empty_text)); } + body->addLogEntryOriginal(id, lang(canHaveCaption ? lng_admin_log_previous_caption : lng_admin_log_previous_message), oldValue); addPart(body); }; diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index 33433ee3a..651212805 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -49,7 +49,7 @@ TextParseOptions _webpageTitleOptions = { Qt::LayoutDirectionAuto, // dir }; TextParseOptions _webpageDescriptionOptions = { - TextParseLinks | TextParseMentions | TextParseHashtags | TextParseMultiline | TextParseRichText, // flags + TextParseLinks | TextParseMentions | TextParseHashtags | TextParseMultiline | TextParseRichText | TextParseMono, // flags 0, // maxw 0, // maxh Qt::LayoutDirectionAuto, // dir @@ -3726,7 +3726,10 @@ void HistoryGame::initDimensions() { if (!_attach) { text += _parent->skipBlock(); } - _description.setText(st::webPageDescriptionStyle, text, _webpageDescriptionOptions); + auto marked = TextWithEntities { text }; + auto parseFlags = TextParseLinks | TextParseMultiline | TextParseRichText; + textParseEntities(marked.text, parseFlags, &marked.entities); + _description.setMarkedText(st::webPageDescriptionStyle, marked, _webpageDescriptionOptions); } } if (_title.isEmpty() && !title.isEmpty()) { @@ -4151,7 +4154,10 @@ void HistoryInvoice::fillFromData(const MTPDmessageMediaInvoice &data) { // init strings auto description = qs(data.vdescription); if (!description.isEmpty()) { - _description.setText(st::webPageDescriptionStyle, description, _webpageDescriptionOptions); + auto marked = TextWithEntities { description }; + auto parseFlags = TextParseLinks | TextParseMultiline | TextParseRichText; + textParseEntities(marked.text, parseFlags, &marked.entities); + _description.setMarkedText(st::webPageDescriptionStyle, marked, _webpageDescriptionOptions); } auto title = textOneLine(qs(data.vtitle)); if (!title.isEmpty()) { @@ -4457,7 +4463,10 @@ HistoryLocation::HistoryLocation(gsl::not_null parent, const Locat _title.setText(st::webPageTitleStyle, textClean(title), _webpageTitleOptions); } if (!description.isEmpty()) { - _description.setText(st::webPageDescriptionStyle, textClean(description), _webpageDescriptionOptions); + auto marked = TextWithEntities { textClean(description) }; + auto parseFlags = TextParseLinks | TextParseMultiline | TextParseRichText; + textParseEntities(marked.text, parseFlags, &marked.entities); + _description.setMarkedText(st::webPageDescriptionStyle, marked, _webpageDescriptionOptions); } }