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

View File

@@ -141,7 +141,6 @@ void AddFeaturesList(
st,
st::boostFeatureIconPosition);
};
const auto proj = &Ui::Text::RichLangValue;
const auto lowMax = std::max({
features.linkLogoLevel,
features.profileIconLevel,
@@ -206,13 +205,15 @@ void AddFeaturesList(
}, line->lifetime());
}
if (i >= features.sponsoredLevel) {
add(tr::lng_channel_earn_off(proj), st::boostFeatureOffSponsored);
add(
tr::lng_channel_earn_off(tr::rich),
st::boostFeatureOffSponsored);
}
if (i >= features.customWallpaperLevel) {
add(
(group
? tr::lng_feature_custom_background_group
: tr::lng_feature_custom_background_channel)(proj),
: tr::lng_feature_custom_background_channel)(tr::rich),
st::boostFeatureCustomBackground);
}
if (i >= features.wallpaperLevel) {
@@ -222,12 +223,12 @@ void AddFeaturesList(
: tr::lng_feature_backgrounds_channel)(
lt_count,
rpl::single(float64(features.wallpapersCount)),
proj),
tr::rich),
st::boostFeatureBackground);
}
if (i >= features.emojiStatusLevel) {
add(
tr::lng_feature_emoji_status(proj),
tr::lng_feature_emoji_status(tr::rich),
st::boostFeatureEmojiStatus);
}
if (const auto j = features.profileColorsByLevel.find(i)
@@ -238,7 +239,7 @@ void AddFeaturesList(
add(
(group
? tr::lng_feature_profile_icon_group
: tr::lng_feature_profile_icon_channel)(proj),
: tr::lng_feature_profile_icon_channel)(tr::rich),
st::boostFeatureProfileIcon);
}
if (profileColors > 0) {
@@ -247,7 +248,7 @@ void AddFeaturesList(
: tr::lng_feature_profile_color_channel)(
lt_count,
rpl::single(float64(profileColors)),
proj
tr::rich
), st::boostFeatureProfileColor);
}
if (!group) {
@@ -257,14 +258,14 @@ void AddFeaturesList(
}
if (i >= features.linkLogoLevel) {
add(
tr::lng_feature_link_emoji(proj),
tr::lng_feature_link_emoji(tr::rich),
st::boostFeatureCustomLink);
}
if (linkStyles > 0) {
add(tr::lng_feature_link_style_channel(
lt_count,
rpl::single(float64(linkStyles)),
proj
tr::rich
), st::boostFeatureLink);
}
if (const auto j = features.nameColorsByLevel.find(i)
@@ -275,31 +276,31 @@ void AddFeaturesList(
add(tr::lng_feature_name_color_channel(
lt_count,
rpl::single(float64(nameColors)),
proj
tr::rich
), st::boostFeatureName);
}
add(tr::lng_feature_reactions(
lt_count,
rpl::single(float64(i)),
proj
tr::rich
), st::boostFeatureCustomReactions);
}
add(
tr::lng_feature_stories(lt_count, rpl::single(float64(i)), proj),
tr::lng_feature_stories(lt_count, rpl::single(1. * i), tr::rich),
st::boostFeatureStories);
if (!group && i >= features.autotranslateLevel) {
add(
tr::lng_feature_autotranslate(proj),
tr::lng_feature_autotranslate(tr::rich),
st::boostFeatureAutoTranslate);
}
if (group && i >= features.transcribeLevel) {
add(
tr::lng_feature_transcribe(proj),
tr::lng_feature_transcribe(tr::rich),
st::boostFeatureTranscribe);
}
if (group && i >= features.emojiPackLevel) {
add(
tr::lng_feature_custom_emoji_pack(proj),
tr::lng_feature_custom_emoji_pack(tr::rich),
st::boostFeatureCustomEmoji);
}
}
@@ -391,7 +392,7 @@ void BoostBox(
? (wasLifting
- std::clamp(counters.mine - wasMine, 0, wasLifting - 1))
: 0;
const auto bold = Ui::Text::Bold(name);
const auto bold = tr::bold(name);
const auto now = counters.boosts;
const auto full = !counters.nextLevelBoosts;
const auto left = (counters.nextLevelBoosts > now)
@@ -400,14 +401,14 @@ void BoostBox(
auto post = tr::lng_boost_channel_post_stories(
lt_count,
rpl::single(float64(counters.level + (left ? 1 : 0))),
Ui::Text::RichLangValue);
tr::rich);
return (lifting > 1)
? tr::lng_boost_group_lift_restrictions_many(
lt_count,
rpl::single(float64(lifting)),
Ui::Text::RichLangValue)
tr::rich)
: lifting
? tr::lng_boost_group_lift_restrictions(Ui::Text::RichLangValue)
? tr::lng_boost_group_lift_restrictions(tr::rich)
: (counters.mine || full)
? (left
? tr::lng_boost_channel_needs_unlock(
@@ -415,12 +416,12 @@ void BoostBox(
rpl::single(float64(left)),
lt_channel,
rpl::single(bold),
Ui::Text::RichLangValue)
tr::rich)
: (!counters.level
? (data.group
? tr::lng_boost_channel_reached_first_group
: tr::lng_boost_channel_reached_first)(
Ui::Text::RichLangValue)
tr::rich)
: (data.group
? tr::lng_boost_channel_reached_more_group
: tr::lng_boost_channel_reached_more)(
@@ -428,13 +429,13 @@ void BoostBox(
rpl::single(float64(counters.level)),
lt_post,
std::move(post),
Ui::Text::RichLangValue)))
tr::rich)))
: tr::lng_boost_channel_needs_unlock(
lt_count,
rpl::single(float64(left)),
lt_channel,
rpl::single(bold),
Ui::Text::RichLangValue);
tr::rich);
}) | rpl::flatten_latest();
if (wasLifting) {
state->data.value(
@@ -657,7 +658,7 @@ void BoostBoxAlready(not_null<GenericBox*> box, bool group) {
ConfirmBox(box, {
.text = (group
? tr::lng_boost_error_already_text_group
: tr::lng_boost_error_already_text)(Text::RichLangValue),
: tr::lng_boost_error_already_text)(tr::rich),
.title = tr::lng_boost_error_already_title(),
.inform = true,
});
@@ -676,7 +677,7 @@ void GiftForBoostsBox(
rpl::single(receive) | tr::to_count(),
lt_channel,
rpl::single(TextWithEntities{ channel }),
Text::RichLangValue),
tr::rich),
.title = tr::lng_boost_need_more(),
.inform = true,
});
@@ -686,7 +687,7 @@ void GiftedNoBoostsBox(not_null<GenericBox*> box, bool group) {
InformBox(box, {
.text = (group
? tr::lng_boost_error_gifted_text_group
: tr::lng_boost_error_gifted_text)(Text::RichLangValue),
: tr::lng_boost_error_gifted_text)(tr::rich),
.title = tr::lng_boost_error_gifted_title(),
});
}
@@ -698,7 +699,7 @@ void PremiumForBoostsBox(
ConfirmBox(box, {
.text = (group
? tr::lng_boost_error_premium_text_group
: tr::lng_boost_error_premium_text)(Text::RichLangValue),
: tr::lng_boost_error_premium_text)(tr::rich),
.confirmed = buyPremium,
.confirmText = tr::lng_boost_error_premium_yes(),
.title = tr::lng_boost_error_premium_title(),
@@ -746,12 +747,12 @@ void AskBoostBox(
return tr::lng_boost_channel_needs_level_color(
lt_count,
rpl::single(float64(data.requiredLevel)),
Ui::Text::RichLangValue);
tr::rich);
}, [&](AskBoostAutotranslate data) {
return tr::lng_boost_channel_needs_level_autotranslate(
lt_count,
rpl::single(float64(data.requiredLevel)),
Ui::Text::RichLangValue);
tr::rich);
}, [&](AskBoostWallpaper data) {
isGroup = data.group;
return (data.group
@@ -759,7 +760,7 @@ void AskBoostBox(
: tr::lng_boost_channel_needs_level_wallpaper)(
lt_count,
rpl::single(float64(data.requiredLevel)),
Ui::Text::RichLangValue);
tr::rich);
}, [&](AskBoostEmojiStatus data) {
isGroup = data.group;
return (data.group
@@ -767,35 +768,35 @@ void AskBoostBox(
: tr::lng_boost_channel_needs_level_status)(
lt_count,
rpl::single(float64(data.requiredLevel)),
Ui::Text::RichLangValue);
tr::rich);
}, [&](AskBoostEmojiPack data) {
isGroup = true;
return tr::lng_boost_group_needs_level_emoji(
lt_count,
rpl::single(float64(data.requiredLevel)),
Ui::Text::RichLangValue);
tr::rich);
}, [&](AskBoostCustomReactions data) {
return tr::lng_boost_channel_needs_level_reactions(
lt_count,
rpl::single(float64(data.count)),
lt_same_count,
rpl::single(TextWithEntities{ QString::number(data.count) }),
Ui::Text::RichLangValue);
tr::rich);
}, [&](AskBoostCpm data) {
return tr::lng_boost_channel_needs_level_cpm(
lt_count,
rpl::single(float64(data.requiredLevel)),
Ui::Text::RichLangValue);
tr::rich);
}, [&](AskBoostWearCollectible data) {
return tr::lng_boost_channel_needs_level_wear(
lt_count,
rpl::single(float64(data.requiredLevel)),
Ui::Text::RichLangValue);
tr::rich);
});
auto text = rpl::combine(
std::move(reasonText),
(isGroup ? tr::lng_boost_group_ask : tr::lng_boost_channel_ask)(
Ui::Text::RichLangValue)
tr::rich)
) | rpl::map([](TextWithEntities &&text, TextWithEntities &&ask) {
return text.append(u"\n\n"_q).append(std::move(ask));
});

