Got rid Ui::CreateLabelWithCustomEmoji.

This commit is contained in:
23rd
2025-08-14 18:10:20 +03:00
parent e0fb9ffbb0
commit 707af8a295
11 changed files with 21 additions and 112 deletions
-2
View File
@@ -1627,8 +1627,6 @@ PRIVATE
ui/text/format_song_document_name.h
ui/widgets/expandable_peer_list.cpp
ui/widgets/expandable_peer_list.h
ui/widgets/label_with_custom_emoji.cpp
ui/widgets/label_with_custom_emoji.h
ui/widgets/chat_filters_tabs_strip.cpp
ui/widgets/chat_filters_tabs_strip.h
ui/widgets/peer_bubble.cpp
@@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rect.h"
#include "ui/text/text_utilities.h"
#include "ui/vertical_list.h"
#include "ui/widgets/label_with_custom_emoji.h"
#include "window/window_session_controller.h"
#include "styles/style_boxes.h"
#include "styles/style_channel_earn.h"
@@ -78,7 +77,7 @@ void GiftCreditsBox(
u"internal:stars_examples"_q);
});
content->add(
Ui::CreateLabelWithCustomEmoji(
object_ptr<Ui::FlatLabel>(
content,
tr::lng_credits_box_history_entry_gift_out_about(
lt_user,
@@ -86,7 +85,6 @@ void GiftCreditsBox(
lt_link,
std::move(link),
Ui::Text::RichLangValue),
Core::TextContext({ .session = &peer->session() }),
st::creditsBoxAbout),
st::boxRowPadding,
style::al_top);
@@ -35,7 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toast/toast.h"
#include "ui/vertical_list.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/label_with_custom_emoji.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/slider_natural_width.h"
#include "ui/wrap/slide_wrap.h"
@@ -58,7 +58,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/vertical_list.h"
#include "ui/widgets/fields/input_field.h"
#include "ui/widgets/label_with_custom_emoji.h"
#include "ui/widgets/peer_bubble.h"
#include "ui/widgets/popup_menu.h"
#include "ui/widgets/slider_natural_width.h"
@@ -414,21 +413,19 @@ void InnerWidget::fill() {
const auto session = &_peer->session();
const auto withdrawalEnabled = WithdrawalEnabled(session);
const auto arrow = Ui::Text::IconEmoji(&st::textMoreIconEmoji);
const auto addAboutWithLearn = [&](const tr::phrase<lngtag_link> &text) {
auto label = Ui::CreateLabelWithCustomEmoji(
auto label = object_ptr<Ui::FlatLabel>(
container,
text(
lt_link,
tr::lng_channel_earn_about_link(
lt_emoji,
rpl::single(arrow),
rpl::single(Ui::Text::IconEmoji(&st::textMoreIconEmoji)),
Ui::Text::RichLangValue
) | rpl::map([](TextWithEntities text) {
return Ui::Text::Link(std::move(text), 1);
}),
Ui::Text::RichLangValue),
Core::TextContext({ .session = session }),
st::boxDividerLabel);
label->setLink(1, std::make_shared<LambdaClickHandler>([=] {
_show->showBox(Box([=](not_null<Ui::GenericBox*> box) {
@@ -545,7 +542,7 @@ void InnerWidget::fill() {
const auto l = box->addRow(
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
content,
Ui::CreateLabelWithCustomEmoji(
object_ptr<Ui::FlatLabel>(
content,
tr::lng_channel_earn_learn_coin_title(
lt_emoji,
@@ -553,7 +550,6 @@ void InnerWidget::fill() {
Ui::Text::Link(bigCurrencyIcon, 1)),
Ui::Text::RichLangValue
),
emojiHelper.context(),
st::boxTitle)))->entity();
const auto diamonds = l->lifetime().make_state<int>(0);
l->setLink(1, std::make_shared<LambdaClickHandler>([=] {
@@ -570,20 +566,19 @@ void InnerWidget::fill() {
Ui::AddSkip(content);
{
const auto label = box->addRow(
Ui::CreateLabelWithCustomEmoji(
object_ptr<Ui::FlatLabel>(
content,
tr::lng_channel_earn_learn_coin_about(
lt_link,
tr::lng_channel_earn_about_link(
lt_emoji,
rpl::single(arrow),
rpl::single(Ui::Text::IconEmoji(
&st::textMoreIconEmoji)),
Ui::Text::RichLangValue
) | rpl::map([](TextWithEntities text) {
return Ui::Text::Link(std::move(text), 1);
}),
Ui::Text::RichLangValue
),
Core::TextContext({ .session = session }),
Ui::Text::RichLangValue),
st::channelEarnLearnDescription));
label->resizeToWidth(box->width()
- rect::m::sum::h(st::boxRowPadding));
@@ -72,7 +72,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/vertical_list.h"
#include "ui/widgets/checkbox.h"
#include "ui/widgets/dropdown_menu.h"
#include "ui/widgets/label_with_custom_emoji.h"
#include "ui/widgets/menu/menu_item_base.h"
#include "ui/widgets/popup_menu.h"
#include "webview/webview_interface.h"
@@ -384,7 +383,7 @@ void FillBotUsepic(
not_null<Ui::GenericBox*> box,
not_null<PeerData*> bot,
base::weak_ptr<Window::SessionController> weak) {
auto aboutLabel = Ui::CreateLabelWithCustomEmoji(
auto aboutLabel = object_ptr<Ui::FlatLabel>(
box->verticalLayout(),
tr::lng_allow_bot_webview_details(
lt_emoji,
@@ -393,7 +392,6 @@ void FillBotUsepic(
) | rpl::map([](TextWithEntities text) {
return Ui::Text::Link(std::move(text), u"internal:"_q);
}),
Core::TextContext({ .session = &bot->session() }),
st::defaultFlatLabel);
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
box->verticalLayout(),
+4 -8
View File
@@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toast/toast.h"
#include "ui/vertical_list.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/label_with_custom_emoji.h"
#include "ui/widgets/menu/menu_add_action_callback.h"
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
#include "ui/widgets/menu/menu_multiline_action.h"
@@ -96,12 +95,10 @@ void AboutBox(
tr::lng_sponsored_menu_revenued_about(),
st::boxTitle)));
Ui::AddSkip(content);
box->addRow(object_ptr<Ui::CenterWrap<>>(
box->addRow(object_ptr<Ui::FlatLabel>(
content,
object_ptr<Ui::FlatLabel>(
content,
tr::lng_sponsored_revenued_subtitle(),
st::channelEarnLearnDescription)));
tr::lng_sponsored_revenued_subtitle(),
st::channelEarnLearnDescription));
Ui::AddSkip(content);
Ui::AddSkip(content);
{
@@ -224,7 +221,7 @@ void AboutBox(
const auto available = box->width()
- rect::m::sum::h(st::boxRowPadding);
box->addRow(
Ui::CreateLabelWithCustomEmoji(
object_ptr<Ui::FlatLabel>(
content,
(isChannel
? tr::lng_sponsored_revenued_footer_description
@@ -240,7 +237,6 @@ void AboutBox(
return Ui::Text::Link(std::move(t), kUrl.utf16());
}),
Ui::Text::RichLangValue),
Core::TextContext({ .session = session }),
st::channelEarnLearnDescription))->resizeToWidth(available);
}
Ui::AddSkip(content);
@@ -41,7 +41,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/widgets/checkbox.h" // Ui::RadiobuttonGroup.
#include "ui/widgets/gradient_round_button.h"
#include "ui/widgets/label_with_custom_emoji.h"
#include "ui/wrap/fade_wrap.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/wrap/vertical_layout.h"
@@ -524,24 +523,23 @@ void Business::setupContent() {
const auto session = &_controller->session();
{
const auto arrow = Ui::Text::IconEmoji(&st::textMoreIconEmoji);
inner->add(object_ptr<Ui::DividerLabel>(
inner,
Ui::CreateLabelWithCustomEmoji(
object_ptr<Ui::FlatLabel>(
inner,
tr::lng_business_about_sponsored(
lt_link,
rpl::combine(
tr::lng_business_about_sponsored_link(
lt_emoji,
rpl::single(arrow),
rpl::single(Ui::Text::IconEmoji(
&st::textMoreIconEmoji)),
Ui::Text::RichLangValue),
tr::lng_business_about_sponsored_url()
) | rpl::map([](TextWithEntities text, QString url) {
return Ui::Text::Link(text, url);
}),
Ui::Text::RichLangValue),
Core::TextContext({ .session = session }),
st::boxDividerLabel),
st::defaultBoxDividerLabelPadding,
RectPart::Top | RectPart::Bottom));
@@ -86,7 +86,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/discrete_sliders.h"
#include "ui/widgets/fields/number_input.h"
#include "ui/widgets/popup_menu.h"
#include "ui/widgets/label_with_custom_emoji.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/tooltip.h"
#include "ui/wrap/fade_wrap.h"
@@ -1694,7 +1693,7 @@ void GenericCreditsEntryBox(
u"internal:stars_examples"_q);
});
box->addRow(
Ui::CreateLabelWithCustomEmoji(
object_ptr<Ui::FlatLabel>(
box,
(!e.in && peer)
? tr::lng_credits_box_history_entry_gift_out_about(
@@ -1707,7 +1706,6 @@ void GenericCreditsEntryBox(
lt_link,
std::move(link),
Ui::Text::RichLangValue),
Core::TextContext({ .session = session }),
st::creditsBoxAbout),
st::boxRowPadding,
style::al_top);
@@ -1724,7 +1722,7 @@ void GenericCreditsEntryBox(
});
const auto percent = 100. - (e.paidMessagesCommission / 10.);
box->addRow(
Ui::CreateLabelWithCustomEmoji(
object_ptr<Ui::FlatLabel>(
box,
tr::lng_credits_paid_messages_fee_about(
lt_percent,
@@ -1733,7 +1731,6 @@ void GenericCreditsEntryBox(
lt_link,
std::move(link),
Ui::Text::RichLangValue),
Core::TextContext({ .session = session }),
st::creditsBoxAbout),
st::boxRowPadding,
style::al_top);
@@ -2913,8 +2910,7 @@ void AddWithdrawalWidget(
Ui::AddSkip(container);
Ui::AddSkip(container);
const auto arrow = Ui::Text::IconEmoji(&st::textMoreIconEmoji);
auto about = Ui::CreateLabelWithCustomEmoji(
auto about = object_ptr<Ui::FlatLabel>(
container,
(peer->isSelf()
? tr::lng_self_earn_learn_credits_out_about
@@ -2922,7 +2918,7 @@ void AddWithdrawalWidget(
lt_link,
tr::lng_channel_earn_about_link(
lt_emoji,
rpl::single(arrow),
rpl::single(Ui::Text::IconEmoji(&st::textMoreIconEmoji)),
Ui::Text::RichLangValue
) | rpl::map([](TextWithEntities text) {
return Ui::Text::Link(
@@ -2930,7 +2926,6 @@ void AddWithdrawalWidget(
tr::lng_bot_earn_balance_about_url(tr::now));
}),
Ui::Text::RichLangValue),
{},
st::boxDividerLabel);
Ui::AddSkip(container);
container->add(object_ptr<Ui::DividerLabel>(
@@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/vertical_list.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/fields/number_input.h"
#include "ui/widgets/label_with_custom_emoji.h"
#include "ui/widgets/labels.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/wrap/vertical_layout.h"
@@ -129,7 +128,7 @@ InviteLinkSubscriptionToggle FillCreateInviteLinkSubscriptionToggle(
state->usdRate = peer->session().credits().rateValue(peer);
auto about = Ui::CreateLabelWithCustomEmoji(
auto about = object_ptr<Ui::FlatLabel>(
container,
tr::lng_group_invite_subscription_about(
lt_link,
@@ -143,7 +142,6 @@ InviteLinkSubscriptionToggle FillCreateInviteLinkSubscriptionToggle(
tr::lng_group_invite_subscription_about_url(tr::now));
}),
Ui::Text::RichLangValue),
Core::TextContext({ .session = &peer->session() }),
st::boxDividerLabel);
Ui::AddSkip(wrap->entity());
Ui::AddSkip(wrap->entity());
@@ -1,31 +0,0 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "ui/widgets/label_with_custom_emoji.h"
#include "core/ui_integration.h"
#include "ui/widgets/labels.h"
#include "styles/style_widgets.h"
namespace Ui {
object_ptr<Ui::FlatLabel> CreateLabelWithCustomEmoji(
QWidget *parent,
rpl::producer<TextWithEntities> &&text,
Text::MarkedContext context,
const style::FlatLabel &st) {
auto label = object_ptr<Ui::FlatLabel>(parent, st);
const auto raw = label.data();
context.repaint = [=] { raw->update(); };
std::move(text) | rpl::start_with_next([=](const TextWithEntities &text) {
raw->setMarkedText(text, context);
}, label->lifetime());
return label;
}
} // namespace Ui
@@ -1,35 +0,0 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
template <typename Object>
class object_ptr;
namespace Main {
class Session;
} // namespace Main
namespace style {
struct FlatLabel;
} // namespace style
namespace Ui::Text {
struct MarkedContext;
} // namespace Ui::Text
namespace Ui {
class FlatLabel;
[[nodiscard]] object_ptr<Ui::FlatLabel> CreateLabelWithCustomEmoji(
QWidget *parent,
rpl::producer<TextWithEntities> &&text,
Text::MarkedContext context,
const style::FlatLabel &st);
} // namespace Ui