Improve Ui::Text::String features.

This commit is contained in:
John Preston 2023-10-03 17:50:33 +04:00
parent 2b3f17e982
commit 396c229a4d
31 changed files with 85 additions and 82 deletions

View file

@ -194,7 +194,7 @@ not_null<Ui::FlatLabel*> CreateWarningLabel(
if (value >= 0) { if (value >= 0) {
result->setText(QString::number(value)); result->setText(QString::number(value));
} else { } else {
result->setMarkedText(Ui::Text::PlainLink( result->setMarkedText(Ui::Text::Colorized(
QString::number(value))); QString::number(value)));
} }
result->setVisible(shown); result->setVisible(shown);

View file

@ -75,7 +75,7 @@ constexpr auto kShowChatNamesCount = 8;
.entities = (history->chatListBadgesState().unread .entities = (history->chatListBadgesState().unread
? EntitiesInText{ ? EntitiesInText{
{ EntityType::Semibold, 0, int(name.size()), QString() }, { EntityType::Semibold, 0, int(name.size()), QString() },
{ EntityType::PlainLink, 0, int(name.size()), QString() }, { EntityType::Colorized, 0, int(name.size()), QString() },
} }
: EntitiesInText{}), : EntitiesInText{}),
}; };

View file

@ -85,7 +85,7 @@ using ItemPreviewImage = HistoryView::ItemPreviewImage;
const TextWithEntities &caption, const TextWithEntities &caption,
bool hasMiniImages = false) { bool hasMiniImages = false) {
if (caption.text.isEmpty()) { if (caption.text.isEmpty()) {
return Ui::Text::PlainLink(attachType); return Ui::Text::Colorized(attachType);
} }
return hasMiniImages return hasMiniImages
@ -96,7 +96,7 @@ using ItemPreviewImage = HistoryView::ItemPreviewImage;
tr::lng_dialogs_text_media_wrapped( tr::lng_dialogs_text_media_wrapped(
tr::now, tr::now,
lt_media, lt_media,
Ui::Text::PlainLink(attachType), Ui::Text::Colorized(attachType),
Ui::Text::WithEntities), Ui::Text::WithEntities),
lt_caption, lt_caption,
caption, caption,
@ -558,7 +558,7 @@ ItemPreview Media::toGroupPreview(
: fileCount : fileCount
? tr::lng_in_dlg_file_count(tr::now, lt_count, fileCount) ? tr::lng_in_dlg_file_count(tr::now, lt_count, fileCount)
: tr::lng_in_dlg_album(tr::now); : tr::lng_in_dlg_album(tr::now);
result.text = Ui::Text::PlainLink(genericText); result.text = Ui::Text::Colorized(genericText);
} }
if (!loadingContext.empty()) { if (!loadingContext.empty()) {
result.loadingContext = std::move(loadingContext); result.loadingContext = std::move(loadingContext);
@ -937,7 +937,7 @@ TextWithEntities MediaFile::notificationText() const {
const auto text = _emoji.isEmpty() const auto text = _emoji.isEmpty()
? tr::lng_in_dlg_sticker(tr::now) ? tr::lng_in_dlg_sticker(tr::now)
: tr::lng_in_dlg_sticker_emoji(tr::now, lt_emoji, _emoji); : tr::lng_in_dlg_sticker_emoji(tr::now, lt_emoji, _emoji);
return Ui::Text::PlainLink(text); return Ui::Text::Colorized(text);
} }
const auto type = [&] { const auto type = [&] {
if (_document->isVideoMessage()) { if (_document->isVideoMessage()) {
@ -1719,7 +1719,7 @@ PollData *MediaPoll::poll() const {
} }
TextWithEntities MediaPoll::notificationText() const { TextWithEntities MediaPoll::notificationText() const {
return Ui::Text::PlainLink(_poll->question); return Ui::Text::Colorized(_poll->question);
} }
QString MediaPoll::pinnedTextSubstring() const { QString MediaPoll::pinnedTextSubstring() const {

View file

@ -308,14 +308,14 @@ Image *Story::replyPreview() const {
TextWithEntities Story::inReplyText() const { TextWithEntities Story::inReplyText() const {
const auto type = tr::lng_in_dlg_story(tr::now); const auto type = tr::lng_in_dlg_story(tr::now);
return _caption.text.isEmpty() return _caption.text.isEmpty()
? Ui::Text::PlainLink(type) ? Ui::Text::Colorized(type)
: tr::lng_dialogs_text_media( : tr::lng_dialogs_text_media(
tr::now, tr::now,
lt_media_part, lt_media_part,
tr::lng_dialogs_text_media_wrapped( tr::lng_dialogs_text_media_wrapped(
tr::now, tr::now,
lt_media, lt_media,
Ui::Text::PlainLink(type), Ui::Text::Colorized(type),
Ui::Text::WithEntities), Ui::Text::WithEntities),
lt_caption, lt_caption,
_caption, _caption,

View file

@ -260,7 +260,7 @@ void PaintFolderEntryText(
.now = context.now, .now = context.now,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat), .pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler), .pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.elisionLines = rect.height() / st::dialogsTextFont->height, .elisionHeight = rect.height(),
}); });
} }
@ -420,7 +420,7 @@ void PaintRow(
.now = context.now, .now = context.now,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat), .pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler), .pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.elisionLines = 1, .elisionOneLine = true,
}); });
} else if (draft } else if (draft
|| (supportMode || (supportMode
@ -462,13 +462,13 @@ void PaintRow(
auto &cache = thread->cloudDraftTextCache(); auto &cache = thread->cloudDraftTextCache();
if (cache.isEmpty()) { if (cache.isEmpty()) {
using namespace TextUtilities; using namespace TextUtilities;
auto draftWrapped = Text::PlainLink( auto draftWrapped = Text::Colorized(
tr::lng_dialogs_text_from_wrapped( tr::lng_dialogs_text_from_wrapped(
tr::now, tr::now,
lt_from, lt_from,
tr::lng_from_draft(tr::now))); tr::lng_from_draft(tr::now)));
auto draftText = supportMode auto draftText = supportMode
? Text::PlainLink( ? Text::Colorized(
Support::ChatOccupiedString(history)) Support::ChatOccupiedString(history))
: tr::lng_dialogs_text_with_from( : tr::lng_dialogs_text_with_from(
tr::now, tr::now,
@ -514,7 +514,7 @@ void PaintRow(
.now = context.now, .now = context.now,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat), .pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler), .pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.elisionLines = 1, .elisionOneLine = true,
}); });
} }
} else if (!item) { } else if (!item) {

View file

@ -94,7 +94,7 @@ TextWithEntities DialogsPreviewText(TextWithEntities text) {
EntityType::Underline, EntityType::Underline,
EntityType::Italic, EntityType::Italic,
EntityType::CustomEmoji, EntityType::CustomEmoji,
EntityType::PlainLink, EntityType::Colorized,
}); });
for (auto &entity : result.entities) { for (auto &entity : result.entities) {
if (entity.type() == EntityType::Pre) { if (entity.type() == EntityType::Pre) {
@ -102,6 +102,13 @@ TextWithEntities DialogsPreviewText(TextWithEntities text) {
EntityType::Code, EntityType::Code,
entity.offset(), entity.offset(),
entity.length()); entity.length());
} else if (entity.type() == EntityType::Colorized
&& !entity.data().isEmpty()) {
// Drop 'data' so that only link-color colorization takes place.
entity = EntityInText(
EntityType::Colorized,
entity.offset(),
entity.length());
} }
} }
return result; return result;
@ -188,7 +195,7 @@ void MessageView::prepare(
TextUtilities::Trim(preview.text); TextUtilities::Trim(preview.text);
auto textToCache = DialogsPreviewText(std::move(preview.text)); auto textToCache = DialogsPreviewText(std::move(preview.text));
_hasPlainLinkAtBegin = !textToCache.entities.empty() _hasPlainLinkAtBegin = !textToCache.entities.empty()
&& (textToCache.entities.front().type() == EntityType::PlainLink); && (textToCache.entities.front().type() == EntityType::Colorized);
_textCache.setMarkedText( _textCache.setMarkedText(
st::dialogsTextStyle, st::dialogsTextStyle,
std::move(textToCache), std::move(textToCache),
@ -305,7 +312,6 @@ void MessageView::paint(
rect.setWidth(rect.width() - st::forumDialogJumpArrowSkip); rect.setWidth(rect.width() - st::forumDialogJumpArrowSkip);
finalRight -= st::forumDialogJumpArrowSkip; finalRight -= st::forumDialogJumpArrowSkip;
} }
const auto lines = rect.height() / st::dialogsTextFont->height;
const auto pausedSpoiler = context.paused const auto pausedSpoiler = context.paused
|| On(PowerSaving::kChatSpoiler); || On(PowerSaving::kChatSpoiler);
if (!_senderCache.isEmpty()) { if (!_senderCache.isEmpty()) {
@ -313,7 +319,7 @@ void MessageView::paint(
.position = rect.topLeft(), .position = rect.topLeft(),
.availableWidth = rect.width(), .availableWidth = rect.width(),
.palette = palette, .palette = palette,
.elisionLines = lines, .elisionHeight = rect.height(),
}); });
rect.setLeft(rect.x() + _senderCache.maxWidth()); rect.setLeft(rect.x() + _senderCache.maxWidth());
if (!_imagesCache.empty() && !_leftIcon) { if (!_imagesCache.empty() && !_leftIcon) {
@ -381,7 +387,7 @@ void MessageView::paint(
.now = context.now, .now = context.now,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat), .pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = pausedSpoiler, .pausedSpoiler = pausedSpoiler,
.elisionLines = lines, .elisionHeight = rect.height(),
}); });
rect.setLeft(rect.x() + _textCache.maxWidth()); rect.setLeft(rect.x() + _textCache.maxWidth());
} }
@ -457,7 +463,7 @@ HistoryView::ItemPreview PreviewWithSender(
auto fullWithOffset = tr::lng_dialogs_text_with_from( auto fullWithOffset = tr::lng_dialogs_text_with_from(
tr::now, tr::now,
lt_from_part, lt_from_part,
Ui::Text::PlainLink(std::move(wrappedWithOffset.text)), Ui::Text::Colorized(std::move(wrappedWithOffset.text)),
lt_message, lt_message,
std::move(preview.text), std::move(preview.text),
TextWithTagOffset<lt_from_part>::FromString); TextWithTagOffset<lt_from_part>::FromString);

View file

@ -75,7 +75,7 @@ void TopicsView::prepare(MsgId frontRootId, Fn<void()> customEmojiRepaint) {
title.title.setMarkedText( title.title.setMarkedText(
st::dialogsTextStyle, st::dialogsTextStyle,
(unread (unread
? Ui::Text::PlainLink( ? Ui::Text::Colorized(
Ui::Text::Wrapped( Ui::Text::Wrapped(
std::move(topicTitle), std::move(topicTitle),
EntityType::Bold)) EntityType::Bold))
@ -141,7 +141,7 @@ void TopicsView::paint(
.now = context.now, .now = context.now,
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat), .pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler), .pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.elisionLines = 1, .elisionOneLine = true,
}); });
const auto skip = skipBig const auto skip = skipBig
? context.st->topicsSkipBig ? context.st->topicsSkipBig

View file

@ -45,7 +45,7 @@ void TopBar::updateData(Content &&content) {
.append(" \xe2\x80\x93 ") .append(" \xe2\x80\x93 ")
.append(row.label) .append(row.label)
.append(' ') .append(' ')
.append(Ui::Text::PlainLink(row.info))); .append(Ui::Text::Colorized(row.info)));
_progress->setValue(row.progress); _progress->setValue(row.progress);
} }