View File

@@ -290,7 +290,7 @@ object_ptr<Ui::RpWidget> ChooseRepeatPeriod(
) | rpl::on_next([=](TimeId value, bool locked) {
auto result = tr::lng_schedule_repeat_label(
tr::now,
Ui::Text::WithEntities);
tr::marked);
const auto text = [&] {
const auto i = ranges::lower_bound(
@@ -301,8 +301,8 @@ object_ptr<Ui::RpWidget> ChooseRepeatPeriod(
return (i != end(map)) ? i->text : map.back().text;
}();
label->setMarkedText(result.append(' ').append(Ui::Text::Link(
Ui::Text::Bold(text).append(
label->setMarkedText(result.append(' ').append(tr::link(
tr::bold(text).append(
Ui::Text::IconEmoji(locked
? &st::scheduleRepeatDropdownLock
: &st::scheduleRepeatDropdownArrow))

View File

@@ -178,13 +178,13 @@ void CollectibleInfoBox(
? tr::lng_collectible_phone_title(
tr::now,
lt_phone,
Ui::Text::Link(formatted),
Ui::Text::WithEntities)
tr::link(formatted),
tr::marked)
: tr::lng_collectible_username_title(
tr::now,
lt_username,
Ui::Text::Link(formatted),
Ui::Text::WithEntities);
tr::link(formatted),
tr::marked);
const auto copyCallback = [box, type, formatted, text = info.copyText](
bool copyLink) {
QGuiApplication::clipboard()->setText((text.isEmpty() || !copyLink)
@@ -218,7 +218,7 @@ void CollectibleInfoBox(
TextWithEntities{ FormatDate(info.date) },
lt_price,
FormatPrice(info),
Ui::Text::RichLangValue);
tr::rich);
const auto label = box->addRow(
object_ptr<Ui::FlatLabel>(box, st::collectibleInfo),
st::collectibleInfoPadding,

View File

@@ -51,8 +51,8 @@ void ConfirmPhoneBox::prepare() {
this,
tr::lng_confirm_phone_about(
lt_phone,
rpl::single(Ui::Text::Bold(Ui::FormatPhone(_phone))),
Ui::Text::WithEntities),
rpl::single(tr::bold(Ui::FormatPhone(_phone))),
tr::marked),
st::confirmPhoneAboutLabel);
_code.create(this, st::confirmPhoneCodeField, tr::lng_code_ph());

View File

@@ -135,13 +135,13 @@ InviteLinkSubscriptionToggle FillCreateInviteLinkSubscriptionToggle(
tr::lng_group_invite_subscription_about_link(
lt_emoji,
rpl::single(Ui::Text::IconEmoji(&st::textMoreIconEmoji)),
Ui::Text::RichLangValue
tr::rich
) | rpl::map([](TextWithEntities text) {
return Ui::Text::Link(
return tr::link(
std::move(text),
tr::lng_group_invite_subscription_about_url(tr::now));
}),
Ui::Text::RichLangValue),
tr::rich),
st::boxDividerLabel);
Ui::AddSkip(wrap->entity());
Ui::AddSkip(wrap->entity());

View File

@@ -83,14 +83,14 @@ void ShowOrPremiumBox(
tr::lng_lastseen_show_about(
lt_user,
rpl::single(TextWithEntities{ shortName }),
Text::RichLangValue),
tr::rich),
tr::lng_lastseen_show_button(),
tr::lng_lastseen_or(),
tr::lng_lastseen_premium_title(),
tr::lng_lastseen_premium_about(
lt_user,
rpl::single(TextWithEntities{ shortName }),
Text::RichLangValue),
tr::rich),
tr::lng_lastseen_premium_button(),
tr::lng_lastseen_shown_toast(tr::now),
u"show_or_premium_lastseen"_q,
@@ -100,14 +100,14 @@ void ShowOrPremiumBox(
tr::lng_readtime_show_about(
lt_user,
rpl::single(TextWithEntities{ shortName }),
Text::RichLangValue),
tr::rich),
tr::lng_readtime_show_button(),
tr::lng_readtime_or(),
tr::lng_readtime_premium_title(),
tr::lng_readtime_premium_about(
lt_user,
rpl::single(TextWithEntities{ shortName }),
Text::RichLangValue),
tr::rich),
tr::lng_readtime_premium_button(),
tr::lng_readtime_shown_toast(tr::now),
u"show_or_premium_readtime"_q,

View File

@@ -197,12 +197,12 @@ void Action::refresh(const DownloadsEntry &entry) {
? TextWithEntities{
FormatProgressText(entry.ready, entry.total),
}
: tr::lng_bot_download_starting(tr::now, Text::WithEntities))
: tr::lng_bot_download_starting(tr::now, tr::marked))
: tr::lng_bot_download_failed(
tr::now,
lt_retry,
Text::Link(tr::lng_bot_download_retry(tr::now)),
Text::WithEntities);
tr::marked);
_progress.setMarkedText(progressText);
const auto enabled = isEnabled();

View File

@@ -2121,7 +2121,7 @@ TextWithEntities ErrorText(const Webview::Available &info) {
Text::Link(
"Microsoft Edge WebView2 Runtime",
"https://go.microsoft.com/fwlink/p/?LinkId=2124703"),
Ui::Text::WithEntities);
tr::marked);
case Error::NoWebKitGTK:
return { tr::lng_payments_webview_install_webkit(tr::now) };
case Error::OldWindows:

View File

@@ -243,11 +243,11 @@ void SetupSendAsButton(
tr::lng_send_as_premium_required(
tr::now,
lt_link,
Ui::Text::Link(
Ui::Text::Bold(
tr::link(
tr::bold(
tr::lng_send_as_premium_required_link(
tr::now))),
Ui::Text::WithEntities),
tr::marked),
u"send_as"_q);
return false;
}

View File

@@ -343,8 +343,8 @@ void ChooseThemeController::initButtons() {
Ui::ConfirmBox(box, {
.text = tr::lng_chat_theme_gift_replace(
lt_name,
rpl::single(Ui::Text::Bold(nowHasTheme->shortName())),
Ui::Text::WithEntities),
rpl::single(tr::bold(nowHasTheme->shortName())),
tr::marked),
.confirmed = confirmed,
.confirmText = tr::lng_box_yes(),
});

View File

@@ -86,7 +86,7 @@ void DownloadBar::show(DownloadBarContent &&content) {
_title.setMarkedText(
st::defaultTextStyle,
(content.count > 1
? Ui::Text::Bold(
? tr::bold(
tr::lng_profile_files(tr::now, lt_count, content.count))
: content.singleName));
refreshInfo(_progress.current());
@@ -139,7 +139,7 @@ void DownloadBar::refreshInfo(const DownloadBarProgress &progress) {
_info.setMarkedText(
st::downloadInfoStyle,
(progress.ready < progress.total
? Text::WithEntities(
? tr::marked(
FormatDownloadText(progress.ready, progress.total))
: Text::Link((_content.count > 1)
? tr::lng_downloads_view_in_section(tr::now)

View File

@@ -513,33 +513,33 @@ object_ptr<RoundButton> FilterLinkProcessButton(
case FilterLinkHeaderType::AddingFilter:
return badge.isEmpty()
? tr::lng_filters_by_link_add_no(
Ui::Text::WithEntities
tr::marked
) | with(QString())
: tr::lng_filters_by_link_add_button(
lt_folder,
rpl::single(title),
Ui::Text::WithEntities
tr::marked
) | with(badge);
case FilterLinkHeaderType::AddingChats:
return badge.isEmpty()
? tr::lng_filters_by_link_join_no(
Ui::Text::WithEntities
tr::marked
) | with(QString())
: tr::lng_filters_by_link_and_join_button(
lt_count,
rpl::single(float64(count)),
Ui::Text::WithEntities) | with(badge);
tr::marked) | with(badge);
case FilterLinkHeaderType::AllAdded:
return tr::lng_box_ok(Ui::Text::WithEntities) | with(QString());
return tr::lng_box_ok(tr::marked) | with(QString());
case FilterLinkHeaderType::Removing:
return badge.isEmpty()
? tr::lng_filters_by_link_remove_button(
Ui::Text::WithEntities
tr::marked
) | with(QString())
: tr::lng_filters_by_link_and_quit_button(
lt_count,
rpl::single(float64(count)),
Ui::Text::WithEntities) | with(badge);
tr::marked) | with(badge);
}
Unexpected("Type in FilterLinkProcessButton.");
}) | rpl::flatten_latest();

View File

@@ -546,7 +546,7 @@ void SetupEmptyView(
(query ? Icon::NoResults : Icon::Search),
(query
? tr::lng_maps_no_places
: tr::lng_maps_choose_to_search)(Text::WithEntities));
: tr::lng_maps_choose_to_search)(tr::marked));
view->setMinimalHeight(st::recentPeersEmptyHeightMin);
view->show();

View File

@@ -239,20 +239,20 @@ void AboutRatingBox(
? tr::lng_stars_rating_about(
lt_name,
rpl::single(TextWithEntities{ name }),
Text::RichLangValue) | rpl::type_erased
tr::rich) | rpl::type_erased
: tr::lng_stars_rating_about_your(
Text::RichLangValue) | rpl::type_erased;
tr::rich) | rpl::type_erased;
if (data.level < 0) {
auto text = (data.stars < 0)
? tr::lng_stars_rating_negative_your(
lt_count_decimal,
rpl::single(-data.stars * 1.),
Text::RichLangValue)
tr::rich)
: tr::lng_stars_rating_negative(
lt_name,
rpl::single(TextWithEntities{ name }),
Text::RichLangValue);
tr::rich);
box->addRow(
object_ptr<FlatLabel>(
box,
@@ -289,8 +289,8 @@ void AboutRatingBox(
tr::now,
lt_arrow,
Text::IconEmoji(&st::textMoreIconEmoji),
Text::WithEntities)),
Text::RichLangValue);
tr::marked)),
tr::rich);
});
const auto aboutPending = box->addRow(
object_ptr<FlatLabel>(
@@ -342,7 +342,7 @@ void AboutRatingBox(
tr::now,
lt_emoji,
makeActive(tr::lng_stars_rating_added(tr::now)),
Text::RichLangValue),
tr::rich),
},
{
st::menuIconRatingUsers,
@@ -351,7 +351,7 @@ void AboutRatingBox(
tr::now,
lt_emoji,
makeActive(tr::lng_stars_rating_added(tr::now)),
Text::RichLangValue),
tr::rich),
},
{
st::menuIconRatingRefund,
@@ -360,7 +360,7 @@ void AboutRatingBox(
tr::now,
lt_emoji,
makeInactive(tr::lng_stars_rating_deducted(tr::now)),
Text::RichLangValue),
tr::rich),
},
};
const auto context = helper.context();

