From 707af8a29546a09c7cf30ef40091e4e6b4b0cbfc Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 14 Aug 2025 18:10:20 +0300 Subject: [PATCH] Got rid Ui::CreateLabelWithCustomEmoji. --- Telegram/CMakeLists.txt | 2 -- .../SourceFiles/boxes/gift_credits_box.cpp | 4 +-- .../info/bot/earn/info_bot_earn_list.cpp | 1 - .../earn/info_channel_earn_list.cpp | 19 ++++------ .../inline_bots/bot_attach_web_view.cpp | 4 +-- Telegram/SourceFiles/menu/menu_sponsored.cpp | 12 +++---- .../settings/settings_business.cpp | 8 ++--- .../settings/settings_credits_graphics.cpp | 13 +++---- .../ui/boxes/edit_invite_link_session.cpp | 4 +-- .../ui/widgets/label_with_custom_emoji.cpp | 31 ---------------- .../ui/widgets/label_with_custom_emoji.h | 35 ------------------- 11 files changed, 21 insertions(+), 112 deletions(-) delete mode 100644 Telegram/SourceFiles/ui/widgets/label_with_custom_emoji.cpp delete mode 100644 Telegram/SourceFiles/ui/widgets/label_with_custom_emoji.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index d01f72ec9f..963205f75a 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -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 diff --git a/Telegram/SourceFiles/boxes/gift_credits_box.cpp b/Telegram/SourceFiles/boxes/gift_credits_box.cpp index f96069a1b3..e3c915c770 100644 --- a/Telegram/SourceFiles/boxes/gift_credits_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_credits_box.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( 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); diff --git a/Telegram/SourceFiles/info/bot/earn/info_bot_earn_list.cpp b/Telegram/SourceFiles/info/bot/earn/info_bot_earn_list.cpp index 620ff8ada9..89747650f5 100644 --- a/Telegram/SourceFiles/info/bot/earn/info_bot_earn_list.cpp +++ b/Telegram/SourceFiles/info/bot/earn/info_bot_earn_list.cpp @@ -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" diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp index 1f5105e164..20445954ce 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp @@ -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 &text) { - auto label = Ui::CreateLabelWithCustomEmoji( + auto label = object_ptr( 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([=] { _show->showBox(Box([=](not_null box) { @@ -545,7 +542,7 @@ void InnerWidget::fill() { const auto l = box->addRow( object_ptr>( content, - Ui::CreateLabelWithCustomEmoji( + object_ptr( 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(0); l->setLink(1, std::make_shared([=] { @@ -570,20 +566,19 @@ void InnerWidget::fill() { Ui::AddSkip(content); { const auto label = box->addRow( - Ui::CreateLabelWithCustomEmoji( + object_ptr( 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)); diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index be8fbdbefa..4f21817adc 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -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 box, not_null bot, base::weak_ptr weak) { - auto aboutLabel = Ui::CreateLabelWithCustomEmoji( + auto aboutLabel = object_ptr( 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( box->verticalLayout(), diff --git a/Telegram/SourceFiles/menu/menu_sponsored.cpp b/Telegram/SourceFiles/menu/menu_sponsored.cpp index 2073239170..656d5053a5 100644 --- a/Telegram/SourceFiles/menu/menu_sponsored.cpp +++ b/Telegram/SourceFiles/menu/menu_sponsored.cpp @@ -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>( + box->addRow(object_ptr( content, - object_ptr( - 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( 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); diff --git a/Telegram/SourceFiles/settings/settings_business.cpp b/Telegram/SourceFiles/settings/settings_business.cpp index a619971545..384a11faaf 100644 --- a/Telegram/SourceFiles/settings/settings_business.cpp +++ b/Telegram/SourceFiles/settings/settings_business.cpp @@ -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( inner, - Ui::CreateLabelWithCustomEmoji( + object_ptr( 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)); diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 2ef4636fd9..a08d5594d1 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -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( 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( 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( 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( diff --git a/Telegram/SourceFiles/ui/boxes/edit_invite_link_session.cpp b/Telegram/SourceFiles/ui/boxes/edit_invite_link_session.cpp index f868cc3e97..2f09147979 100644 --- a/Telegram/SourceFiles/ui/boxes/edit_invite_link_session.cpp +++ b/Telegram/SourceFiles/ui/boxes/edit_invite_link_session.cpp @@ -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( 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()); diff --git a/Telegram/SourceFiles/ui/widgets/label_with_custom_emoji.cpp b/Telegram/SourceFiles/ui/widgets/label_with_custom_emoji.cpp deleted file mode 100644 index 69f1d5f14f..0000000000 --- a/Telegram/SourceFiles/ui/widgets/label_with_custom_emoji.cpp +++ /dev/null @@ -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 CreateLabelWithCustomEmoji( - QWidget *parent, - rpl::producer &&text, - Text::MarkedContext context, - const style::FlatLabel &st) { - auto label = object_ptr(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 diff --git a/Telegram/SourceFiles/ui/widgets/label_with_custom_emoji.h b/Telegram/SourceFiles/ui/widgets/label_with_custom_emoji.h deleted file mode 100644 index 662ce0fa7b..0000000000 --- a/Telegram/SourceFiles/ui/widgets/label_with_custom_emoji.h +++ /dev/null @@ -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 -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 CreateLabelWithCustomEmoji( - QWidget *parent, - rpl::producer &&text, - Text::MarkedContext context, - const style::FlatLabel &st); - -} // namespace Ui