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()) {
const auto pinnedEndpoint = _call->videoEndpointPinned()
? _call->videoEndpointLarge().endpoint
: std::string();
const auto participant = real->participantByEndpoint(pinnedEndpoint);
if (participant && participant->peer == participantPeer) {
result->addAction(
tr::lng_group_call_context_unpin_camera(tr::now),
[=] { _call->pinVideoEndpoint(VideoEndpoint()); });
} else if (const auto participant = real->participantByPeer(
participantPeer)) {
const auto participant = real->participantByPeer(participantPeer);
if (participant) {
const auto pinnedEndpoint = _call->videoEndpointPinned()
? _call->videoEndpointLarge().endpoint
: std::string();
const auto &camera = computeCameraEndpoint(participant);
const auto &screen = computeScreenEndpoint(participant);
const auto streamsScreen = _call->streamsVideo(screen);
if (streamsScreen || _call->streamsVideo(camera)) {
const auto callback = [=] {
_call->pinVideoEndpoint(VideoEndpoint{
participantPeer,
streamsScreen ? screen : camera });
};
result->addAction(
tr::lng_group_call_context_pin_camera(tr::now),
callback);
if (_call->streamsVideo(camera)) {
if (pinnedEndpoint == camera) {
result->addAction(
tr::lng_group_call_context_unpin_camera(tr::now),
[=] { _call->pinVideoEndpoint(VideoEndpoint()); });
} else {
result->addAction(
tr::lng_group_call_context_pin_camera(tr::now),
[=] { _call->pinVideoEndpoint(VideoEndpoint{
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([=] {
enlargeVideo();
}, _callLifetime);
_call->videoEndpointPinnedValue(
) | rpl::filter([=](bool pinned) {
return pinned && (_mode == PanelMode::Default);
}) | rpl::start_with_next([=] {
enlargeVideo();
}, _callLifetime);
}
void Panel::enlargeVideo() {