Fix camera preview in Calls Settings.

This commit is contained in:
John Preston 2022-03-07 12:33:48 +04:00
parent 98f2f6d4c0
commit 7e617b7f39
1 changed files with 21 additions and 21 deletions

View File

@ -148,30 +148,30 @@ void Calls::setupContent() {
const auto top = st::boxRoundShadow.extend.top();
const auto bottom = st::boxRoundShadow.extend.bottom();
bubbleWrap->widthValue(
auto frameSize = track->renderNextFrame(
) | rpl::map([=] {
return track->frameSize();
}) | rpl::filter([=](QSize size) {
return !size.isEmpty()
&& !Core::App().calls().currentCall()
&& !Core::App().calls().currentGroupCall();
});
auto bubbleWidth = bubbleWrap->widthValue(
) | rpl::filter([=](int width) {
return (width > 2 * padding + 1);
}) | rpl::start_with_next([=](int width) {
const auto use = (width - 2 * padding);
return width > 2 * padding + 1;
});
rpl::combine(
std::move(bubbleWidth),
std::move(frameSize)
) | rpl::start_with_next([=](int width, QSize frame) {
const auto useWidth = (width - 2 * padding);
const auto useHeight = std::min(
((useWidth * frame.height()) / frame.width()),
(useWidth * 480) / 640);
bubbleWrap->resize(width, top + useHeight + bottom);
bubble->updateGeometry(
::Calls::VideoBubble::DragMode::None,
QRect(padding, top, use, (use * 480) / 640));
}, bubbleWrap->lifetime());
track->renderNextFrame(
) | rpl::start_with_next([=] {
const auto size = track->frameSize();
if (size.isEmpty()
|| Core::App().calls().currentCall()
|| Core::App().calls().currentGroupCall()) {
return;
}
const auto width = bubbleWrap->width();
const auto use = (width - 2 * padding);
const auto height = std::min(
((use * size.height()) / size.width()),
(use * 480) / 640);
bubbleWrap->resize(width, top + height + bottom);
QRect(padding, top, useWidth, useHeight));
bubbleWrap->update();
}, bubbleWrap->lifetime());