View File

@@ -310,8 +310,8 @@ void UserpicButton::choosePhotoLocally() {
? (*phrase)(
tr::now,
lt_user,
Ui::Text::Bold(name),
Ui::Text::WithEntities)
tr::bold(name),
tr::marked)
: TextWithEntities()),
.confirm = ((type == ChosenType::Suggest)
? tr::lng_profile_suggest_button(tr::now)

View File

@@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h" // Ui::FlatLabel
#include "ui/widgets/buttons.h" // Ui::IconButton
#include "ui/wrap/slide_wrap.h" // Ui::SlideWrap
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
#include "base/platform/base_platform_info.h"
#include "lang/lang_keys.h"
#include "styles/style_window.h"
@@ -47,15 +46,15 @@ private:
[[nodiscard]] rpl::producer<QString> OutdatedReasonPhrase() {
const auto why = Platform::WhySystemBecomesOutdated();
return (why == Platform::OutdateReason::Is32Bit)
? tr::lng_outdated_title_bits()
: tr::lng_outdated_title();
? tr::lng_outdated_title_bits(tr::upper)
: tr::lng_outdated_title(tr::upper);
}
Bar::Bar(not_null<QWidget*> parent, QDate date)
: _date(date)
, _title(
this,
OutdatedReasonPhrase() | Text::ToUpper(),
OutdatedReasonPhrase(),
st::windowOutdatedTitle)
, _details(this,
QString(),

View File

@@ -756,7 +756,7 @@ void ShowListBox(
const auto title = content->add(
object_ptr<Ui::FlatLabel>(
content,
base::take(entry.title) | Ui::Text::ToBold(),
base::take(entry.title) | rpl::map(tr::bold),
stLabel),
entry.icon ? iconTitlePadding : titlePadding);
content->add(

View File

@@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "ui/vertical_list.h"
#include "ui/text/text_utilities.h"
#include "lang/lang_text_entity.h"
#include "ui/widgets/box_content_divider.h"
#include "ui/widgets/labels.h"
#include "ui/wrap/padding_wrap.h"
@@ -41,7 +41,7 @@ not_null<Ui::FlatLabel*> AddDividerText(
RectParts parts) {
return AddDividerText(
container,
std::move(text) | Ui::Text::ToWithEntities(),
std::move(text) | rpl::map(tr::marked),
margins,
st,
parts);

View File

@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_peer.h"
#include "info/profile/info_profile_values.h"
#include "lang/lang_text_entity.h"
#include "ui/controls/userpic_button.h"
#include "ui/rect.h"
#include "ui/text/text_utilities.h"
@@ -151,8 +152,8 @@ void AddExpandablePeerList(
using namespace Info::Profile;
auto name = controller->data.bold
? NameValue(peer) | Ui::Text::ToBold()
: NameValue(peer) | Ui::Text::ToWithEntities();
? NameValue(peer) | rpl::map(tr::bold)
: NameValue(peer) | rpl::map(tr::marked);
const auto userpic
= Ui::CreateChild<Ui::UserpicButton>(line, peer, st);
const auto checkbox = Ui::CreateChild<Ui::Checkbox>(