diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 97058d6c4..869118ac5 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -480,10 +480,6 @@ int Element::skipBlockHeight() const { return st::msgDateFont->height - st::msgDateDelta.y(); } -QString Element::skipBlock() const { - return textcmdSkipBlock(skipBlockWidth(), skipBlockHeight()); -} - int Element::infoWidth() const { return 0; } diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index b9be5fecd..92f15bbf8 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -269,7 +269,6 @@ public: int skipBlockWidth() const; int skipBlockHeight() const; - QString skipBlock() const; virtual int infoWidth() const; virtual int bottomInfoFirstLineWidth() const; virtual bool bottomInfoIsWide() const; diff --git a/Telegram/SourceFiles/history/view/media/history_view_game.cpp b/Telegram/SourceFiles/history/view/media/history_view_game.cpp index cf8be3686..0c66cf3a3 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_game.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_game.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_cursor_state.h" #include "history/view/media/history_view_media_common.h" #include "ui/item_text_options.h" +#include "ui/text/text_utilities.h" #include "ui/cached_round_corners.h" #include "ui/chat/chat_style.h" #include "core/ui_integration.h" @@ -70,12 +71,14 @@ QSize Game::countOptimalSize() { if (_description.isEmpty() && !_data->description.isEmpty()) { auto text = _data->description; if (!text.isEmpty()) { - if (!_attach) { - text += _parent->skipBlock(); - } auto marked = TextWithEntities { text }; auto parseFlags = TextParseLinks | TextParseMultiline | TextParseRichText; TextUtilities::ParseEntities(marked, parseFlags); + if (!_attach) { + _description.updateSkipBlock( + _parent->skipBlockWidth(), + _parent->skipBlockHeight()); + } _description.setMarkedText( st::webPageDescriptionStyle, marked, diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index a778c7019..04c5d2f17 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -202,7 +202,9 @@ QSize WebPage::countOptimalSize() { auto text = _data->description; if (textFloatsAroundInfo) { - text.text += _parent->skipBlock(); + _description.updateSkipBlock( + _parent->skipBlockWidth(), + _parent->skipBlockHeight()); } if (isLogEntryOriginal()) { // Fix layout for small bubbles (narrow media caption edit log entries). @@ -232,13 +234,16 @@ QSize WebPage::countOptimalSize() { Ui::WebpageTextTitleOptions()); } if (_title.isEmpty() && !title.isEmpty()) { + auto titleWithEntities = Ui::Text::Link(title, _data->url); if (textFloatsAroundInfo && _description.isEmpty()) { - title += _parent->skipBlock(); + _title.updateSkipBlock( + _parent->skipBlockWidth(), + _parent->skipBlockHeight()); } if (!_siteNameLines && !_data->url.isEmpty()) { _title.setMarkedText( st::webPageTitleStyle, - Ui::Text::Link(title, _data->url), + std::move(titleWithEntities), Ui::WebpageTextTitleOptions()); } else { diff --git a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp index 98a954298..e00361f41 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_preview.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_preview.cpp @@ -284,7 +284,12 @@ int Generator::computeInfoWidth(Status status, QString date) { void Generator::addTextBubble(QString text, QString date, Status status) { Bubble bubble; auto skipBlock = computeSkipBlock(status, date); - bubble.text.setRichText(st::messageTextStyle, text + textcmdSkipBlock(skipBlock.width(), skipBlock.height()), Ui::ItemTextDefaultOptions()); + auto marked = TextWithEntities{ std::move(text) }; + bubble.text.setMarkedText( + st::messageTextStyle, + std::move(marked), + Ui::ItemTextDefaultOptions()); + bubble.text.updateSkipBlock(skipBlock.width(), skipBlock.height()); auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right(); accumulate_min(width, st::msgPadding.left() + bubble.text.maxWidth() + st::msgPadding.right()); @@ -308,7 +313,12 @@ void Generator::addPhotoBubble(QString image, QString caption, QString date, Sta bubble.photoWidth = style::ConvertScale(bubble.photo.width() / 2); bubble.photoHeight = style::ConvertScale(bubble.photo.height() / 2); auto skipBlock = computeSkipBlock(status, date); - bubble.text.setRichText(st::messageTextStyle, caption + textcmdSkipBlock(skipBlock.width(), skipBlock.height()), Ui::ItemTextDefaultOptions()); + auto marked = TextWithEntities{ std::move(caption) }; + bubble.text.setMarkedText( + st::messageTextStyle, + std::move(marked), + Ui::ItemTextDefaultOptions()); + bubble.text.updateSkipBlock(skipBlock.width(), skipBlock.height()); auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right(); accumulate_min(width, bubble.photoWidth);