diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 7af0eaabf..e70464ef0 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -1751,18 +1751,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } if (const auto media = item->media()) { if (const auto poll = media->poll()) { - if (!poll->closed()) { - if (poll->voted() && !poll->quiz()) { - _menu->addAction(tr::lng_polls_retract(tr::now), [=] { - session->api().sendPollVotes(itemId, {}); - }); - } - if (item->canStopPoll()) { - _menu->addAction(tr::lng_polls_stop(tr::now), [=] { - HistoryView::StopPoll(session, itemId); - }); - } - } + HistoryView::AddPollActions( + _menu, + poll, + item, + HistoryView::Context::History); } else if (const auto contact = media->sharedContact()) { const auto phone = contact->phoneNumber; _menu->addAction(tr::lng_profile_copy_phone(tr::now), [=] { diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 4eb646699..dcabec08a 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -868,6 +868,9 @@ base::unique_qptr FillContextMenu( const auto document = linkDocument ? linkDocument->document().get() : nullptr; + const auto poll = item + ? (item->media() ? item->media()->poll() : nullptr) + : nullptr; const auto hasSelection = !request.selectedItems.empty() || !request.selectedText.empty(); @@ -897,6 +900,8 @@ base::unique_qptr FillContextMenu( // }); // AddToggleGroupingAction(result, linkPeer->peer()); // } + } else if (poll) { + AddPollActions(result, poll, item, list->elementContext()); } else if (!request.overSelection && view && !hasSelection) { const auto owner = &view->data()->history()->owner(); const auto media = view->media(); @@ -979,4 +984,30 @@ void StopPoll(not_null session, FullMsgId itemId) { stop)); } +void AddPollActions( + not_null menu, + not_null poll, + not_null item, + Context context) { + if ((context != Context::History) + && (context != Context::Replies) + && (context != Context::Pinned)) { + return; + } + if (poll->closed()) { + return; + } + const auto itemId = item->fullId(); + if (poll->voted() && !poll->quiz()) { + menu->addAction(tr::lng_polls_retract(tr::now), [=] { + poll->session().api().sendPollVotes(itemId, {}); + }); + } + if (item->canStopPoll()) { + menu->addAction(tr::lng_polls_stop(tr::now), [=] { + StopPoll(&poll->session(), itemId); + }); + } +} + } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.h b/Telegram/SourceFiles/history/view/history_view_context_menu.h index e33495dbe..be6f160dc 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.h +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.h @@ -49,5 +49,10 @@ void CopyPostLink( FullMsgId itemId, Context context); void StopPoll(not_null session, FullMsgId itemId); +void AddPollActions( + not_null menu, + not_null poll, + not_null item, + Context context); } // namespace diff --git a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp index 2738debf8..3d5b393da 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp @@ -765,7 +765,9 @@ void Poll::draw(Painter &p, const QRect &r, TextSelection selection, crl::time m : nullptr; if (animation) { animation->percent.update(progress, anim::linear); - animation->filling.update(progress, anim::linear); + animation->filling.update( + progress, + showVotes() ? anim::easeOutCirc : anim::linear); animation->opacity.update(progress, anim::linear); } const auto height = paintAnswer(