View file

@ -2932,9 +2932,7 @@ ItemPreview HistoryItem::toPreview(ToPreviewOptions options) const {
// Because larger version is shown exactly to the left of the small. // Because larger version is shown exactly to the left of the small.
//auto media = _media ? _media->toPreview(options) : ItemPreview(); //auto media = _media ? _media->toPreview(options) : ItemPreview();
return { return {
.text = Ui::Text::Wrapped( .text = Ui::Text::Colorized(notificationText()),
notificationText(),
EntityType::PlainLink),
//.images = std::move(media.images), //.images = std::move(media.images),
//.loadingContext = std::move(media.loadingContext), //.loadingContext = std::move(media.loadingContext),
}; };
@ -3011,7 +3009,7 @@ TextWithEntities HistoryItem::inReplyText() const {
result = Ui::Text::Mid(result, name.size()); result = Ui::Text::Mid(result, name.size());
TextUtilities::Trim(result); TextUtilities::Trim(result);
} }
return Ui::Text::Wrapped(result, EntityType::PlainLink); return Ui::Text::Colorized(result);
} }
const std::vector<ClickHandlerPtr> &HistoryItem::customTextLinks() const { const std::vector<ClickHandlerPtr> &HistoryItem::customTextLinks() const {

View file

@ -630,7 +630,7 @@ void HistoryMessageReply::paint(
.pausedEmoji = (context.paused .pausedEmoji = (context.paused
|| On(PowerSaving::kEmojiChat)), || On(PowerSaving::kEmojiChat)),
.pausedSpoiler = pausedSpoiler, .pausedSpoiler = pausedSpoiler,
.elisionLines = 1, .elisionOneLine = true,
}); });
p.setTextPalette(stm->textPalette); p.setTextPalette(stm->textPalette);
} }

