Add 'pin screencast' context menu item.

This commit is contained in:
John Preston 2021-05-12 15:32:42 +04:00
parent e39ffbc83c
commit bd83ed8130
2 changed files with 37 additions and 20 deletions

View file

@ -1221,28 +1221,38 @@ base::unique_qptr<Ui::PopupMenu> Members::Controller::createRowContextMenu(
}); });
if (const auto real = _call->lookupReal()) { if (const auto real = _call->lookupReal()) {
const auto pinnedEndpoint = _call->videoEndpointPinned() const auto participant = real->participantByPeer(participantPeer);
? _call->videoEndpointLarge().endpoint if (participant) {
: std::string(); const auto pinnedEndpoint = _call->videoEndpointPinned()
const auto participant = real->participantByEndpoint(pinnedEndpoint); ? _call->videoEndpointLarge().endpoint
if (participant && participant->peer == participantPeer) { : std::string();
result->addAction(
tr::lng_group_call_context_unpin_camera(tr::now),
[=] { _call->pinVideoEndpoint(VideoEndpoint()); });
} else if (const auto participant = real->participantByPeer(
participantPeer)) {
const auto &camera = computeCameraEndpoint(participant); const auto &camera = computeCameraEndpoint(participant);
const auto &screen = computeScreenEndpoint(participant); const auto &screen = computeScreenEndpoint(participant);
const auto streamsScreen = _call->streamsVideo(screen); if (_call->streamsVideo(camera)) {
if (streamsScreen || _call->streamsVideo(camera)) { if (pinnedEndpoint == camera) {
const auto callback = [=] { result->addAction(
_call->pinVideoEndpoint(VideoEndpoint{ tr::lng_group_call_context_unpin_camera(tr::now),
participantPeer, [=] { _call->pinVideoEndpoint(VideoEndpoint()); });
streamsScreen ? screen : camera }); } else {
}; result->addAction(
result->addAction( tr::lng_group_call_context_pin_camera(tr::now),
tr::lng_group_call_context_pin_camera(tr::now), [=] { _call->pinVideoEndpoint(VideoEndpoint{
callback); participantPeer,
camera }); });
}
}
if (_call->streamsVideo(screen)) {
if (pinnedEndpoint == screen) {
result->addAction(
tr::lng_group_call_context_unpin_screen(tr::now),
[=] { _call->pinVideoEndpoint(VideoEndpoint()); });
} else {
result->addAction(
tr::lng_group_call_context_pin_screen(tr::now),
[=] { _call->pinVideoEndpoint(VideoEndpoint{
participantPeer,
screen }); });
}
} }
} }
} }

View file

@ -976,6 +976,13 @@ void Panel::setupMembers() {
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
enlargeVideo(); enlargeVideo();
}, _callLifetime); }, _callLifetime);
_call->videoEndpointPinnedValue(
) | rpl::filter([=](bool pinned) {
return pinned && (_mode == PanelMode::Default);
}) | rpl::start_with_next([=] {
enlargeVideo();
}, _callLifetime);
} }
void Panel::enlargeVideo() { void Panel::enlargeVideo() {