From aa29d1c6193a97c626253b26298b27f0cac7d65b Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 27 Nov 2023 10:21:22 +0400 Subject: [PATCH] Allow select single album part under spoiler. --- .../history/history_inner_widget.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index dfc8398549..179031ed42 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2362,9 +2362,14 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } }; - const auto addSelectMessageAction = [&]( - not_null item, - bool asGroup = true) { + const auto asGroup = !Element::Moused() + || (Element::Moused() != Element::Hovered()) + || (Element::Moused()->pointState( + mapPointToItem( + mapFromGlobal(_mousePosition), + Element::Moused()) + ) != HistoryView::PointState::GroupPart); + const auto addSelectMessageAction = [&](not_null item) { if (item->isRegular() && !item->isService() && !hasSelectRestriction()) { @@ -2523,7 +2528,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { }, &st::menuIconReport); } } - addSelectMessageAction(item, false); + addSelectMessageAction(item); if (isUponSelected != -2 && blockSender) { _menu->addAction(tr::lng_profile_block_user(tr::now), [=] { blockSenderItem(itemId); @@ -2540,6 +2545,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { : nullptr; return result ? groupLeaderOrSelf(result) : nullptr; }(); + const auto partItemOrLeader = (asGroup || !albumPartItem) + ? item + : albumPartItem; const auto itemId = item ? item->fullId() : FullMsgId(); const auto canDelete = item && item->canDelete() @@ -2576,7 +2584,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } addItemActions(item, item); } else { - addReplyAction(item); + addReplyAction(partItemOrLeader); addItemActions(item, albumPartItem); if (item && !isUponSelected) { const auto media = (view ? view->media() : nullptr); @@ -2723,7 +2731,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { }, &st::menuIconReport); } } - addSelectMessageAction(item); + addSelectMessageAction(partItemOrLeader); if (isUponSelected != -2 && canBlockSender) { _menu->addAction(tr::lng_profile_block_user(tr::now), [=] { blockSenderAsGroup(itemId);