View file

@ -7949,7 +7949,7 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
.now = now, .now = now,
.pausedEmoji = paused || On(PowerSaving::kEmojiChat), .pausedEmoji = paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = pausedSpoiler, .pausedSpoiler = pausedSpoiler,
.elisionLines = 1, .elisionOneLine = true,
}); });
} else { } else {
p.setFont(st::msgDateFont); p.setFont(st::msgDateFont);

View file

@ -902,7 +902,7 @@ void FieldHeader::paintEditOrReplyToMessage(Painter &p) {
.now = crl::now(), .now = crl::now(),
.pausedEmoji = p.inactive() || On(PowerSaving::kEmojiChat), .pausedEmoji = p.inactive() || On(PowerSaving::kEmojiChat),
.pausedSpoiler = p.inactive() || On(PowerSaving::kChatSpoiler), .pausedSpoiler = p.inactive() || On(PowerSaving::kChatSpoiler),
.elisionLines = 1, .elisionOneLine = true,
}); });
} }

View file

@ -181,7 +181,7 @@ void ForwardPanel::updateTexts() {
text = DropCustomEmoji(std::move(text)); text = DropCustomEmoji(std::move(text));
} }
} else { } else {
text = Ui::Text::PlainLink( text = Ui::Text::Colorized(
tr::lng_forward_messages(tr::now, lt_count, count)); tr::lng_forward_messages(tr::now, lt_count, count));
} }
} }
@ -364,7 +364,7 @@ void ForwardPanel::paint(
.now = now, .now = now,
.pausedEmoji = paused || On(PowerSaving::kEmojiChat), .pausedEmoji = paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = pausedSpoiler, .pausedSpoiler = pausedSpoiler,
.elisionLines = 1, .elisionOneLine = true,
}); });
} }

