Use more simple tr::... text helpers.

This commit is contained in:
John Preston
2025-12-15 12:15:25 +04:00
parent 629158fedb
commit 08a979e638
213 changed files with 1657 additions and 1643 deletions
@@ -80,7 +80,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rect.h"
#include "ui/ui_utility.h"
#include "ui/text/format_values.h"
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
#include "ui/text/text_variant.h"
#include "ui/toast/toast.h"
#include "ui/vertical_list.h"
@@ -144,7 +143,7 @@ base::options::toggle ShowChannelJoinedBelowAbout({
end(usernames));
for (auto &username : std::move(subrange)) {
const auto isLast = (usernames.back() == username);
result.append(Ui::Text::Link(
result.append(tr::link(
'@' + base::take(username.text),
username.entities.front().data()));
if (!isLast) {
@@ -162,8 +161,8 @@ base::options::toggle ShowChannelJoinedBelowAbout({
UsernamesValue(peer) | rpl::map([](std::vector<TextWithEntities> v) {
return !v.empty();
}),
tr::lng_filters_link_subtitle(Ui::Text::WithEntities),
tr::lng_info_link_topic_label(Ui::Text::WithEntities));
tr::lng_filters_link_subtitle(tr::marked),
tr::lng_info_link_topic_label(tr::marked));
}
[[nodiscard]] Fn<void(QString)> UsernamesLinkCallback(
@@ -238,7 +237,7 @@ base::options::toggle ShowChannelJoinedBelowAbout({
? tr::lng_you_joined_group
: tr::lng_action_you_joined)(
tr::now,
Ui::Text::Italic));
tr::italic));
value.append(Italic(": "));
const auto raw = channel->inviteDate;
value.append(Link(
@@ -874,7 +873,7 @@ void DeleteContactNote(
auto label = BirthdayLabelText(rpl::duplicate(birthday));
auto text = BirthdayValueText(
rpl::duplicate(birthday)
) | Ui::Text::ToWithEntities();
) | rpl::map(tr::marked);
const auto giftIcon = Ui::CreateChild<Ui::RpWidget>(layout);
giftIcon->resize(st::birthdayTodayIcon.size());
@@ -983,7 +982,7 @@ template <typename Text, typename ToggleOn, typename Callback>
const style::SettingsButton &st = st::infoMainButton) {
const auto button = AddActionButton(
parent,
std::move(text) | Ui::Text::ToUpper(),
std::move(text) | rpl::map(tr::upper),
std::move(toggleOn),
std::move(callback),
nullptr,
@@ -1635,7 +1634,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
UsernameValue(user, true) | rpl::map([=](TextWithEntities u) {
return u.text.isEmpty()
? TextWithEntities()
: Ui::Text::Link(u, UsernameUrl(user, u.text.mid(1)));
: tr::link(u, UsernameUrl(user, u.text.mid(1)));
}),
QString(),
st::infoProfileLabeledUsernamePadding);
@@ -1683,7 +1682,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
} else if (!details.location.point) {
return TextWithEntities{ details.location.address };
}
return Ui::Text::Link(
return tr::link(
TextUtilities::SingleLine(details.location.address),
LocationClickHandler::Url(*details.location.point));
});
@@ -1706,7 +1705,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
const auto text = link.text;
return text.isEmpty()
? TextWithEntities()
: Ui::Text::Link(
: tr::link(
(text.startsWith(u"https://"_q)
? text.mid(u"https://"_q.size())
: text) + addToLink,
@@ -1749,7 +1748,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
channel
) | rpl::map([](const ChannelLocation *location) {
return location
? Ui::Text::Link(
? tr::link(
TextUtilities::SingleLine(location->address),
LocationClickHandler::Url(location->point))
: TextWithEntities();
@@ -1794,7 +1793,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupPersonalChannel(
const auto channelLabelFactory = [=](rpl::producer<ChannelData*> c) {
return rpl::combine(
tr::lng_info_personal_channel_label(Ui::Text::WithEntities),
tr::lng_info_personal_channel_label(tr::marked),
std::move(c)
) | rpl::map([](TextWithEntities &&text, ChannelData *channel) {
const auto count = channel ? channel->membersCount() : 0;
@@ -1850,7 +1849,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupPersonalChannel(
) | rpl::map([=](ChannelData *channel) {
return channel ? NameValue(channel) : rpl::single(QString());
}) | rpl::flatten_latest() | rpl::map([](const QString &name) {
return name.isEmpty() ? TextWithEntities() : Ui::Text::Link(name);
return name.isEmpty() ? TextWithEntities() : tr::link(name);
});
auto line = CreateTextWithLabel(
result,
@@ -2111,8 +2110,8 @@ void DetailsFiller::setupMainApp() {
rpl::combine(
tr::lng_profile_open_app_about(
lt_terms,
tr::lng_profile_open_app_terms() | Ui::Text::ToLink(url),
Ui::Text::WithEntities),
tr::lng_profile_open_app_terms(tr::url(url)),
tr::marked),
user->session().changes().peerFlagsValue(
user,
Data::PeerUpdate::Flag::VerifyInfo)
@@ -2389,8 +2388,8 @@ void ActionsFiller::addAffiliateProgram(not_null<UserData*> user) {
lt_bot,
rpl::single(TextWithEntities{ user->name() }),
lt_amount,
rpl::duplicate(commission) | Ui::Text::ToWithEntities(),
Ui::Text::RichLangValue));
rpl::duplicate(commission) | rpl::map(tr::marked),
tr::rich));
Ui::AddSkip(inner);
wrap->toggleOn(std::move(