MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / ConfirmInviteBox

Function ConfirmInviteBox

Telegram/SourceFiles/api/api_chat_invite.cpp:436–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434}
435
436void ConfirmInviteBox(
437 not_null<Ui::GenericBox*> box,
438 not_null<Main::Session*> session,
439 const MTPDchatInvite *invitePtr,
440 ChannelData *invitePeekChannel,
441 Fn<void()> submit) {
442 auto invite = ParseInvite(session, *invitePtr);
443 const auto isChannel = invite.isChannel && !invite.isMegagroup;
444 const auto requestApprove = invite.isRequestNeeded;
445 const auto count = invite.participantsCount;
446
447 struct State {
448 std::shared_ptr<Data::PhotoMedia> photoMedia;
449 std::unique_ptr<Ui::EmptyUserpic> photoEmpty;
450 std::vector<InviteParticipant> participants;
451 };
452 const auto state = box->lifetime().make_state<State>();
453 state->participants = std::move(invite.participants);
454
455 const auto status = [&] {
456 return invitePeekChannel
457 ? tr::lng_channel_invite_private(tr::now)
458 : (!state->participants.empty()
459 && int(state->participants.size()) < count)
460 ? tr::lng_group_invite_members(tr::now, lt_count, count)
461 : (count > 0 && isChannel)
462 ? tr::lng_chat_status_subscribers(
463 tr::now,
464 lt_count_decimal,
465 count)
466 : (count > 0)
467 ? tr::lng_chat_status_members(tr::now, lt_count_decimal, count)
468 : isChannel
469 ? tr::lng_channel_status(tr::now)
470 : tr::lng_group_status(tr::now);
471 }();
472
473 box->setNoContentMargin(true);
474 box->setWidth(st::boxWideWidth);
475 const auto content = box->verticalLayout();
476
477 Ui::AddSkip(content, st::confirmInvitePhotoTop);
478 const auto userpic = content->add(
479 object_ptr<Ui::RpWidget>(content),
480 style::al_top);
481 const auto photoSize = st::confirmInvitePhotoSize;
482 userpic->resize(Size(photoSize));
483 userpic->setNaturalWidth(photoSize);
484 userpic->paintRequest(
485 ) | rpl::on_next([=, small = Data::PhotoSize::Small] {
486 auto p = QPainter(userpic);
487 if (state->photoMedia) {
488 if (const auto image = state->photoMedia->image(small)) {
489 p.drawPixmap(
490 0,
491 0,
492 image->pix(
493 Size(photoSize),

Callers

nothing calls this directly

Calls 15

ParseInviteFunction · 0.85
BadgeForInviteFunction · 0.85
resizeMethod · 0.80
paintCircleMethod · 0.80
wantedMethod · 0.80
moveToLeftMethod · 0.80
paintUserpicLeftMethod · 0.80
FileOriginClass · 0.70
AddSkipFunction · 0.50
QPainterClass · 0.50
PainterClass · 0.50

Tested by

no test coverage detected