View file

@ -358,15 +358,15 @@ void ServiceMessagePainter::PaintComplexBubble(
} }
} }
QVector<int> ServiceMessagePainter::CountLineWidths( std::vector<int> ServiceMessagePainter::CountLineWidths(
const Ui::Text::String &text, const Ui::Text::String &text,
const QRect &textRect) { const QRect &textRect) {
const auto linesCount = qMax( const auto linesCount = qMax(
textRect.height() / st::msgServiceFont->height, textRect.height() / st::msgServiceFont->height,
1); 1);
auto result = QVector<int>(); auto result = text.countLineWidths(textRect.width(), {
result.reserve(linesCount); .reserve = linesCount,
text.countLineWidths(textRect.width(), &result); });
const auto minDelta = 2 * (Ui::HistoryServiceMsgRadius() const auto minDelta = 2 * (Ui::HistoryServiceMsgRadius()
+ Ui::HistoryServiceMsgInvertedRadius() + Ui::HistoryServiceMsgInvertedRadius()

View file

@ -113,7 +113,7 @@ public:
const QRect &textRect); const QRect &textRect);
private: private:
static QVector<int> CountLineWidths( static std::vector<int> CountLineWidths(
const Ui::Text::String &text, const Ui::Text::String &text,
const QRect &textRect); const QRect &textRect);

View file

@ -257,7 +257,7 @@ void Game::draw(Painter &p, const PaintContext &context) const {
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat), .pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler), .pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.selection = toDescriptionSelection(context.selection), .selection = toDescriptionSelection(context.selection),
.elisionLines = _descriptionLines, .elisionHeight = _descriptionLines * lineHeight,
.elisionRemoveFromEnd = endskip, .elisionRemoveFromEnd = endskip,
}); });
tshift += _descriptionLines * lineHeight; tshift += _descriptionLines * lineHeight;

