From b6fa6a369199be74b40b28da1ecce774cf6f2bdd Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 17 Jul 2026 17:47:15 +0300 Subject: [PATCH] Added folder context menu to community link in profile. --- .../info/profile/info_profile_actions.cpp | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index cb2887a23b..7c0695b89f 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/qt/qt_key_modifiers.h" #include "base/timer_rpl.h" #include "base/unixtime.h" +#include "boxes/choose_filter_box.h" #include "boxes/peer_list_box.h" #include "boxes/peers/add_bot_to_chat_box.h" #include "boxes/peers/edit_contact_box.h" @@ -38,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_changes.h" #include "data/data_channel.h" #include "data/data_chat.h" +#include "data/data_chat_filters.h" #include "data/data_folder.h" #include "data/data_forum.h" #include "data/data_forum_topic.h" @@ -2554,8 +2556,12 @@ Section DetailsFiller::makeCommunityLink(not_null peer) { class Controller final : public PeerListController { public: - Controller(not_null community, Fn open) - : _community(community) + Controller( + not_null window, + not_null community, + Fn open) + : _window(window) + , _community(community) , _open(std::move(open)) { setStyleOverrides(&st::peerListSingleRow); } @@ -2592,8 +2598,33 @@ Section DetailsFiller::makeCommunityLink(not_null peer) { void rowClicked(not_null row) override { _open(); } + base::unique_qptr rowContextMenu( + QWidget *parent, + not_null row) override { + const auto history = _community->owner().history(_community); + if (!history->owner().chatsFilters().has() + || !history->inChatList() + || (_community->isCommunity() + && !_community->collapsedInDialogs())) { + return nullptr; + } + auto result = base::make_unique_q( + parent, + st::popupMenuWithIcons); + Ui::Menu::CreateAddActionCallback(result.get())({ + .text = tr::lng_filters_menu_add(tr::now), + .handler = nullptr, + .icon = &st::menuIconAddToFolder, + .fillSubmenu = [&](not_null submenu) { + FillChooseFilterMenu(_window, submenu, history); + }, + .submenuSt = &st::foldersMenu, + }); + return result; + } private: + const not_null _window; const not_null _community; Fn _open; @@ -2603,6 +2634,7 @@ Section DetailsFiller::makeCommunityLink(not_null peer) { PeerListContentDelegateSimple >(); const auto controller = container->lifetime().make_state( + window, community, [=] { window->showPeerInfo(community); }); const auto content = container->add(object_ptr(