From 2de08746acebaba62f7d227a13f352363c70b3e7 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 19 Nov 2025 12:49:26 +0300 Subject: [PATCH] Added toast to topic icon in profile top bar. --- Telegram/Resources/langs/lang.strings | 1 + .../info/profile/info_profile_top_bar.cpp | 37 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index a4fe1d4106..dc292e101b 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1592,6 +1592,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_profile_administrators#one" = "{count} administrator"; "lng_profile_administrators#other" = "{count} administrators"; "lng_profile_manage" = "Channel settings"; +"lng_profile_topic_toast" = "This topic contains {name}"; "lng_invite_upgrade_title" = "Upgrade to Premium"; "lng_invite_upgrade_group_invite#one" = "{users} only accepts invitations to groups from Contacts and **Premium** users."; diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp index 8efba0ef49..485509c9dd 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp @@ -89,6 +89,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/themes/window_theme.h" #include "window/window_peer_menu.h" #include "window/window_session_controller.h" +#include "ui/text/text_utilities.h" +#include "ui/toast/toast.h" +#include "boxes/sticker_set_box.h" #include "styles/style_boxes.h" #include "styles/style_chat_helpers.h" #include "styles/style_chat.h" @@ -1230,7 +1233,39 @@ void TopBar::setupUserpicButton( (*menu)->popup(QCursor::pos()); } else if (button == Qt::LeftButton) { - if (_hasStories) { + if (_topicIconView && _topic && _topic->iconId()) { + const auto document = _peer->owner().document( + _topic->iconId()); + if (const auto sticker = document->sticker()) { + const auto packName + = _peer->owner().customEmojiManager().lookupSetName( + sticker->set.id); + if (!packName.isEmpty()) { + const auto text = tr::lng_profile_topic_toast( + tr::now, + lt_name, + Ui::Text::Link(packName, u"internal:"_q), + Ui::Text::WithEntities); + const auto weak = base::make_weak(controller); + controller->showToast(Ui::Toast::Config{ + .text = text, + .filter = [=, set = sticker->set]( + const ClickHandlerPtr &handler, + Qt::MouseButton) { + if (const auto strong = weak.get()) { + strong->show( + Box( + strong->uiShow(), + set, + Data::StickersType::Emoji)); + } + return false; + }, + .duration = crl::time(3000), + }); + } + } + } else if (_hasStories) { controller->openPeerStories(_peer->id); } else { openPhoto();