View file

@ -583,7 +583,9 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
.pausedEmoji = context.paused || On(PowerSaving::kEmojiChat), .pausedEmoji = context.paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler), .pausedSpoiler = context.paused || On(PowerSaving::kChatSpoiler),
.selection = toDescriptionSelection(context.selection), .selection = toDescriptionSelection(context.selection),
.elisionLines = std::max(_descriptionLines, 0), .elisionHeight = ((_descriptionLines > 0)
? (_descriptionLines * lineHeight)
: 0),
.elisionRemoveFromEnd = (_descriptionLines > 0) ? endskip : 0, .elisionRemoveFromEnd = (_descriptionLines > 0) ? endskip : 0,
}); });
tshift += (_descriptionLines > 0) tshift += (_descriptionLines > 0)

View file

@ -524,7 +524,7 @@ void Cover::refreshStatusText() {
_refreshStatusTimer.callOnce(updateIn); _refreshStatusTimer.callOnce(updateIn);
} }
return showOnline return showOnline
? PlainLink(result) ? Ui::Text::Colorized(result)
: TextWithEntities{ .text = result }; : TextWithEntities{ .text = result };
} else if (auto chat = _peer->asChat()) { } else if (auto chat = _peer->asChat()) {
if (!chat->amIn()) { if (!chat->amIn()) {
@ -543,7 +543,7 @@ void Cover::refreshStatusText() {
onlineCount, onlineCount,
channel->isMegagroup()); channel->isMegagroup());
return hasMembersLink return hasMembersLink
? PlainLink(result) ? Ui::Text::Colorized(result)
: TextWithEntities{ .text = result }; : TextWithEntities{ .text = result };
} }
return tr::lng_chat_status_unaccessible(tr::now, WithEntities); return tr::lng_chat_status_unaccessible(tr::now, WithEntities);

View file

