mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
parent
d557e0f2b7
commit
0bdb38753b
4 changed files with 44 additions and 13 deletions
|
@ -1751,18 +1751,11 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
}
|
}
|
||||||
if (const auto media = item->media()) {
|
if (const auto media = item->media()) {
|
||||||
if (const auto poll = media->poll()) {
|
if (const auto poll = media->poll()) {
|
||||||
if (!poll->closed()) {
|
HistoryView::AddPollActions(
|
||||||
if (poll->voted() && !poll->quiz()) {
|
_menu,
|
||||||
_menu->addAction(tr::lng_polls_retract(tr::now), [=] {
|
poll,
|
||||||
session->api().sendPollVotes(itemId, {});
|
item,
|
||||||
});
|
HistoryView::Context::History);
|
||||||
}
|
|
||||||
if (item->canStopPoll()) {
|
|
||||||
_menu->addAction(tr::lng_polls_stop(tr::now), [=] {
|
|
||||||
HistoryView::StopPoll(session, itemId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (const auto contact = media->sharedContact()) {
|
} else if (const auto contact = media->sharedContact()) {
|
||||||
const auto phone = contact->phoneNumber;
|
const auto phone = contact->phoneNumber;
|
||||||
_menu->addAction(tr::lng_profile_copy_phone(tr::now), [=] {
|
_menu->addAction(tr::lng_profile_copy_phone(tr::now), [=] {
|
||||||
|
|
|
@ -868,6 +868,9 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
const auto document = linkDocument
|
const auto document = linkDocument
|
||||||
? linkDocument->document().get()
|
? linkDocument->document().get()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
const auto poll = item
|
||||||
|
? (item->media() ? item->media()->poll() : nullptr)
|
||||||
|
: nullptr;
|
||||||
const auto hasSelection = !request.selectedItems.empty()
|
const auto hasSelection = !request.selectedItems.empty()
|
||||||
|| !request.selectedText.empty();
|
|| !request.selectedText.empty();
|
||||||
|
|
||||||
|
@ -897,6 +900,8 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
||||||
// });
|
// });
|
||||||
// AddToggleGroupingAction(result, linkPeer->peer());
|
// AddToggleGroupingAction(result, linkPeer->peer());
|
||||||
// }
|
// }
|
||||||
|
} else if (poll) {
|
||||||
|
AddPollActions(result, poll, item, list->elementContext());
|
||||||
} else if (!request.overSelection && view && !hasSelection) {
|
} else if (!request.overSelection && view && !hasSelection) {
|
||||||
const auto owner = &view->data()->history()->owner();
|
const auto owner = &view->data()->history()->owner();
|
||||||
const auto media = view->media();
|
const auto media = view->media();
|
||||||
|
@ -979,4 +984,30 @@ void StopPoll(not_null<Main::Session*> session, FullMsgId itemId) {
|
||||||
stop));
|
stop));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddPollActions(
|
||||||
|
not_null<Ui::PopupMenu*> menu,
|
||||||
|
not_null<PollData*> poll,
|
||||||
|
not_null<HistoryItem*> 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
|
} // namespace HistoryView
|
||||||
|
|
|
@ -49,5 +49,10 @@ void CopyPostLink(
|
||||||
FullMsgId itemId,
|
FullMsgId itemId,
|
||||||
Context context);
|
Context context);
|
||||||
void StopPoll(not_null<Main::Session*> session, FullMsgId itemId);
|
void StopPoll(not_null<Main::Session*> session, FullMsgId itemId);
|
||||||
|
void AddPollActions(
|
||||||
|
not_null<Ui::PopupMenu*> menu,
|
||||||
|
not_null<PollData*> poll,
|
||||||
|
not_null<HistoryItem*> item,
|
||||||
|
Context context);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -765,7 +765,9 @@ void Poll::draw(Painter &p, const QRect &r, TextSelection selection, crl::time m
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (animation) {
|
if (animation) {
|
||||||
animation->percent.update(progress, anim::linear);
|
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);
|
animation->opacity.update(progress, anim::linear);
|
||||||
}
|
}
|
||||||
const auto height = paintAnswer(
|
const auto height = paintAnswer(
|
||||||
|
|
Loading…
Add table
Reference in a new issue