From 6eb486d885666a885bebaf629b1dc974596eae74 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 28 Mar 2026 23:08:00 +0300 Subject: [PATCH] Added hidden-results poll info label to context menu. --- .../history/history_inner_widget.cpp | 8 ++++++ .../view/history_view_context_menu.cpp | 27 +++++++++++++++++++ .../history/view/history_view_context_menu.h | 2 ++ 3 files changed, 37 insertions(+) diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 64dbcb7ccc..fef075cc05 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -3417,6 +3417,14 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { }); } + if (leaderOrSelf && !_menu->empty()) { + const auto media = leaderOrSelf->media(); + const auto poll = media ? media->poll() : nullptr; + if (poll && !poll->closed() && poll->hideResultsUntilClose()) { + HistoryView::InsertPollHiddenResultsLabel(_menu.get()); + } + } + if (_menu->empty()) { _menu = nullptr; return; diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 651dceb869..4c37b01f43 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/menu/menu_action.h" #include "ui/widgets/menu/menu_common.h" #include "ui/widgets/menu/menu_multiline_action.h" +#include "ui/widgets/menu/menu_separator.h" #include "ui/image/image.h" #include "ui/toast/toast.h" #include "ui/text/format_song_document_name.h" @@ -1274,6 +1275,24 @@ void ShowWhoReadInfo( } // namespace +void InsertPollHiddenResultsLabel(not_null menu) { + auto label = base::make_unique_q( + menu->menu(), + menu->st().menu, + st::historyHasCustomEmoji, + st::historyHasCustomEmojiPosition, + tr::lng_polls_context_ends(tr::now, tr::rich)); + menu->insertAction(0, std::move(label)); + const auto sepAction = new QAction(menu->menu()); + sepAction->setSeparator(true); + auto separator = base::make_unique_q( + menu->menu(), + menu->st().menu, + menu->st().menu.separator, + sepAction); + menu->insertAction(1, std::move(separator)); +} + ContextMenuRequest::ContextMenuRequest( not_null navigation) : navigation(navigation) { @@ -1442,6 +1461,14 @@ base::unique_qptr FillContextMenu( // Build the full message menu. FillContextMenuItems(result, list, request, hasPollOption); + if (item) { + const auto media = item->media(); + const auto poll = media ? media->poll() : nullptr; + if (poll && !poll->closed() && poll->hideResultsUntilClose()) { + InsertPollHiddenResultsLabel(result.get()); + } + } + if (hasPollOption) { const auto raw = result.get(); const auto owner = &item->history()->owner(); diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.h b/Telegram/SourceFiles/history/view/history_view_context_menu.h index 81ac0a1b24..3ddb3e1b97 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.h +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.h @@ -58,6 +58,8 @@ base::unique_qptr FillContextMenu( not_null list, const ContextMenuRequest &request); +void InsertPollHiddenResultsLabel(not_null menu); + void CopyPostLink( not_null controller, FullMsgId itemId,