@ -133,8 +133,8 @@ bool ValueParser::readTag() {
_tagsUsed.insert(_currentTagIndex); _tagsUsed.insert(_currentTagIndex);
if (_currentTagReplacer.isEmpty()) { if (_currentTagReplacer.isEmpty()) {
_currentTagReplacer = QString(4, TextCommand); _currentTagReplacer = QString(4, QChar(kTextCommand));
_currentTagReplacer[1] = kTextCommandLangTag; _currentTagReplacer[1] = QChar(kTextCommandLangTag);
} }
_currentTagReplacer[2] = QChar(0x0020 + _currentTagIndex); _currentTagReplacer[2] = QChar(0x0020 + _currentTagIndex);
@ -168,8 +168,10 @@ QString PrepareTestValue(const QString &current, QChar filler) {
auto result = QString(size + 1, filler); auto result = QString(size + 1, filler);
auto inCommand = false; auto inCommand = false;
for (auto i = 0; i != size; ++i) { for (auto i = 0; i != size; ++i) {
auto ch = current[i]; const auto ch = current[i];
auto newInCommand = (ch.unicode() == TextCommand) ? (!inCommand) : inCommand; const auto newInCommand = (ch.unicode() == kTextCommand)
? (!inCommand)
: inCommand;
if (inCommand || newInCommand || ch.isSpace()) { if (inCommand || newInCommand || ch.isSpace()) {
result[i + 1] = ch; result[i + 1] = ch;
} }

View file

@ -868,8 +868,10 @@ auto ChoosePlural = ChoosePluralDefault;
int FindTagReplacementPosition(const QString &original, ushort tag) { int FindTagReplacementPosition(const QString &original, ushort tag) {
for (auto s = original.constData(), ch = s, e = ch + original.size(); ch != e;) { for (auto s = original.constData(), ch = s, e = ch + original.size(); ch != e;) {
if (*ch == TextCommand) { if (ch->unicode() == kTextCommand) {
if (ch + kTagReplacementSize <= e && (ch + 1)->unicode() == kTextCommandLangTag && *(ch + 3) == TextCommand) { if (ch + kTagReplacementSize <= e
&& (ch + 1)->unicode() == kTextCommandLangTag
&& (ch + 3)->unicode() == kTextCommand) {
if ((ch + 2)->unicode() == 0x0020 + tag) { if ((ch + 2)->unicode() == 0x0020 + tag) {
return ch - s; return ch - s;
} else { } else {

View file

@ -11,11 +11,12 @@ enum lngtag_count : int;
namespace Lang { namespace Lang {
inline constexpr auto kTextCommand = 0x10;
inline constexpr auto kTextCommandLangTag = 0x20; inline constexpr auto kTextCommandLangTag = 0x20;
constexpr auto kTagReplacementSize = 4; constexpr auto kTagReplacementSize = 4;
[[nodiscard]] int FindTagReplacementPosition( [[nodiscard]] int FindTagReplacementPosition(
const QString &original, const QString &original,
ushort tag); ushort tag);
struct ShortenedCount { struct ShortenedCount {

View file

@ -5014,7 +5014,7 @@ void OverlayWidget::paintCaptionContent(
.spoiler = Ui::Text::DefaultSpoilerCache(), .spoiler = Ui::Text::DefaultSpoilerCache(),
.pausedEmoji = On(PowerSaving::kEmojiChat), .pausedEmoji = On(PowerSaving::kEmojiChat),
.pausedSpoiler = On(PowerSaving::kChatSpoiler), .pausedSpoiler = On(PowerSaving::kChatSpoiler),
.elisionLines = inner.height() / lineHeight, .elisionHeight = inner.height(),
.elisionRemoveFromEnd = _captionSkipBlockWidth, .elisionRemoveFromEnd = _captionSkipBlockWidth,
}); });

View file

@ -888,17 +888,13 @@ void Panel::showWebviewError(
rich.append("\n\n"); rich.append("\n\n");
switch (information.error) { switch (information.error) {
case Error::NoWebview2: { case Error::NoWebview2: {
const auto command = QString(QChar(TextCommand)); rich.append(tr::lng_payments_webview_install_edge(
const auto text = tr::lng_payments_webview_install_edge(
tr::now, tr::now,
lt_link, lt_link,
command); Text::Link(
const auto parts = text.split(command);
rich.append(parts.value(0))
.append(Text::Link(
"Microsoft Edge WebView2 Runtime", "Microsoft Edge WebView2 Runtime",
"https://go.microsoft.com/fwlink/p/?LinkId=2124703")) "https://go.microsoft.com/fwlink/p/?LinkId=2124703"),
.append(parts.value(1)); Ui::Text::WithEntities));
} break; } break;
case Error::NoWebKitGTK: case Error::NoWebKitGTK:
rich.append(tr::lng_payments_webview_install_webkit(tr::now)); rich.append(tr::lng_payments_webview_install_webkit(tr::now));

View file

@ -1265,17 +1265,13 @@ void Panel::showWebviewError(
rich.append("\n\n"); rich.append("\n\n");
switch (information.error) { switch (information.error) {
case Error::NoWebview2: { case Error::NoWebview2: {
const auto command = QString(QChar(TextCommand)); rich.append(tr::lng_payments_webview_install_edge(
const auto text = tr::lng_payments_webview_install_edge(
tr::now, tr::now,
lt_link, lt_link,
command); Text::Link(
const auto parts = text.split(command);
rich.append(parts.value(0))
.append(Text::Link(
"Microsoft Edge WebView2 Runtime", "Microsoft Edge WebView2 Runtime",
"https://go.microsoft.com/fwlink/p/?LinkId=2124703")) "https://go.microsoft.com/fwlink/p/?LinkId=2124703"),
.append(parts.value(1)); Ui::Text::WithEntities));
} break; } break;
case Error::NoWebKitGTK: case Error::NoWebKitGTK:
rich.append(tr::lng_payments_webview_install_webkit(tr::now)); rich.append(tr::lng_payments_webview_install_webkit(tr::now));

View file

@ -469,9 +469,9 @@ void ChatStyle::assignPalette(not_null<const style::palette*> palette) {
} }
for (auto &stm : _messageStyles) { for (auto &stm : _messageStyles) {
const auto same = (stm.textPalette.linkFg->c == stm.historyTextFg->c); stm.textPalette.linkAlwaysActive
stm.textPalette.linkAlwaysActive = same ? 1 : 0; = stm.semiboldPalette.linkAlwaysActive
stm.semiboldPalette.linkAlwaysActive = same ? 1 : 0; = (stm.textPalette.linkFg->c == stm.historyTextFg->c);
} }
_paletteChanged.fire({}); _paletteChanged.fire({});

View file

@ -457,7 +457,7 @@ void MessageBar::paint(Painter &p) {
.now = now, .now = now,
.pausedEmoji = paused || On(PowerSaving::kEmojiChat), .pausedEmoji = paused || On(PowerSaving::kEmojiChat),
.pausedSpoiler = pausedSpoiler, .pausedSpoiler = pausedSpoiler,
.elisionLines = 1, .elisionOneLine = true,
}); });
} }
} else if (_animation->bodyAnimation == BodyAnimation::Text) { } else if (_animation->bodyAnimation == BodyAnimation::Text) {

View file

@ -444,7 +444,7 @@ void EmptyUserpic::fillString(const QString &name) {
} }
} else if (!letterFound && ch->isLetterOrNumber()) { } else if (!letterFound && ch->isLetterOrNumber()) {
letterFound = true; letterFound = true;
if (ch + 1 != end && Ui::Text::IsDiac(*(ch + 1))) { if (ch + 1 != end && Ui::Text::IsDiacritic(*(ch + 1))) {
letters.push_back(QString(ch, 2)); letters.push_back(QString(ch, 2));
levels.push_back(level); levels.push_back(level);
++ch; ++ch;

View file

@ -76,7 +76,7 @@ TextParseOptions TextNameOptions = {
}; };
TextParseOptions TextDialogOptions = { TextParseOptions TextDialogOptions = {
TextParsePlainLinks | TextParseMarkdown, // flags TextParseColorized | TextParseMarkdown, // flags
0, // maxw is style-dependent 0, // maxw is style-dependent
1, // maxh 1, // maxh
Qt::LayoutDirectionAuto, // lang-dependent Qt::LayoutDirectionAuto, // lang-dependent

View file

@ -828,7 +828,7 @@ void Notification::paintTitle(Painter &p) {
.spoiler = Ui::Text::DefaultSpoilerCache(), .spoiler = Ui::Text::DefaultSpoilerCache(),
.pausedEmoji = On(PowerSaving::kEmojiChat), .pausedEmoji = On(PowerSaving::kEmojiChat),
.pausedSpoiler = On(PowerSaving::kChatSpoiler), .pausedSpoiler = On(PowerSaving::kChatSpoiler),
.elisionLines = 1, .elisionOneLine = true,
}); });
} }
@ -842,7 +842,7 @@ void Notification::paintText(Painter &p) {
.spoiler = Ui::Text::DefaultSpoilerCache(), .spoiler = Ui::Text::DefaultSpoilerCache(),
.pausedEmoji = On(PowerSaving::kEmojiChat), .pausedEmoji = On(PowerSaving::kEmojiChat),
.pausedSpoiler = On(PowerSaving::kChatSpoiler), .pausedSpoiler = On(PowerSaving::kChatSpoiler),
.elisionLines = _textRect.height() / st::dialogsTextFont->height, .elisionHeight = _textRect.height(),
}); });
} }
@ -922,7 +922,7 @@ void Notification::updateNotifyDisplay() {
2 * st::dialogsTextFont->height); 2 * st::dialogsTextFont->height);
const auto text = !_reaction.empty() const auto text = !_reaction.empty()
? (!_author.isEmpty() ? (!_author.isEmpty()
? Ui::Text::PlainLink(_author).append(' ') ? Ui::Text::Colorized(_author).append(' ')
: TextWithEntities() : TextWithEntities()
).append(Manager::ComposeReactionNotification( ).append(Manager::ComposeReactionNotification(
_item, _item,
@ -935,7 +935,7 @@ void Notification::updateNotifyDisplay() {
.spoilerLoginCode = options.spoilerLoginCode, .spoilerLoginCode = options.spoilerLoginCode,
}).text }).text
: ((!_author.isEmpty() : ((!_author.isEmpty()
? Ui::Text::PlainLink(_author) ? Ui::Text::Colorized(_author)
: TextWithEntities() : TextWithEntities()
).append(_forwardedCount > 1 ).append(_forwardedCount > 1
? ('\n' + tr::lng_forward_messages( ? ('\n' + tr::lng_forward_messages(
@ -944,7 +944,7 @@ void Notification::updateNotifyDisplay() {
_forwardedCount)) _forwardedCount))
: QString())); : QString()));
const auto options = TextParseOptions{ const auto options = TextParseOptions{
(TextParsePlainLinks (TextParseColorized
| TextParseMarkdown | TextParseMarkdown
| (_forwardedCount > 1 ? TextParseMultiline : 0)), | (_forwardedCount > 1 ? TextParseMultiline : 0)),
0, 0,

View file

@ -47,7 +47,7 @@ namespace {
} }
} else if (!letterFound && ch->isLetterOrNumber()) { } else if (!letterFound && ch->isLetterOrNumber()) {
letterFound = true; letterFound = true;
if (ch + 1 != end && Ui::Text::IsDiac(*(ch + 1))) { if (ch + 1 != end && Ui::Text::IsDiacritic(*(ch + 1))) {
letters.push_back(QString(ch, 2)); letters.push_back(QString(ch, 2));
levels.push_back(level); levels.push_back(level);
++ch; ++ch;
@ -353,25 +353,25 @@ void Generator::generateData() {
"Mike Apple", "Mike Apple",
2, 2,
"9:00", "9:00",
Ui::Text::PlainLink(QChar(55357) Ui::Text::Colorized(QChar(55357)
+ QString() + QString()
+ QChar(56836) + QChar(56836)
+ " Sticker")); + " Sticker"));
_rows.back().unreadCounter = 2; _rows.back().unreadCounter = 2;
_rows.back().muted = true; _rows.back().muted = true;
addRow("Evening Club", 1, "8:00", Ui::Text::PlainLink("Eva: Photo")); addRow("Evening Club", 1, "8:00", Ui::Text::Colorized("Eva: Photo"));
_rows.back().type = Row::Type::Group; _rows.back().type = Row::Type::Group;
addRow( addRow(
"Old Pirates", "Old Pirates",
6, 6,
"7:00", "7:00",
Ui::Text::PlainLink("Max:").append(" Yo-ho-ho!")); Ui::Text::Colorized("Max:").append(" Yo-ho-ho!"));
_rows.back().type = Row::Type::Group; _rows.back().type = Row::Type::Group;
addRow("Max Bright", 3, "6:00", { .text = "How about some coffee?" }); addRow("Max Bright", 3, "6:00", { .text = "How about some coffee?" });
_rows.back().status = Status::Received; _rows.back().status = Status::Received;
addRow("Natalie Parker", 4, "5:00", { .text = "OK, great)" }); addRow("Natalie Parker", 4, "5:00", { .text = "OK, great)" });
_rows.back().status = Status::Received; _rows.back().status = Status::Received;
addRow("Davy Jones", 5, "4:00", Ui::Text::PlainLink("Keynote.pdf")); addRow("Davy Jones", 5, "4:00", Ui::Text::Colorized("Keynote.pdf"));
_topBarName.setText(st::msgNameStyle, "Eva Summer", Ui::NameTextOptions()); _topBarName.setText(st::msgNameStyle, "Eva Summer", Ui::NameTextOptions());
_topBarStatus = "online"; _topBarStatus = "online";

@ -1 +1 @@
Subproject commit 93458e4cb3845c9743bb0c0a78f1e6ce7ee99363 Subproject commit 02440524eaa2b1bd6d1909ff4aa2ca207a282b2c